Skip to content

chore: keep the default IFormattable.ToString of IValueSetFactory out of ILCompiler's inlining - #316

Merged
CaffeinatedCoder merged 1 commit into
release/10.xfrom
fix/315-noinlining-default-iformattable
Oct 19, 2026
Merged

CaffeinatedCoder merged 1 commit into
release/10.xfrom
fix/315-noinlining-default-iformattable

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #315

Problem

#299 keeps the Native AOT trap under the .NET 11 SDK out of 10.1.0 by giving each of the 17 value set
families its own IFormattable.ToString, so the default in IValueSetFactory<TSet, T> is never the code a
consumer runs. A family added without that override compiles, passes every test on the .NET 10 SDK that CI
runs, and ends a net11.0 Native AOT publish with SIGTRAP (exit 133, no output) on its first ToString;
only the manual SMOKE_AOT_SDK run shows it.

There is no consumer-facing gap: IValueSetFactory<,> declares internal abstract static FromTrusted, so
nothing outside this repository can implement it (CS0535 from a scratch project). #315's first version said
otherwise; it was corrected.

Change

[MethodImpl(MethodImplOptions.NoInlining)] on the default IFormattable.ToString of
IValueSetFactory<TSet, T>, which is the workaround hez2010 gave on dotnet/runtime#136073 (ILCompiler inlines
the default into the instantiating thunk of the shared-generic interface, where the cast of this fails). The
per-family overrides stay. IRangeFactory's default is untouched: it printed every range in the same publishes.
No public surface and no answer changes, so there is no changelog line.

Tests

Measured with SDK 11.0.100-rc.2.26504.105 on osx-arm64, SMOKE_AOT_SDK=… test/consumer-smoke-test.sh:

Sets Default Native binary
10.0.0 state (the overrides of e54ed35 reverted) no attribute exit 133 after aot-float64set
10.0.0 state NoInlining ran to the end, "ToString on every value set family" passes
overrides in place, GuidSet alone reverted no attribute ran to the end

The smoke leg cannot be in this repository's CI (#297 gives 10.x no .NET 11 SDK leg), so
ValueSetContractTests.TheDefaultToString_OfTheSetFactoryInterface_IsNotInlined asserts the flag by
reflection: it fails with only the attribute stripped (message names #299/#315 and the upstream issue) and
passes with it. The conventions project passes (404).

The same change goes to main in a separate PR after this one merges.

🤖 Generated with Claude Code

… of ILCompiler's inlining

#299 stopped the Native AOT trap under the .NET 11 SDK by giving each value set
family its own IFormattable.ToString, so the interface's default is never the
code a consumer runs. That holds only while every family, present and future,
carries the override: a family without one compiles, passes every test on the
.NET 10 SDK that CI runs, and traps (exit 133, no output) only in a net11.0
Native AOT publish, which only the manual SMOKE_AOT_SDK run exercises.

Root cause, from hez2010 on dotnet/runtime#136073: ILCompiler inlines the small
default into the instantiating thunk of the shared-generic interface, where the
receiver is typed as the thunk's module type, so the cast of `this` fails. This
puts their workaround, [MethodImpl(NoInlining)], on the default and keeps the
overrides. It changes no public surface and no answer, so there is no changelog
entry.

Measured with SDK 11.0.100-rc.2.26504.105 on osx-arm64, test/consumer-smoke-test.sh
with SMOKE_AOT_SDK, on the 10.0.0 state of the sets (the overrides of e54ed35
reverted): without the attribute the native binary exits with 133 right after
aot-float64set, as #291 saw; with only the attribute added it runs to the end and
"ToString on every value set family" passes. Removing the overrides of one family
alone (GuidSet) does not trap, so the proof needs the whole 10.0.0 state.

The smoke run cannot be in CI (#297 gives the 10.x CI no .NET 11 SDK leg), so a
conventions test asserts the flag on the default by reflection; it fails with the
attribute stripped and passes with it.

IValueSetFactory cannot be implemented outside this repository (FromTrusted is
internal abstract), so there is no consumer-facing gap; #315 says so. The range
default (IRangeFactory) printed every range in the same publish and is left alone.

Refs #315, dotnet/runtime#136073

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/aot Native AOT and trimming area/value-sets Value set families and wrapper arities chore Build, CI, packaging, refactoring with no behaviour change package/core Affects CodoMetis.ValueRanges

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant