Repository navigation
[registrar] Preserve platform assembly with partial-static. Fixes #27610 - #27613
rolfbjarne wants to merge 8 commits into
Conversation
The prebuilt registrar refers to metadata tokens from the original platform assembly. Copy that assembly unchanged when using partial-static so its registrar remains valid and framework references are retained. Fixes #27610 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Warn when the partial-static registrar overrides platform assembly trimming, and use ApiTestApp for the regression cases. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The registrar condition omits accepted partial-static aliases, allowing trimming to retain the prebuilt archive and leaving the linker/token-compatibility failure unresolved.
1 open issue
What changed in this PR
Preserves the Apple platform assembly for the partial-static registrar, addressing #27610 while allowing other assemblies to be trimmed.
Changes:
- Forces platform-assembly copying and adds warning MT7203.
- Adds trimming annotations and targeted warning suppressions.
- Documents the behavior and adds iOS/Mac Catalyst regression coverage.
| File | Description |
|---|---|
| tests/dotnet/UnitTests/RegistrarTest.cs | Checks assembly preservation and registrar compatibility. |
| src/ObjCRuntime/TypeConverter.cs | Annotates reflection-dependent conversions. |
| src/ObjCRuntime/Runtime.cs | Updates trimming annotations and suppressions. |
| src/ObjCRuntime/RequiresSuperAttribute.cs | Suppresses a tooling-related trimming warning. |
| src/ObjCRuntime/DynamicRegistrar.cs | Suppresses a configuration-dependent warning. |
| src/ObjCRuntime/Blocks.cs | Limits suppression to applicable platforms. |
| src/Foundation/NSCoder.cs | Annotates reflection-dependent decoding. |
| msbuild/Xamarin.MacDev.Tasks/Tasks/MacDevMessage.cs | Supports numbered diagnostics. |
| msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx | Adds localized MT7203 text. |
| dotnet/targets/Xamarin.Shared.Sdk.targets | Preserves the platform assembly and emits MT7203. |
| docs/website/mtouch-errors.md | Documents MT7203. |
| docs/building-apps/build-properties.md | Explains partial-static trimming behavior. |
Review effort: Balanced
✅ 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 #b6f45fa] Test results 🔥Test results❌ Tests failed on VSTS: test results 1 tests crashed, 0 tests failed, 143 tests passed. Failures❌ msbuild tests🔥 Failed catastrophically on VSTS: test results - msbuild (no summary found). Html Report (VSDrops) Download Successes✅ 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 |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Platform-assembly rewriting can invalidate prebuilt registrar metadata tokens in the Release/partial-static/strict configuration, and the new warning incorrectly reuses the existing MT7203 diagnostic number.
2 open issues
1 resolved since last review
Review effort: Balanced
| Update="@(ResolvedFileToPublish)" | ||
| Condition="'$(_RegistrarMode)' == 'partial-static' And '%(ResolvedFileToPublish.Filename)' == '$(_PlatformAssemblyName)' And '%(ResolvedFileToPublish.Extension)' == '.dll'" | ||
| > | ||
| <TrimMode>copy</TrimMode> |
| <!-- The partial-static registrar contains metadata tokens from the original platform assembly, so disable trimming for the platform assembly when using the partial-static registrar. --> | ||
| <MacDevMessage | ||
| Condition="'$(_RegistrarMode)' == 'partial-static' And '$(PublishTrimmed)' == 'true' And '%(ResolvedFileToPublish.Filename)' == '$(_PlatformAssemblyName)' And '%(ResolvedFileToPublish.Extension)' == '.dll' And '%(ResolvedFileToPublish.TrimMode)' != 'copy' And ('%(ResolvedFileToPublish.TrimMode)' != '' Or '$(TrimMode)' != 'copy')" | ||
| Code="7203" |
|
🔥 Unable to find the contents for the comment: D:\a\1\s\change-detection\results\gh-comment.md does not exist :fire Pipeline on Agent |
🔥 [CI Build #4ff6177] Test results 🔥Test results❌ Tests failed on VSTS: test results 29 tests crashed, 0 tests failed, 0 tests passed. Failures❌ assembly-processing tests🔥 Failed catastrophically on VSTS: test results - assembly-processing (no summary found). Html Report (VSDrops) Download ❌ cecil tests🔥 Failed catastrophically on VSTS: test results - cecil (no summary found). Html Report (VSDrops) Download ❌ dotnettests tests (iOS)🔥 Failed catastrophically on VSTS: test results - dotnettests_ios (no summary found). Html Report (VSDrops) Download ❌ dotnettests tests (MacCatalyst)🔥 Failed catastrophically on VSTS: test results - dotnettests_maccatalyst (no summary found). Html Report (VSDrops) Download ❌ dotnettests tests (macOS)🔥 Failed catastrophically on VSTS: test results - dotnettests_macos (no summary found). Html Report (VSDrops) Download ❌ dotnettests tests (Multiple platforms)🔥 Failed catastrophically on VSTS: test results - dotnettests_multiple (no summary found). Html Report (VSDrops) Download ❌ dotnettests tests (tvOS)🔥 Failed catastrophically on VSTS: test results - dotnettests_tvos (no summary found). Html Report (VSDrops) Download ❌ framework tests🔥 Failed catastrophically on VSTS: test results - framework (no summary found). Html Report (VSDrops) Download ❌ fsharp tests🔥 Failed catastrophically on VSTS: test results - fsharp (no summary found). Html Report (VSDrops) Download ❌ generator tests🔥 Failed catastrophically on VSTS: test results - generator (no summary found). Html Report (VSDrops) Download ❌ interdependent-binding-projects tests🔥 Failed catastrophically on VSTS: test results - interdependent-binding-projects (no summary found). Html Report (VSDrops) Download ❌ introspection tests🔥 Failed catastrophically on VSTS: test results - introspection (no summary found). Html Report (VSDrops) Download ❌ linker tests (iOS)🔥 Failed catastrophically on VSTS: test results - linker_ios (no summary found). Html Report (VSDrops) Download ❌ linker tests (MacCatalyst)🔥 Failed catastrophically on VSTS: test results - linker_maccatalyst (no summary found). Html Report (VSDrops) Download ❌ linker tests (macOS)🔥 Failed catastrophically on VSTS: test results - linker_macos (no summary found). Html Report (VSDrops) Download ❌ linker tests (tvOS)🔥 Failed catastrophically on VSTS: test results - linker_tvos (no summary found). Html Report (VSDrops) Download ❌ monotouch tests (iOS)🔥 Failed catastrophically on VSTS: test results - monotouch_ios (no summary found). Html Report (VSDrops) Download ❌ monotouch tests (MacCatalyst)🔥 Failed catastrophically on VSTS: test results - monotouch_maccatalyst (no summary found). Html Report (VSDrops) Download ❌ monotouch tests (macOS)🔥 Failed catastrophically on VSTS: test results - monotouch_macos (no summary found). Html Report (VSDrops) Download ❌ monotouch tests (tvOS)🔥 Failed catastrophically on VSTS: test results - monotouch_tvos (no summary found). Html Report (VSDrops) Download ❌ msbuild tests🔥 Failed catastrophically on VSTS: test results - msbuild (no summary found). Html Report (VSDrops) Download ❌ sharpie tests🔥 Failed catastrophically on VSTS: test results - sharpie (no summary found). Html Report (VSDrops) Download ❌ windows tests🔥 Failed catastrophically on VSTS: test results - windows (no summary found). Html Report (VSDrops) Download ❌ xcframework tests🔥 Failed catastrophically on VSTS: test results - xcframework (no summary found). Html Report (VSDrops) Download ❌ xtro tests🔥 Failed catastrophically on VSTS: test results - xtro (no summary found). Html Report (VSDrops) Download ❌ Tests on macOS Sonoma (14) testsHtml Report (VSDrops) Download ❌ Tests on macOS Sequoia (15) testsHtml Report (VSDrops) Download ❌ Tests on macOS Tahoe (26) testsHtml Report (VSDrops) Download ❌ Tests on macOS Golden Gate (27) testsHtml Report (VSDrops) Download SuccessesmacOS testsLinux Build VerificationPipeline on Agent |


Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
4ff6177ed7a1388e206907ec00312ac1f3cc38ca↑ Default-registrar cases pass on installed platforms.
↓ iOS device execution remains unverified.
↓ The original app was not rerun.
This preserves the platform assembly when using the
partial-staticregistrar, so its original metadata tokens remain valid while other assemblies can still be trimmed. It emits warning MT7203 when trimming has to be disabled for the platform assembly, and documents the behavior. Regression coverage verifies the platform assembly stays byte-identical, its MVID is present in the native executable, and registrar validation succeeds.Fixes #27610
🤖 Pull request created by Copilot