Summary
Track making Tomlyn.Extensions.Configuration NativeAOT/trim compatible.
Current state
The library currently calls the reflection-based TomlSerializer.Deserialize<TomlTable>(string) overload. That overload is annotated [RequiresUnreferencedCode]/[RequiresDynamicCode], and Tomlyn disables reflection-based serialization by default when PublishAot=true. As a result the library emits IL2026/IL3050 warnings when marked AOT-compatible and would fail at runtime under NativeAOT.
Fix
Submitted in #8:
- Add an internal source-generated
TomlSerializerContext with [TomlSerializable(typeof(TomlTable))].
- Parse via
TomlSerializer.Deserialize<TomlTable>(text, TomlModelSerializerContext.Default).
- Mark the library
<IsAotCompatible>true</IsAotCompatible> and bump Tomlyn to 2.10.1.
- Add a NativeAOT smoke-test project and CI workflow (tests +
dotnet publish -r linux-x64 + run).
Verification
- Release build of all TFMs: no IL2026/IL3050.
dotnet test (net10.0): passing.
- Trimmed publish + run: passing; CI performs the full NativeAOT publish/run.
Pull request: #8
Summary
Track making
Tomlyn.Extensions.ConfigurationNativeAOT/trim compatible.Current state
The library currently calls the reflection-based
TomlSerializer.Deserialize<TomlTable>(string)overload. That overload is annotated[RequiresUnreferencedCode]/[RequiresDynamicCode], and Tomlyn disables reflection-based serialization by default whenPublishAot=true. As a result the library emits IL2026/IL3050 warnings when marked AOT-compatible and would fail at runtime under NativeAOT.Fix
Submitted in #8:
TomlSerializerContextwith[TomlSerializable(typeof(TomlTable))].TomlSerializer.Deserialize<TomlTable>(text, TomlModelSerializerContext.Default).<IsAotCompatible>true</IsAotCompatible>and bump Tomlyn to 2.10.1.dotnet publish -r linux-x64+ run).Verification
dotnet test(net10.0): passing.Pull request: #8