Skip to content

[R23] Fix generator type identities and diagnose unsupported scopes - #28

Open
JetF0x wants to merge 1 commit into
Carsillas:rewritefrom
JetF0x:fix/review-r23
Open

JetF0x wants to merge 1 commit into
Carsillas:rewritefrom
JetF0x:fix/review-r23

Conversation

@JetF0x

@JetF0x JetF0x commented Sep 12, 2026

Copy link
Copy Markdown

Addresses review finding R23.

Generic network classes currently throw during generation, flattened namespace names can collide and cancel unrelated outputs, and nested or inaccessible types can produce invalid generated C#. This fixes R23 by encoding metadata identities into distinct source-hint directories, bounding path components for Windows, and escaping type identifiers throughout generated declarations and serialized type references.

The generator now reports source-located diagnostics before building an unsupported model: CN0035 for generic network declarations or generic containing scopes, CN0036 for nested network classes, CN0037 for file-local network classes, CN0038 for inaccessible serialized types, and CN0039 for parameter types that cannot appear in the generated public message receive API. These emission diagnostics belong to the generator, so installing the analyzer alongside it reports each error once. Invalid declarations do not suppress unrelated valid output.

Validation: all 28 new combined analyzer/generator cases pass, and the full Release solution passes 256 tests with .NET SDK 10.0.400 / net8.0. Coverage includes namespace/output-role/case collisions, long hints, unsupported scopes, property/collection/message accessibility, successful nested-struct serialization and RPC dispatch, and private inherited member controls. An actual EmitCompilerGeneratedFiles build with long type names succeeds; a normal build with both components emits each new diagnostic once.

Compatibility: generated source hint paths change, while existing runtime type IDs, message IDs, serializer names, and wire encodings retain their previous algorithms. Generic, nested, and file-local network classes remain unsupported and now fail explicitly. Accessible nested data structs, closed generic data structs, internal network classes, and private inherited members with accessible types remain supported. Rejected partial declarations can also produce the compiler's normal missing-implementation errors; no invalid implementation is emitted for them.

Integration: retain R20's member identifiers and local-name allocation alongside these escaped type names. When combining the independent R22 and R24 fixes, keep their declaration and inherited-name guards and preserve the null-model check after the model factory.

When integrating R26 (#31), apply its recursion bounds and cancellation checks to the new NetworkTypeValidation.FindInaccessibleType traversal of type arguments and public struct fields too. This earlier accessibility check runs before model validation and must not bypass the recursion protection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant