Skip to content

Conversation

askpt
Copy link
Member

@askpt askpt commented Aug 15, 2025

This PR

This pull request introduces comprehensive support for .NET NativeAOT compilation in the OpenFeature .NET SDK. It adds an AOT compatibility test project, updates documentation, and refactors code to remove reflection usage and ensure all components work seamlessly with AOT and trimming. The changes also include updates to the build configuration and dependency management to guarantee full compatibility across all major platforms and architectures.

AOT/NativeAOT Compatibility and Testing

  • Added a new GitHub Actions workflow (.github/workflows/aot-compatibility.yml) to automatically test AOT compatibility across Linux, Windows, and macOS (both x64 and ARM64) for every push and pull request.
  • Introduced the test/OpenFeature.AotCompatibility/OpenFeature.AotCompatibility.csproj project, which is configured and implemented to verify AOT compatibility and demonstrate usage patterns.
  • Updated build properties in build/Common.prod.props to set IsAotCompatible for net8.0 and net9.0 targets, ensuring all relevant builds are flagged for AOT support.

Documentation and Guidance

  • Added docs/AOT_COMPATIBILITY.md with detailed instructions, migration guide, and examples for using OpenFeature with NativeAOT. The main README.md now highlights full NativeAOT compatibility and links to this guide. [1] [2]

Codebase Refactoring for AOT

  • Removed DescriptionAttribute usage from ErrorType enum and replaced reflection-based enum description logic with a manual, switch-based implementation in EnumExtensions, making it AOT-compatible. [1] [2] [3]
  • Updated ValueJsonConverter documentation and implementation to clarify and ensure AOT compatibility by using manual JSON reading/writing.
  • Added OpenFeatureJsonSerializerContext to pre-generate JSON serialization code for all relevant types, enabling trimming and NativeAOT scenarios.

Dependency and Solution Updates

  • Added necessary package references (Microsoft.Extensions.Logging.Console, Microsoft.Extensions.Hosting) for AOT scenarios and updated Directory.Packages.props accordingly.
  • Updated solution and project files to include the new AOT compatibility test project and ensure proper internal visibility for testing. [1] [2] [3] [4]

Related Issues

Fixes #440

Notes

  • For the following features, we need to make sure to always use compatible AOT code (not use reflection, etc.)
  • If a new distinct feature is added, we should add that to the NativeAOT test project (this is due to how the trimming works during the publishing)

@askpt askpt linked an issue Aug 15, 2025 that may be closed by this pull request
3 tasks
Copy link

codecov bot commented Aug 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.73%. Comparing base (ee1deb3) to head (2cadd2a).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #554      +/-   ##
==========================================
+ Coverage   89.67%   89.73%   +0.05%     
==========================================
  Files          64       64              
  Lines        2509     2522      +13     
  Branches      296      295       -1     
==========================================
+ Hits         2250     2263      +13     
  Misses        199      199              
  Partials       60       60              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@askpt askpt changed the title Add NativeAOT Support feat: Add NativeAOT Support Aug 15, 2025
askpt added 6 commits August 15, 2025 15:30
…erties and AspNetCore sample tests

Signed-off-by: André Silva <[email protected]>
…step and standardize comment formatting

Signed-off-by: André Silva <[email protected]>
…nd switch to PowerShell for script execution

Signed-off-by: André Silva <[email protected]>
…lumn and enhance binary size logging

Signed-off-by: André Silva <[email protected]>
@open-feature open-feature deleted a comment from github-actions bot Aug 18, 2025
askpt added 2 commits August 18, 2025 17:02
…ntation for NativeAOT support

Signed-off-by: André Silva <[email protected]>
… sections and enhancing clarity

Signed-off-by: André Silva <[email protected]>
@askpt askpt marked this pull request as ready for review August 18, 2025 16:09
@askpt askpt requested a review from a team as a code owner August 18, 2025 16:09
askpt and others added 2 commits August 19, 2025 16:21
Co-authored-by: Weihan Li <[email protected]>
Signed-off-by: André Silva <[email protected]>
Co-authored-by: Weihan Li <[email protected]>
Signed-off-by: André Silva <[email protected]>
@askpt askpt requested a review from WeihanLi August 19, 2025 15:27
Co-authored-by: Weihan Li <[email protected]>
Signed-off-by: André Silva <[email protected]>
@askpt askpt changed the title feat: Add NativeAOT Support perf: Add NativeAOT Support Aug 20, 2025
@askpt askpt added this pull request to the merge queue Aug 25, 2025
Merged via the queue into main with commit acd0486 Aug 25, 2025
24 of 25 checks passed
@askpt askpt deleted the askpt/440-feature-investigate-nativeaot branch August 25, 2025 19:35
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.

[FEATURE] Investigate NativeAOT
4 participants