Skip to content

Hold the two AOT claims (A02, A03) with a reflection-disabled test project #107

Open

Description

@CaffeinatedCoder

dotnet run tools/oracles.cs status lists two unheld claims, both from docs/serialization.md#native-aot:

  • A02 — under Native AOT, JsonSerializer.Serialize(value) with default options throws InvalidOperationException for a range, a variant, a RangeSet and a value set, typed or through object.
  • A03 — a RangeSet<TRange, T> or wrapper set the program never constructs still deserializes through its attribute converter; if trimming removed the registration, the lookup throws NotSupportedException naming the type.

Today only test/consumer-smoke-test.sh observes them (aot-default-options, aot-rangeset-read, aot-noda-rangeset-read, aot-wrapper-read), and heldBy can only name a test class (OracleCatalogueTests), so the catalogue can't point at the script.

What can hold them short of a Native AOT publish

Most of A02 and A03 is about System.Text.Json with reflection turned off, not about AOT compilation itself. PublishAot flips the feature switch System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault to false; that switch can be set in an ordinary JIT process. Measured on main (7f4dc47) in a console app with <JsonSerializerIsReflectionEnabledByDefault>false</JsonSerializerIsReflectionEnabledByDefault>:

IsReflectionEnabledByDefault = False
range: InvalidOperationException          variant: InvalidOperationException
rangeset: InvalidOperationException       stringset: InvalidOperationException
object-range: InvalidOperationException   object-set: InvalidOperationException
rangeset-read: {[1,5],[7,10]}             (RangeSet<Int64Range, long>, never constructed, via a JsonSerializerContext)
wrapper-read: {1,2}                       (Int32Set<Code>, never constructed)
stringset-wrapper-read: {a,b}             (StringSet<Key>, never constructed)

That is exactly the smoke test's aot-default-options row and the three *-read rows, reproduced without an AOT publish.

The switch is per process, as Npgsql.DisableDateTimeInfinityConversions is, so it needs its own test project — the same shape as test/CodoMetis.ValueRanges.EFCore.PostgreSQL.InfinityDisabled.IntegrationTests: a RuntimeHostConfigurationOption for System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault = false, a TheSwitch_IsInEffect check, and one test class (say ReflectionDisabledJsonTests) that heldBy can name for A02 and A03. No Docker needed.

What stays with the smoke test

  • Whether the registration code was compiled into the binary. Under the JIT every instantiation exists on demand, so "a type the program only deserializes" is not a distinct case there. Only the Native AOT consumer answers that, and GenericConverters says so in its remarks.
  • The trimming half of A03 (NotSupportedException naming the type when the registration is gone). It is reachable in a unit test only through GenericConverters.Get(typeof(X)) for a type that never registers, and that class is internal with InternalsVisibleTo for the NodaTime satellite only. Either widen InternalsVisibleTo to the test project and assert the exception's message names the type, or leave this half to the smoke test and say so in the claim.

Proposal: add the project, point A02 and A03 at it, and extend docs/oracles.md#what-it-does-not-see to say which part of the AOT promise it still can't see. Found in the 10.0.0 bug hunt; tests only, no library change.

Activity

  1. added
    tests
    area/json
    area/aot
    on Oct 17, 2026
  2. added
    package/core
    on Oct 17, 2026
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

    area/aotarea/jsonpackage/coretests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions