Repository navigation
chore: keep the default IFormattable.ToString of IValueSetFactory out of ILCompiler's inlining - #318
Merged
Conversation
… 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
deleted the
chore/317-noinlining-default-iformattable
branch
October 19, 2026 14:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #317
Problem
Port of #315 to
main, where it landed onrelease/10.xas 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 everytest on the SDK CI runs, and traps (exit 133) only in a
net11.0Native AOT publish.IValueSetFactory<,>cannot be implemented outside this repository (FromTrustedisinternal abstract), sothis guards future families here and is no consumer-facing gap.
Change
[MethodImpl(MethodImplOptions.NoInlining)]on the defaultIFormattable.ToStringofIValueSetFactory<TSet, T>, hez2010's workaround on dotnet/runtime#136073, and a conventions test asserting theflag 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.xwith SDK 11.0.100-rc.2.26504.105 (see #315 and #316): the10.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_IsNotInlinedfails with only the attribute stripped and passes with it.
🤖 Generated with Claude Code