Skip to content

[tests] Fix IsLinkAll trimmer dataflow heuristic workaround - #26295

Merged
rolfbjarne merged 2 commits into
mainfrom
dev/rolf/glowing-robot
Jul 28, 2026
Merged

rolfbjarne merged 2 commits into
mainfrom
dev/rolf/glowing-robot

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

Addresses a review comment from #26292.

Problem

In tests/common/TestRuntime.LinkAll.cs, the IsLinkAll property resolved the +LinkerSentinel type using a compile-time-constant type name:

link_all = typeof (TestRuntime).Assembly.GetType (typeof (TestRuntime).FullName + "+LinkerSentinel") is null;

The trimmer's dataflow analysis (dotnet/runtime#127319) can resolve that constant string and preserve the LinkerSentinel type, which would make IsLinkAll incorrectly report false even in link-all builds.

Fix

Introduce a WorkAroundLinkerHeuristics property 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 in tests/linker/* (e.g. CommonLinkAllTest.cs, PreserveTest.cs).

🤖 Pull request created by Copilot

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
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 WorkAroundLinkerHeuristics string to the +LinkerSentinel lookup used by TestRuntime.IsLinkAll.
  • Applies the same workaround to TestRuntime.IsLinkAny’s GetType checks.
  • Adds an explanatory comment documenting why the workaround is needed (matching the established pattern in tests/linker/*).

@rolfbjarne
rolfbjarne marked this pull request as ready for review July 27, 2026 18:10
@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 84a88c0913229fc73602d3140551d43dae4b164b [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🚀 [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
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker (iOS): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 15 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 19 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 19 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 19 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

macOS tests

✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Ventura (13): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

✅ Linux build succeeded

Pipeline on Agent
Hash: 84a88c0913229fc73602d3140551d43dae4b164b [PR build]

@rolfbjarne rolfbjarne added the ready-to-review This PR is ready to review/merge. label Jul 28, 2026
@rolfbjarne
rolfbjarne enabled auto-merge (squash) July 28, 2026 11:51
@rolfbjarne
rolfbjarne merged commit d2e5b26 into main Jul 28, 2026
57 checks passed
@rolfbjarne
rolfbjarne deleted the dev/rolf/glowing-robot branch July 28, 2026 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copilot ready-to-review This PR is ready to review/merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants