Repository navigation
fix: Private nested types in NetworkVariables in CoreCLR - #4239
Conversation
|
|
||
| for (var definition = type.Resolve(); definition != null && definition.IsNested; definition = definition.DeclaringType) | ||
| { | ||
| if ((definition.IsNestedPrivate || definition.IsNestedFamily || definition.IsNestedFamilyAndAssembly) && !hidden.Contains(definition)) |
There was a problem hiding this comment.
InitializeSerialization still fails on CoreCLR when NetworkVariable<Payload> uses a referenced base's protected internal nested enum without friend access. A derived NetworkBehaviour can legally declare that field using protected access. GetAllFieldsAndResolveGenerics collects Payload, but this predicate does not check IsNestedFamilyOrAssembly. The generated NetworkVariableSerializationHelper cannot access Payload because the helper is outside the base's assembly and inheritance hierarchy. Pass the consuming assembly into CollectTypesHiddenFromAssembly. Reject IsNestedFamilyOrAssembly types when that assembly lacks internal or friend access.
🤖 Helpful? 👍/👎
Codecov ReportAll modified and coverable lines are covered by tests ✅ @@ Coverage Diff @@
## develop-3.x.x #4239 +/- ##
=================================================
- Coverage 76.75% 76.74% -0.01%
=================================================
Files 159 159
Lines 28078 28078
=================================================
- Hits 21550 21549 -1
- Misses 6528 6529 +1
Flags with carried forward coverage won't be shown. Click here to find out more. see 1 file with indirect coverage changes
|
Purpose of this PR
When we generate the serialization code for NetworkVariables, we add code at the assembly level. Mono, for whatever reason, didn't complain if there were private or protected types in the serialization generation code. CoreCLR throws an error if we try to generate serialization for private types.
This PR detects this case and logs a warning in Mono, and an error in CoreCLR. This gives users a human-readable error message with information on how to fix the issue, and lets the code generation safely continue.
Jira ticket
UUM-156224
Changelog
Documentation
Testing & QA (How your changes can be verified during release Playtest)
Functional Testing
Manual testing :
Manual testing doneAutomated tests:
Covered by existing automated testsCovered by new automated testsDoes the change require QA team to:
Review automated tests?Execute manual tests?Provide feedback about the PR?If any boxes above are checked the QA team will be automatically added as a PR reviewer.
Up-port
n/a
Backports
2.x doesn't need to support CoreCLR