Skip to content

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

Merged
CaffeinatedCoder merged 1 commit into
mainfrom
chore/317-noinlining-default-iformattable
Oct 19, 2026
Merged

CaffeinatedCoder merged 1 commit into
mainfrom
chore/317-noinlining-default-iformattable

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #317

Problem

Port of #315 to main, where it landed on release/10.x as PR #316 (3ed738e).
The 11 line keeps the Native AOT trap (dotnet/runtime#136073) out of a compiled consumer by giving each value
set family its own IFormattable.ToString (#291). A family added without that override compiles, passes every
test on the SDK CI runs, and traps (exit 133) only in a net11.0 Native AOT publish.
IValueSetFactory<,> cannot be implemented outside this repository (FromTrusted is internal abstract), so
this guards future families here and is no consumer-facing gap.

Change

[MethodImpl(MethodImplOptions.NoInlining)] on the default IFormattable.ToString of
IValueSetFactory<TSet, T>, hez2010's workaround on dotnet/runtime#136073, and a conventions test asserting the
flag by reflection. A cherry-pick (-x) of 6317bc3; the only difference is the comment above the attribute,
which names #291 instead of the shipped 10.1.0. No public surface and no answer changes, so no changelog line.

Tests

The AOT measurement was taken on release/10.x with SDK 11.0.100-rc.2.26504.105 (see #315 and #316): the
10.0.0 state of the sets exits 133 without the attribute and runs to the end with it. On this branch, with the
same SDK: the conventions project passes (404, net11.0), and TheDefaultToString_OfTheSetFactoryInterface_IsNotInlined
fails with only the attribute stripped and passes with it.

🤖 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]>
(cherry picked from commit 6317bc3)
@CaffeinatedCoder CaffeinatedCoder added this to the 11.0.0 milestone Oct 19, 2026
@CaffeinatedCoder CaffeinatedCoder added chore Build, CI, packaging, refactoring with no behaviour change area/value-sets Value set families and wrapper arities area/aot Native AOT and trimming package/core Affects CodoMetis.ValueRanges labels Oct 19, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit 5f08625 into main Oct 19, 2026
@CaffeinatedCoder
CaffeinatedCoder deleted the chore/317-noinlining-default-iformattable branch October 19, 2026 14:04
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.

main: keep the default IFormattable.ToString of IValueSetFactory out of ILCompiler's inlining (port of #315, dotnet/runtime#136073)

1 participant