Repository navigation
[dotnet-linker] Remove DynamicDependency signature workaround. Fixes #26413 - #26560
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 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
GetDynamicDependencySignatureworkaround and switches back to usingDocumentationComments.GetSignaturefor 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>
✅ 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 #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 macOS tests✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
Removes the workaround for dotnet/runtime#131892 (the trimmer crashed with a
NullReferenceException, surfaced aserror 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.GetNameSignatureandAddPreserveAllMembersDynamicDependencyAttributesare 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