-
Notifications
You must be signed in to change notification settings - Fork 659
Add YamlDotNet source generator infrastructure for Native AOT support #4688
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
base: main
Are you sure you want to change the base?
Conversation
- Added Vecc.YamlDotNet.Analyzers.StaticGenerator package - Changed init properties to set properties to support source generator - Created GitVersionConfigurationStaticContext for AOT compatibility - Updated ConfigurationSerializer to use static serializer/deserializer - Updated PublicAPI.Unshipped.txt with generated API surface Co-authored-by: arturcic <[email protected]>
The YamlDotNet source generator has limitations: - Doesn't honor custom type inspectors for property naming - Limited support for dynamic types - The static context is kept for future use when generator improves All tests now pass with the regular serializers. Co-authored-by: arturcic <[email protected]>
Co-authored-by: arturcic <[email protected]>
|
{ | ||
// Static context is defined for future AOT support but not currently used | ||
// due to limitations with custom type inspectors and init properties | ||
private static readonly GitVersionConfigurationStaticContext staticContext = new(); |
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.
@copilot I actually need to use the source generator version, and I will later check the AOT
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.
Pull Request Overview
This PR adds YamlDotNet source generator infrastructure to prepare GitVersion for Native AOT (Ahead-of-Time) compilation support. The infrastructure is implemented but not actively used due to current limitations in YamlDotNet's source generator capabilities.
- Added
Vecc.YamlDotNet.Analyzers.StaticGenerator
v16.3.0 package reference and createdGitVersionConfigurationStaticContext
class - Changed property accessors from
internal init
tointernal set
across all configuration classes to support source generator requirements - Added documentation explaining current limitations and future migration path
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
YAMLDOTNET_SOURCE_GENERATOR.md | Documents implementation status, limitations, and future migration path |
PublicAPI.Unshipped.txt | Adds generated types to public API surface |
PreventIncrementConfiguration.cs | Changes 3 properties from init to set for generator compatibility |
IgnoreConfiguration.cs | Changes 4 properties from init to set for generator compatibility |
GitVersionConfigurationStaticContext.cs | New static context class with YamlDotNet source generator attributes |
GitVersionConfiguration.cs | Changes 21 properties from init to set for generator compatibility |
GitVersion.Configuration.csproj | Adds source generator package reference |
ConfigurationSerializer.cs | Adds static context instance for future use |
BranchConfiguration.cs | Changes 14 properties from init to set for generator compatibility |
Directory.Packages.props | Adds version definition for source generator package |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Overview
This PR adds the YamlDotNet source generator infrastructure to prepare GitVersion for Native AOT (Ahead-of-Time) compilation support, as outlined in Using the YamlDotNet Source Generator for Native AOT.
Changes
1. Source Generator Package
Vecc.YamlDotNet.Analyzers.StaticGenerator
v16.3.0 package referenceGitVersionConfigurationStaticContext
class with[YamlStaticContext]
and[YamlSerializable]
attributes for main configuration types2. Property Accessor Updates
Changed
internal init
tointernal set
for all configuration properties to support source generator requirements:BranchConfiguration
(14 properties)GitVersionConfiguration
(21 properties)IgnoreConfiguration
(4 properties)PreventIncrementConfiguration
(3 properties)This change maintains encapsulation (internal setters) while providing flexibility for serialization and future source generator use.
3. Updated Public API Surface
Added generated types to
PublicAPI.Unshipped.txt
:GitVersionConfigurationStaticContext
StaticTypeInspector
and related methodsCurrent Status
While the infrastructure is in place, the static serializer/deserializer is not actively used due to current limitations in YamlDotNet's source generator (v16.3.0):
StaticTypeInspector
doesn't honor custom type inspectors, which GitVersion requires forJsonPropertyName
attribute mappingDictionary<object, object?>
used in override configurationsThe
ConfigurationSerializer
currently uses regularDeserializerBuilder
/SerializerBuilder
with a comment explaining the situation. The static context is instantiated but kept ready for future use.Testing
✅ All 82 configuration tests pass (net8.0 and net9.0)
✅ Full backward compatibility maintained
✅ No breaking changes to existing functionality
Documentation
Added
YAMLDOTNET_SOURCE_GENERATOR.md
documenting:Future Work
When YamlDotNet's source generator improves support for custom type inspectors and complex types, we can enable it in
ConfigurationSerializer.cs
by switching toStaticDeserializerBuilder
/StaticSerializerBuilder
.Related
Fixes #[issue_number]
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.