Repository navigation
fix(runtime): make UnsafeBlit trimming and NativeAOT consumption safe - #763
Merged
Merged
Conversation
SunSi12138
marked this pull request as ready for review
September 29, 2026 12:24
SunSi12138
marked this pull request as draft
September 30, 2026 00:38
SunSi12138
marked this pull request as ready for review
September 30, 2026 00:38
Owner
Author
|
Review follow-up addressed:
Validation on head
The JIT fallback assertion was intentionally retained and now passes after the AOT smoke, proving the packaged Runtime DLL is no longer contaminated. |
SunSi12138
marked this pull request as draft
September 30, 2026 05:46
SunSi12138
marked this pull request as ready for review
October 1, 2026 23:26
Owner
Author
|
Final validation on head
The PR is Ready for Review again. |
SunSi12138
marked this pull request as draft
October 1, 2026 23:53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #761
3.x structural follow-up: #762.
Problem
The final application decides whether it is trimmed or NativeAOT, but
SharpLink.Runtimemay arrive through either a precompiled PackageReference or a source ProjectReference.PublishTrimmed/PublishAotonly in the application project; those ordinary project properties are not automatically forwarded to referenced projects as MSBuild global properties.A child-project
#if PublishTrimmed/PublishAottherefore cannot be the only correctness boundary.2.x support contract
TrimMode=fullare supported through the embedded linker substitution.TrimMode=partial: not part of the 2.x support contract. A prototype usingIsTrimmable=truemade partial trimming link Runtime, but caused a real iOS CoreCLR runtime regression in the blocking mobile evidence. That broader linker-policy change is deferred to the 3.x structural work in [3.x / NativeAOT / Architecture] Separate generated UnsafeBlit ABI validation from reflective fallback #762.This preserves the existing mobile
TrimMode=copybehavior instead of changing the whole Runtime assembly's linker semantics for a narrow source-consumer scenario.2.x fix
Embedded linker substitution
SharpLink.Runtime.dllembedsILLink.Substitutions.xml.RpcUnsafeBlitPlatform.ReflectionFallbackEnabledis stubbed tofalse.Package feature switch at final execution time
buildTransitive/SharpLink.Runtime.targetsuses an execution-time target rather than an evaluation-timeItemGroup._ComputePublishTrimmedwhen that target exists, and before runtimeconfig/ILLink consumeRuntimeHostConfigurationOption.SharpLink.Runtime.UnsafeBlitReflectionFallback=falsefor packaged trimming / NativeAOT consumers even whenPublishTrimmedis computed late.TrimMode=partial, where Runtime remains a copy assembly, the same execution-time target adds a package-scoped ILLink warning-suppression file. This keeps unsupported ProjectReference partial trimming warning-visible._ILLinkSuppressionshook is an SDK-internal .NET 10 coupling, so the nupkg verifier and package smoke explicitly lock that integration.No blanket trim opt-in
IsTrimmable=truein 2.x.RequiresUnreferencedCode.Untrimmed JIT keeps the reflective fallback. Supported trimmed/NativeAOT consumers require generated ABI metadata and fail closed when it is missing.
Regression coverage
PR Package Smoketriggers on Runtime, Generator, SDK, package smoke projects, and the source publish smoke scripts. On every relevant synchronize it executes:Acceptance details:
PublishTrimmed=true,PublishAot=false,TrimMode=fullonly in the app project./p:PublishTrimmed=true.PublishAot=trueonly in their project files; the smoke script no longer injects-p:PublishAot=true.buildTransitive/SharpLink.Runtime.targetsto be present in the Runtime nupkg and verifies the packaged feature-switch setting.TrimMode=partialconsumer, so the feature-switch path is exercised independently of the full-trim linker substitution.PublishTrimmedunset, simulates the Apple workload_ComputePublishTrimmedtarget setting it totrue, and requires both the runtime feature switch and partial-trim suppression to be added afterward.pack --no-build.mktemp -ddirectory under$ROOT/artifacts.Release blocking
Release Gate now calls the reusable Codec Mobile Evidence workflow and includes its result in
release-summary.needs. The existing mobile summary requires Android CoreCLR and iOS CoreCLR evidence to succeed; iOS x64 is the blocking non-experimental lane.Because the Release Gate itself only auto-runs for PRs targeting
main, a narrow PR Release Mobile Wiring check runs when either release/mobile workflow file changes. It invokes the same reusable mobile workflow from a caller workflow and then verifies thatrelease-gate.ymlstill wirescodec-mobile-evidenceintorelease-summary.needs. This gives the caller integration a persistent PR regression check without running the entire Release Gate on everydevPR.Non-goals
IsTrimmable=truechange in 2.x;