Skip to content
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

Added static builders and abstracted reflection components #761

Merged
merged 11 commits into from Feb 7, 2023

Conversation

EdwardCooke
Copy link
Collaborator

When doing an AoT/trimmed library, nstead of using SerializerBuilder and DeserializeBuilder use the StaticSerializerBuilder and StaticDeserializerBuilder. There should be a couple of warnings that will show up when using the current SerializerBuilder and DeserializerBuilder and AoT/trimming. The static ones don't use reflection anywhere, thus, no warnings. There was a bunch of areas in YamlDotNet that was generating generic classes when a custom dictionary object didn't implement IDictionary or a custom list didn't implement IList. That's probably the biggest limitation in the static version, and I couldn't find a way around it.

My testing showed that the static builders worked for the simple serialization without showing any warnings. I'll be working on setting up unit tests for the static implementation over the next bit. If you don't find any issues, I'll bring those changes in to the master branch when the unit tests are complete and push a new version.

There are some minor breaking changes in some of the underlying interfaces/classes, namely the IObjectFactory, there is a new class, ObjectFactoryBase that can be inherited from, which will cover the current implementation without needing to write any additional code or other changes. If you manually instantiated some of the node deserializers, there will need to be code changes, they now take in a ITypeFactory and/or IObjectFactory object.

Those changes were necessary to break out the rest of the reflection implementation so it could be replaced with the static implementation.

Resolves warnings in #740 and #753

@EdwardCooke
Copy link
Collaborator Author

@aaubry this PR will be pushing up a second NuGet package for the static code generator/analyzer. Do you have any issues with this? The NuGet package name is YamlDotNet.Analyzers.StaticGenerator.

@EdwardCooke EdwardCooke merged commit cf7b93c into aaubry:master Feb 7, 2023
@EdwardCooke EdwardCooke deleted the ec-aotwarnings branch August 14, 2023 05:49
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.

None yet

1 participant