[Hot Reload] Add assembly modification safety net. Fixes #26072 - #26417
[Hot Reload] Add assembly modification safety net. Fixes #26072#26417rolfbjarne wants to merge 2 commits into
Conversation
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.
Pull request overview
Adds a Hot Reload compatibility “safety net” to prevent reloadable (Copy) assemblies from being re-saved during HotReloadCompatibleBuild builds, and updates build defaults/documentation so NativeAOT builds don’t opt into this mode by default.
Changes:
- Add a guard in
AppBundleRewriter.SaveAssemblythat reports an error and skips saving when HotReloadCompatibleBuild is enabled for a reloadable (Copy) assembly. - Default
$(HotReloadCompatibleBuild)to Debug for non-NativeAOT builds, and tofalsefor NativeAOT. - Update build-property documentation to reflect the NativeAOT default behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tools/dotnet-linker/AppBundleRewriter.cs | Adds the enforcement check that blocks saving reloadable assemblies during Hot Reload compatible builds. |
| dotnet/targets/Xamarin.Shared.Sdk.targets | Adjusts MSBuild defaults so NativeAOT doesn’t enable HotReloadCompatibleBuild by default. |
| docs/building-apps/build-properties.md | Documents the updated default (non-NativeAOT Debug => true; otherwise false). |
Suppressed comments (2)
tools/dotnet-linker/AppBundleRewriter.cs:1507
- 🤖 💡 Error message — The error text says the assembly “was modified”, but this guard is actually about preventing any reloadable assembly from being saved/re-serialized (which can happen even for metadata-preservation reasons). Consider wording that explains the byte-for-byte constraint and points to $(HotReloadCompatibleBuild) as the controlling switch.
configuration.Logger.LogError (ErrorHelper.CreateError (99, $"The assembly '{assembly.Name.Name}' is reloadable, but was modified during a Hot Reload compatible build."));
tools/dotnet-linker/AppBundleRewriter.cs:1509
- 🤖 💡 Testing — This new safety-net behavior (failing when a reloadable/Copy assembly would be saved under HotReloadCompatibleBuild) doesn’t appear to have a regression test. Given there’s already a dedicated assembly-preparer test harness (tests/assembly-preparer/BaseClass.cs), it would be good to add a focused test that exercises this specific failure mode and asserts on the emitted error (and code, once it’s dedicated).
if (configuration.HotReloadCompatibleBuild && action == AssemblyAction.Copy && assembly != PlatformAssembly) {
configuration.Logger.LogError (ErrorHelper.CreateError (99, $"The assembly '{assembly.Name.Name}' is reloadable, but was modified during a Hot Reload compatible build."));
return;
}
✅ 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 |
🔥 [PR Build #b9e7df2] Build failed (Build macOS tests) 🔥Build failed for the job 'Build macOS tests' (with job status 'Failed') Pipeline on Agent |
🔥 [CI Build #b9e7df2] Test results 🔥Test results❌ Tests failed on VSTS: test results 5 tests crashed, 36 tests failed, 144 tests passed. Failures❌ dotnettests tests (iOS)1 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download ❌ dotnettests tests (MacCatalyst)1 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download ❌ dotnettests tests (macOS)1 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download ❌ dotnettests tests (tvOS)1 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download ❌ interdependent-binding-projects tests3 tests failed, 1 tests passed.Failed tests
Html Report (VSDrops) Download ❌ linker tests (iOS)2 tests failed, 13 tests passed.Failed tests
Html Report (VSDrops) Download ❌ linker tests (MacCatalyst)2 tests failed, 13 tests passed.Failed tests
Html Report (VSDrops) Download ❌ linker tests (macOS)4 tests failed, 17 tests passed.Failed tests
Html Report (VSDrops) Download ❌ linker tests (tvOS)2 tests failed, 13 tests passed.Failed tests
Html Report (VSDrops) Download ❌ monotouch tests (iOS)5 tests failed, 14 tests passed.Failed tests
Html Report (VSDrops) Download ❌ monotouch tests (MacCatalyst)4 tests failed, 14 tests passed.Failed tests
Html Report (VSDrops) Download ❌ monotouch tests (macOS)4 tests failed, 17 tests passed.Failed tests
Html Report (VSDrops) Download ❌ monotouch tests (tvOS)5 tests failed, 14 tests passed.Failed tests
Html Report (VSDrops) Download ❌ windows tests1 tests failed, 2 tests passed.Failed tests
Html Report (VSDrops) Download ❌ Tests on macOS Monterey (12) testsHtml Report (VSDrops) Download ❌ Tests on macOS Ventura (13) testsHtml 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 Successes✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download macOS testsLinux Build VerificationPipeline on Agent |
[Hot Reload] Add assembly modification safety net. Fixes #26072
Add the HotReloadCompatibleBuild MSBuild default and enforce that reloadable user assemblies are not modified during compatible builds.
The safety net reports a normal linker error when a Copy assembly would be saved. NativeAOT builds default HotReloadCompatibleBuild to false, and the build-property documentation now describes the behavior.
Fixes #26072
🤖 Pull request created by Copilot