-
Notifications
You must be signed in to change notification settings - Fork 664
Add YamlDotNet AOT compatibility infrastructure #4686
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
Conversation
Co-authored-by: arturcic <[email protected]>
Co-authored-by: arturcic <[email protected]>
|
Please retry analysis of this Pull-Request directly on SonarQube Cloud |
|
| @@ -0,0 +1,163 @@ | |||
| # YamlDotNet AOT Compatibility Status | |||
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.
Unexpected missing fenced code language flag in info string, expected keyword fenced-code-flag remark-lint
|
@copilot fix Code Format |
| [YamlSerializable(typeof(Dictionary<string, string>))] | ||
| [YamlSerializable(typeof(Dictionary<string, BranchConfiguration>))] | ||
| [YamlSerializable(typeof(HashSet<string>))] | ||
| public partial class YamlConfigurationContext : StaticContext |
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.
where is this one used?
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.
Currently, YamlConfigurationContext is used in YamlAotCompatibilityTests to verify the infrastructure is in place. It's infrastructure for future use - once YamlDotNet's source generator issues are resolved, it will be used in ConfigurationSerializer to enable AOT-compatible serialization (see the "Future Migration Path" section in the aot-compatibility.md documentation for the planned usage with StaticSerializerBuilder and StaticDeserializerBuilder).
|
@copilot please review the comments |
The code is already properly formatted according to the project's .editorconfig and passes |



Overview
This PR implements the necessary infrastructure to enable Native AOT (Ahead-of-Time) compilation support for GitVersion using YamlDotNet's source generator, addressing issue #[issue_number].
Background
Native AOT compilation provides significant benefits including faster startup time, reduced memory footprint, and smaller deployment sizes. However, it requires eliminating runtime reflection, which YamlDotNet traditionally relies on for YAML serialization/deserialization.
YamlDotNet 16.3+ includes source generator support designed to enable AOT compatibility by generating serialization code at compile time. This PR adds the required infrastructure to take advantage of this capability.
Changes
1. Source Generator Package
Added
Vecc.YamlDotNet.Analyzers.StaticGenerator(v16.3.0) as an analyzer-only package reference:2. Static Context Class
Created
YamlConfigurationContextclass that declares all configuration types for source generation:The source generator is designed to implement this partial class at compile time, providing AOT-compatible type information.
3. Comprehensive Documentation
Added detailed documentation at
docs/input/docs/reference/aot-compatibility.mdcovering:4. Test Coverage
Added
YamlAotCompatibilityTeststo verify the infrastructure:Known Limitations
The
Vecc.YamlDotNet.Analyzers.StaticGeneratorpackage currently has known issues where theTypeFactoryGeneratorfails withIndexOutOfRangeExceptionwhen processing certain type patterns (particularly records and complex nested types). This is tracked in YamlDotNet issue #740.These warnings during build can be safely ignored:
Impact
No Breaking Changes: The existing
ConfigurationSerializercontinues to use reflection-based builders. All current functionality remains unchanged.Future Ready: Once the YamlDotNet source generator issues are resolved, migrating to AOT-compatible serialization will require only minimal changes:
ConfigurationSerializerto useStaticSerializerBuilderandStaticDeserializerBuilder<PublishAot>true</PublishAot>in the CLI projectTest Results
References
This PR positions GitVersion to take advantage of Native AOT compilation benefits as soon as the YamlDotNet ecosystem matures, with minimal additional work required.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.