Skip to content

[dotnet-linker] Remove DynamicDependency signature workaround. Fixes #26413 - #26560

Merged
rolfbjarne merged 2 commits into
mainfrom
dev/rolf/issue-26413-dotnet-linker-remove-dynamic
Sep 4, 2026
Merged

rolfbjarne merged 2 commits into
mainfrom
dev/rolf/issue-26413-dotnet-linker-remove-dynamic

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

Removes the workaround for dotnet/runtime#131892 (the trimmer crashed with a NullReferenceException, surfaced as error IL1012, when computing the documentation signature of a method whose parameter type is a nested type from another assembly) now that the trimmer bug is fixed and we've moved to an SDK containing the fix.

[DynamicDependency] attributes now use precise method signatures (including the parameter list) again, instead of matching by name and generic arity alone, so fewer overloads are unnecessarily preserved.

Note: DocumentationComments.GetNameSignature and AddPreserveAllMembersDynamicDependencyAttributes are intentionally left untouched, since [Preserve (AllMembers = true)] preserves every overload anyway, so matching by name there is correct and cheaper.

Fixes #26413

🤖 Pull request created by Copilot

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 4, 2026 05:41

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.

🟡 Changes recommended

DocumentationComments.GetSignature(...) is now recomputed multiple times in branching logic and should be cached to avoid unnecessary repeated signature generation.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates the dotnet-linker’s DynamicDependency emission to always use precise documentation signatures (including parameter lists), removing the previous “name-only when unambiguous” workaround that existed to avoid a trimmer crash.

Changes:

  • Removes the GetDynamicDependencySignature workaround and switches back to using DocumentationComments.GetSignature for method signatures in dynamic dependency attributes.
  • Updates assembly-preparer tests to expect parameter-inclusive method signatures again for affected scenarios.
File summaries
File Description
tools/dotnet-linker/AppBundleRewriter.cs Removes the signature workaround and emits full method signatures for [DynamicDependency] attributes.
tests/assembly-preparer/PreserveSmartEnumConversionsTest.cs Updates expected dynamic dependency signature for GetConstant to include the parameter list.
tests/assembly-preparer/PreserveBlockCodeHandlerTests.cs Updates expected dynamic dependency signature for Invoke to include the parameter list.
Review details

Suppressed comments (1)

tools/dotnet-linker/AppBundleRewriter.cs:1713

  • ⚠️ DocumentationComments.GetSignature (forMethod) is computed separately in each branch; compute once and reuse to avoid repeated doc-comment ID generation.
			if (onType == forMethod.DeclaringType) {
				attrib = CreateDynamicDependencyAttribute (DocumentationComments.GetSignature (forMethod));
			} else if (onType.Module == forMethod.DeclaringType.Module) {
				attrib = CreateDynamicDependencyAttribute (DocumentationComments.GetSignature (forMethod), forMethod.DeclaringType);
			} else {
				attrib = CreateDynamicDependencyAttribute (DocumentationComments.GetSignature (forMethod), forMethod.DeclaringType, forMethod.Module.Assembly);
			}
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@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: 14723d7c344012ac0488ccec9ec786c22f487786 [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🚀 [CI Build #14723d7] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 264 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 7 tests passed. Html Report (VSDrops) Download
✅ linker (iOS): All 31 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 31 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 31 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 25 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 25 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 20 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 25 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 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: 14723d7c344012ac0488ccec9ec786c22f487786 [PR build]

@rolfbjarne
rolfbjarne enabled auto-merge (squash) September 4, 2026 09:04
@rolfbjarne rolfbjarne added the ready-to-review This PR is ready to review/merge. label Sep 4, 2026
@rolfbjarne
rolfbjarne merged commit 029a497 into main Sep 4, 2026
54 checks passed
@rolfbjarne
rolfbjarne deleted the dev/rolf/issue-26413-dotnet-linker-remove-dynamic branch September 4, 2026 15:38
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.

[dotnet-linker] Remove the [DynamicDependency] parameter-list workaround once dotnet/runtime#131892 is fixed

4 participants