fix: allow XAML HR when debugging with mono runtime#22696
fix: allow XAML HR when debugging with mono runtime#22696
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request fixes Hot Reload for XAML when debugging with the mono runtime (specifically iOS and Android) in VS Code. The fix introduces a dual-channel approach where metadata deltas are applied through the debugger channel while updated type information is sent through the regular Hot Reload channel. The PR also includes memory optimizations using AsSpan() instead of ToArray() and eliminates unnecessary object allocations for empty arrays.
Changes:
- Extracted metadata update handler logic into a separate
ApplyUpdatedTypesmethod inHotReloadAgentto allow independent invocation - Modified validation logic to allow null metadata deltas when running with VSCode extension and mono debugger
- Implemented dual-channel approach: metadata deltas via IDE channel, updated types via regular channel when debugging with mono runtime
- Applied memory optimizations using
AsSpan()forImmutableArray<byte>conversions and early return for empty arrays
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Uno.UI.RemoteControl/HotReload/MetadataUpdater/HotReloadAgent.cs | Extracted ApplyUpdatedTypes method to enable separate invocation of metadata update handlers from delta application |
| src/Uno.UI.RemoteControl/HotReload/Messages/AssemblyDeltaReload.cs | Updated validation to conditionally allow null delta properties when running with VSCode extension |
| src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.Agent.cs | Implemented conditional logic to skip delta application when debugging with mono runtime, while still applying updated types |
| src/Uno.UI.RemoteControl.Server.Processors/HotReload/ServerHotReloadProcessor.MetadataUpdate.cs | Refactored to send deltas through IDE channel and types through regular channel when debugging; applied memory optimizations with AsSpan() |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| [MemberNotNullWhen(true, nameof(UpdatedTypes), nameof(MetadataDelta), nameof(ILDelta), nameof(PdbDelta), nameof(ModuleId))] | ||
| public bool IsValid() | ||
| public bool IsValid(bool runningInsideVSCodeExtension) | ||
| { | ||
| return FilePaths is { IsEmpty: false } | ||
| && UpdatedTypes is not null | ||
| && MetadataDelta is not null | ||
| && ILDelta is not null | ||
| && PdbDelta is not null | ||
| && (MetadataDelta is not null || runningInsideVSCodeExtension) | ||
| && (ILDelta is not null || runningInsideVSCodeExtension) | ||
| && (PdbDelta is not null || runningInsideVSCodeExtension) | ||
| && ModuleId is not null; |
There was a problem hiding this comment.
The MemberNotNullWhen attribute states that MetadataDelta, ILDelta, and PdbDelta will be non-null when IsValid returns true. However, the method now allows these properties to be null when runningInsideVSCodeExtension is true. This creates a mismatch between the attribute contract and the actual behavior. Consider updating the attribute to only guarantee non-null for UpdatedTypes and ModuleId, or conditionally include the delta properties based on the parameter value.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22696/wasm-skia-net9/index.html |
GitHub Issue: closes https://github.com/unoplatform/uno.vscode/issues/1240
PR Type:
What is the current behavior? 🤔
When debugging with the mono runtime (e.g. iOS and Android) Hot Reload might not always work, e.g. modifying XAML.
What is the new behavior? 🚀
Hot Reload should always work, when debugging or not, whatever the runtime.
PR Checklist ✅
Please check if your PR fulfills the following requirements:
Screenshots Compare Test Runresults.Other information ℹ️
AsSpaninstead ofToArrayto reduce memory allocationsMemoryStreamand aBinaryWriterwhen the array is empty