Skip to content

[R24] Reject inherited property and collection name collisions - #26

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

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

Conversation

@JetF0x

@JetF0x JetF0x commented Sep 12, 2026

Copy link
Copy Markdown

Addresses review finding R24.

A replicated collection hiding an inherited collection or property, or a replicated property hiding a collection, previously passed Cat.Network analysis and produced duplicate serializer helpers and name-mode switch labels. Property/property hiding was already rejected by CN0007; this change extends that existing rule rather than introducing a new diagnostic.

Move CN0007 into one member-name analyzer and share its inherited-name lookup with the generator. All replicated properties and collections occupy the same inheritance-wide name namespace, including private ancestor members and ancestors beyond an intermediate class. Report the error on the conflicting declaration and identify the original declaring type. Skip emission for conflicting types and their descendants while continuing to generate valid bases and unrelated types.

Validation with .NET SDK 10.0.400 and Release/net8.0:

  • Before the production change, the new combined analyzer/generator suite had 37 failures and 22 passing controls. Collection collisions lacked CN0007, while the property/property controls confirmed that CN0007 already existed.
  • All 61 focused cases now pass: 36 property/list/dictionary collision combinations across direct/multilevel inheritance and public/private bases, an intermediate ordinary-property case, 22 accepted-schema compilation controls, and two private inherited-member runtime round trips.
  • dotnet test Cat.Network.sln -c Release --no-restore passes all 289 tests: 157 runtime, 79 generator, and 53 analyzer tests. Invalid collision cases produce CN0007 without AD0001, CS8785, or errors in generated sources. The existing CS8600 warning at MemoryRelayTransport.cs:21 remains.

Compatibility: valid schema order, field indices, wire names, and emitted code remain unchanged. Distinct names, supported ordinary unannotated hiding, and private inherited scalar/list/dictionary members continue to work, including name-mode serialization. Ambiguous schemas remain unsupported and now receive a direct source diagnostic; because generation is skipped, the compiler can also report a missing implementation for the invalid partial declaration. Suppressing CN0007 does not make the ambiguous schema supported. No runtime API or new diagnostic ID is introduced.

Integration with the independent R22/R23 fixes: keep their declaration/type guards and this inherited-name guard conjunctive. R24 adds Shared/NetworkMemberNames.cs, an independent analyzer registration, and a check before NetworkObjectTypeModel.Create; it does not modify that model factory. Preserve R22's nullable factory result and retain a single null-filter/select stage after all guards. Retain each issue's distinct shared source-file link. This PR is independently based on rewrite, without either neighboring fix.

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