uno icon indicating copy to clipboard operation
uno copied to clipboard

Hot reload of XAML on Windows does not work.

Open christianfo opened this issue 1 year ago • 5 comments

Current behavior

This might be a bug for the WinUI team.

With Windows as the target platform, on a sample Uno Platform app, editing anything in MainPage.xaml using Visual Studio while the app is running causes incorrect errors to be highlighted in the XAML and fails to hot reload the XAML. On a real app, editing anything in most pages presents the same issue.

Expected behavior

Hot reload of XAML to work, at least on Windows

How to reproduce it (as minimally and precisely as possible)

  • Create a sample Uno Platform App using project wizard (I have tried with .Net7 and .Net8 with the same result)
  • Build and launch the app
  • Edit anything in MainPage.xaml
  • The following error is shown and hot reload does not work.
Error	XHR0047	The specified value cannot be assigned. The following type was expected: "String".

Screenshot 2024-02-16 173401

Workaround

None found so far.

Works on UWP/WinUI

None

Environment

No response

NuGet package version(s)

    <PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="8.0.0-rc.2.23479.6" />
    <PackageVersion Include="Microsoft.Windows.Compatibility" Version="8.0.0-rc.2.23479.10" />
    <PackageVersion Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.756" />
    <PackageVersion Include="Microsoft.WindowsAppSDK" Version="1.4.231008000" />
    <PackageVersion Include="Uno.Core.Extensions.Logging.Singleton" Version="4.0.1" />
    <PackageVersion Include="Uno.Extensions.Logging.OSLog" Version="1.7.0" />
    <PackageVersion Include="Uno.Extensions.Logging.WebAssembly.Console" Version="1.7.0" />
    <PackageVersion Include="Uno.Material.WinUI" Version="4.1.1" />
    <PackageVersion Include="Uno.Resizetizer" Version="1.3.0" />
    <PackageVersion Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="5.1.56" />
    <PackageVersion Include="Uno.UniversalImageLoader" Version="1.9.36" />
    <PackageVersion Include="Uno.Wasm.Bootstrap" Version="9.0.0-dev.31" />
    <PackageVersion Include="Uno.Wasm.Bootstrap.DevServer" Version="9.0.0-dev.31" />
    <PackageVersion Include="Uno.Wasm.Bootstrap.Server" Version="9.0.0-dev.31" />
    <PackageVersion Include="Uno.WinUI" Version="5.1.56" />
    <PackageVersion Include="Uno.WinUI.Lottie" Version="5.1.56" />
    <PackageVersion Include="Uno.WinUI.DevServer" Version="5.1.56" />
    <PackageVersion Include="Uno.WinUI.WebAssembly" Version="5.1.56" />
    <PackageVersion Include="Xamarin.Google.Android.Material" Version="1.10.0.1" />

Affected platforms

Windows

IDE

Visual Studio 2022

IDE version

17.8 or 17.9 (reproes with both)

Relevant plugins

No response

Anything else we need to know?

Please advise if this should be posted to the WindowsAppSDK project instead.

christianfo avatar Feb 17 '24 01:02 christianfo

Thanks! This is a duplicate of https://github.com/unoplatform/uno/issues/15517. It is indeed a behavior coming from Visual Studio, but we may be able to work around it from Uno's projects.

jeromelaban avatar Feb 17 '24 01:02 jeromelaban

@jeromelaban, I am not sure I understand. I do have a Windows head project, in fact this reproes if all I have is a Windows head project. So that seems different than #15517. Also, my issue is not so much that the IntelliSense is wrong than this seems to completely break hot reload of XAML on Windows. At least, it does for me, and I don't know how to work around it. It also reproes on two different machines of mine.

christianfo avatar Feb 17 '24 18:02 christianfo

I see. Are you selecting the Windows project in the top left selector in the XAML editor window?

jeromelaban avatar Feb 19 '24 12:02 jeromelaban

I suspect this should be fixed by https://github.com/unoplatform/uno/pull/15333

Can you try with 5.2.0-dev.556 (or later) instead of 5.1.56?

Youssef1313 avatar Feb 19 '24 12:02 Youssef1313

@jeromelaban, this might be it. I had not noticed it, but it has changed to maccatalyst. It seems to work when I select Windows indeed, but let me confirm with a little more testing.

christianfo avatar Feb 20 '24 04:02 christianfo

@jeromelaban and @Youssef1313, I am confirming that the problem I was seeing was indeed due to not having selected the Windows project in the top left selector of the XAML editor. VS seems to be changing this a bit at random every time you close and re-open the solution and I had not noticed it. My apologies for taking up your time on this. This issue can be closed.

christianfo avatar Feb 20 '24 18:02 christianfo

@christianfo Thank you for confirming!

Youssef1313 avatar Feb 20 '24 18:02 Youssef1313