Skip to content

fix: allow XAML HR when debugging with mono runtime#22696

Draft
spouliot wants to merge 1 commit intomasterfrom
dev/spouliot/xaml-hr-debug-mono
Draft

fix: allow XAML HR when debugging with mono runtime#22696
spouliot wants to merge 1 commit intomasterfrom
dev/spouliot/xaml-hr-debug-mono

Conversation

@spouliot
Copy link
Contributor

GitHub Issue: closes https://github.com/unoplatform/uno.vscode/issues/1240

PR Type:

  • 🐞 Bugfix

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:

Other information ℹ️

  • use AsSpan instead of ToArray to reduce memory allocations
  • skip the creation of a MemoryStream and a BinaryWriter when the array is empty
  • needs more testing so it's a draft for the moment

Copilot AI review requested due to automatic review settings February 19, 2026 21:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ApplyUpdatedTypes method in HotReloadAgent to 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() for ImmutableArray<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.

Comment on lines 35 to 43
[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;
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@unodevops
Copy link
Contributor

🤖 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments