Skip to content

NativeAOT compatibility #9

Description

@pableess

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions