-
-
Notifications
You must be signed in to change notification settings - Fork 964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Cecil serialization inheritance cutoff with complex base types #2457
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice solution. Just a question - the check on generic type inside the for loop where we continue - what scenario is that skipping?
Would be nice to add a few comments on those lines that explain what the algorithm is doing. |
Added a couple of comments to clarify. class A<T>{}
class B<T> : A<T>{} Not 100% sure as I haven't tested it, here's the source for that method: stride/sources/core/Stride.Core.AssemblyProcessor/ResolveGenericsVisitor.cs Lines 27 to 44 in beb2972
|
Would it be easy to add a test (in https://github.com/stride3d/stride/blob/master/sources/core/Stride.Core.Tests/TestSerialization.cs) so that we make sure to not break it in the future? (i.e. if we switch to Roslyn) |
Looked into it - in that particular test context, cecil fails to generate a serializer for the class even with the exact same type definitions I used at edit and runtime to validate the changes in this PR. I don't have a lot of time to dig too deep into why the test fails while the real one passes, so I'll have to leave it as is for now |
Thanks for giving it a try, all good then! |
PR Details
The binary serializer can lose serialized data when round-tripped with a specific inheritance setup;
The following logic fails to capture
B<T>
stride/sources/core/Stride.Core.AssemblyProcessor/Serializers/CecilSerializerContext.cs
Lines 198 to 204 in 37bbf0c
Which in turn means that all serialized data contained in its base types would be discarded, most obvious with the component Id inherited from
EntityComponent
, which right now shows up as a new Id on every save caused by the asset collision Id de-duplication using binary serialization through theClone
function:stride/sources/assets/Stride.Core.Assets/Analysis/AssetCollision.cs
Lines 33 to 48 in 37bbf0c
Related Issue
Kind of hard to tell
Types of changes
Checklist