Repository navigation
[tests] Fix IsLinkAll trimmer dataflow heuristic workaround - #26295
Conversation
The IsLinkAll property resolved the "+LinkerSentinel" type via a compile-time-constant string. The trimmer's dataflow analysis (dotnet/runtime#127319) can constant-fold that string and preserve the LinkerSentinel type, making IsLinkAll incorrectly report false in link-all builds. Add a WorkAroundLinkerHeuristics property (returns "" at runtime, but the trimmer can't constant-fold it) and append it to the type-name string so the trimmer can no longer statically resolve the type name. This matches the pattern already used in tests/linker/*. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a19734eb-f3bc-498a-9907-f91eaec2f364
IsLinkAny passes compile-time-constant type-name strings (from an array) to Assembly.GetType. The array/loop indirection happens to defeat the trimmer's dataflow folding today, but as the analysis gets smarter (dotnet/runtime#127319) it could resolve those constants, preserve the probed corlib types, and make IsLinkAny incorrectly report false. Append WorkAroundLinkerHeuristics (a no-op "" at runtime the trimmer can't constant-fold) for the same robustness as IsLinkAll. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a19734eb-f3bc-498a-9907-f91eaec2f364
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
Updates the test runtime’s linker-detection heuristics to avoid the trimmer’s dataflow analysis treating Assembly.GetType(...) string arguments as compile-time constants and inadvertently preserving sentinel types.
Changes:
- Appends a non-constant-foldable
WorkAroundLinkerHeuristicsstring to the+LinkerSentinellookup used byTestRuntime.IsLinkAll. - Applies the same workaround to
TestRuntime.IsLinkAny’sGetTypechecks. - Adds an explanatory comment documenting why the workaround is needed (matching the established pattern in
tests/linker/*).
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
🚀 [CI Build #84a88c0] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 203 tests passed 🎉 Tests counts✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
Addresses a review comment from #26292.
Problem
In
tests/common/TestRuntime.LinkAll.cs, theIsLinkAllproperty resolved the+LinkerSentineltype using a compile-time-constant type name:The trimmer's dataflow analysis (dotnet/runtime#127319) can resolve that constant string and preserve the
LinkerSentineltype, which would makeIsLinkAllincorrectly reportfalseeven in link-all builds.Fix
Introduce a
WorkAroundLinkerHeuristicsproperty that returns""at runtime (but the trimmer can't constant-fold) and append it to the type-name string, so the trimmer can no longer statically resolve+LinkerSentinel. This matches the pattern already used intests/linker/*(e.g.CommonLinkAllTest.cs,PreserveTest.cs).🤖 Pull request created by Copilot