[dotnet-linker] Use [DynamicDependency] attributes instead of manual marking in MarkIProtocolHandler.#24931
Conversation
…marking in MarkIProtocolHandler. This makes it easier to move this code out of a custom linker step in the future. Contributes towards #17693.
There was a problem hiding this comment.
Pull request overview
This PR updates the dotnet-linker trimming pipeline to preserve protocol-related interface metadata via DynamicDependency attributes rather than manually marking protocol interfaces during linking, supporting the longer-term goal of removing custom linker steps (Issue #17693).
Changes:
- Reworked
MarkIProtocolHandlerfrom a mark handler into a pre-mark linker step that injectsDynamicDependencyattributes. - Extended the dotnet-linker
Profilehelper APIs to quickly filter assemblies that are/ reference the platform assembly. - Added
AppBundleRewriterhelpers for creating and de-duplicatingDynamicDependencyattributes on static constructors, and movedMarkIProtocolHandlerto run beforeMarkStep.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| tools/dotnet-linker/MarkIProtocolHandler.cs | Converts protocol preservation from manual marking to injected DynamicDependency before marking begins. |
| tools/dotnet-linker/Compat.cs | Adds helper methods to detect assemblies that reference the platform assembly. |
| tools/dotnet-linker/AppBundleRewriter.cs | Adds helpers for creating/adding DynamicDependency attributes onto static constructors and avoiding duplicates. |
| dotnet/targets/Xamarin.Shared.Sdk.targets | Moves MarkIProtocolHandler into the pre-mark custom steps list. |
You can also share your feedback on Copilot code review. Take the survey.
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.
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.
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.
This way we get validation of any xml docs in dotnet-linker.
…dependency-attributes-markiprotocolhandler
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [CI Build #278c8dc] Build passed (Build packages) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #278c8dc] Build passed (Detect API changes) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
✅ 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 #278c8dc] Build passed (Build macOS tests) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #278c8dc] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 156 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
This makes it easier to move this code out of a custom linker step in the future.
Contributes towards #17693.