Skip to content

Comments

Resolve warnings and fix issues in Native AOT builds#87

Merged
prozolic merged 3 commits intomainfrom
Fix
Jan 10, 2026
Merged

Resolve warnings and fix issues in Native AOT builds#87
prozolic merged 3 commits intomainfrom
Fix

Conversation

@prozolic
Copy link
Owner

This PR resolve warnings and fix issues in Native AOT builds.

  • Add manually UnconditionalSuppressMessageAttribute (suppressing the IL3* and IL2* warnings)
  • Add DynamicallyAccessedMembers to EnumFormatter
  • AddRuntimeFeature.IsDynamicCodeCompiled to some reflections
  • Generates Formatter for the inherited collection interface.

Copilot AI review requested due to automatic review settings January 10, 2026 12:51
Copy link
Contributor

Copilot AI left a 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 resolves warnings and fixes issues for Native AOT compilation by adding proper attributes and runtime checks to support both JIT and AOT scenarios.

Changes:

  • Added UnconditionalSuppressMessage attributes to suppress IL2* and IL3* AOT analysis warnings where reflection is acceptable
  • Added DynamicallyAccessedMembers annotations to types requiring reflection support
  • Added RuntimeFeature.IsDynamicCodeCompiled guards to prevent runtime code generation in AOT scenarios
  • Enhanced the generator to create formatters for inherited collection interfaces (ILookup, IGrouping)
  • Made nullable annotation improvements and refactored collection type metadata organization

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/CsToml.Extensions.Configuration.Tests/TypeDeclarations.cs Made Integers property nullable to match actual usage
src/CsToml/Formatter/TypeFormatter.cs Added IL2057 suppression for Type.GetType reflection usage
src/CsToml/Formatter/Resolver/TomlSerializedObjectFormatterResolver.cs Added IL2090 suppression for ITomlSerializedObjectRegister invocation
src/CsToml/Formatter/Resolver/BuiltinFormatterResolver.cs Added IL3050 suppressions and RuntimeFeature checks to prevent dynamic code generation in AOT
src/CsToml/Formatter/EnumFormatter.cs Added DynamicallyAccessedMembers annotation for enum field reflection
src/CsToml.Generator/TypeMeta.cs Enhanced type discovery to include public generic collection interfaces
src/CsToml.Generator/Generator.cs Added null-forgiving operators after validated non-null checks
src/CsToml.Generator/FormatterTypeMetaData.cs Reorganized collection types, moved FrozenSet to concrete types, added interface collection support
sandbox/ConsoleNativeAOT/Type.cs Added TypeLinqInterface test class for ILookup and IGrouping formatters
sandbox/ConsoleNativeAOT/Program.cs Added test code for TypeLinqInterface serialization
sandbox/ConsoleNativeAOT/ConsoleNativeAOT.csproj Updated to .NET 10.0 and adjusted AOT properties

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@prozolic prozolic merged commit 44dc28f into main Jan 10, 2026
1 check passed
@prozolic prozolic deleted the Fix branch January 10, 2026 13:00
@prozolic prozolic mentioned this pull request Jan 10, 2026
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.

1 participant