unoplatform / uno

Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
https://platform.uno
Apache License 2.0
8.94k stars 724 forks source link

`net5.0+` and Skia XAML Hot Reload does not work if the solution path contains a `#` character #5953

Closed Luk164 closed 1 year ago

Luk164 commented 3 years ago

Current behavior

I am getting a LOT of errors and warnings, even though solutions compile and run just fine.

Expected behavior

No errors/warnings.

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

  1. Create a fresh template
  2. Add this to GTK so build succeeds
<PropertyGroup>
    <UnoUIUseRoslynSourceGenerators>false</UnoUIUseRoslynSourceGenerators>
 </PropertyGroup>
  1. Main layout
    This is my main layout:
 <Page
    x:Class="VentoyTool.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:VentoyTool"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
    mc:Ignorable="d">

    <muxc:NavigationView x:Name="nvSample" HorizontalAlignment="Stretch">
        <muxc:NavigationView.MenuItems>
            <muxc:NavigationViewItem Icon="Play" Content="Menu Item1" Tag="SamplePage1" />
            <muxc:NavigationViewItem Icon="Save" Content="Menu Item2" Tag="SamplePage2" />
            <muxc:NavigationViewItem Icon="Refresh" Content="Menu Item3" Tag="SamplePage3" />
            <muxc:NavigationViewItem Icon="Download" Content="Menu Item4" Tag="SamplePage4" />
        </muxc:NavigationView.MenuItems>
        <Frame x:Name="contentFrame" HorizontalAlignment="Stretch"/>
    </muxc:NavigationView>

</Page>

  1. Test layout (it is loaded to Frame in main layout on construction)
    This is my test layout:
 <Page
    x:Class="VentoyTool.Test"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:VentoyTool"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid>
        <TextBox Text="Test text or something" FontSize="48"/>
    </Grid>
</Page>

  1. Results into following errors/warnings:
    Log:
 Severity   Code    Description Project File    Line    Suppression State
Warning     Found conflicts between different versions of "System.Numerics.Vectors" that could not be resolved.
There was a conflict between "System.Numerics.Vectors, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
    "System.Numerics.Vectors, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
    References which depend on "System.Numerics.Vectors, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Numerics.Vectors.dll].
        C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Numerics.Vectors.dll
          Project file item includes which caused reference "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Numerics.Vectors.dll".
            System.Numerics.Vectors
    References which depend on "System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [].
        C:\Users\lukij\.nuget\packages\system.text.json\5.0.0\lib\netstandard2.0\System.Text.Json.dll
          Project file item includes which caused reference "C:\Users\lukij\.nuget\packages\system.text.json\5.0.0\lib\netstandard2.0\System.Text.Json.dll".
            C:\Users\lukij\.nuget\packages\system.text.json\5.0.0\lib\netstandard2.0\System.Text.Json.dll
            C:\Users\lukij\.nuget\packages\microsoft.extensions.logging.console\5.0.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Console.dll   VentoyTool.Droid            
Error   CS1061  'Test' does not contain a definition for 'InitializeComponent' and no accessible extension method 'InitializeComponent' accepting a first argument of type 'Test' could be found (are you missing a using directive or an assembly reference?)  VentoyTool.Droid, VentoyTool.Skia.Gtk, VentoyTool.Skia.Tizen, VentoyTool.Skia.Wpf, VentoyTool.Wasm, VentoyTool.iOS, VentoyTool.macOS    D:\User_files\Projekty\C#\Uno\VentoyTool\VentoyTool\VentoyTool.Shared\Test.xaml.cs  27  Active
Error   CS0103  The name 'contentFrame' does not exist in the current context   VentoyTool.Skia.Tizen, VentoyTool.Skia.Wpf, VentoyTool.Wasm, VentoyTool.iOS, VentoyTool.macOS   D:\User_files\Projekty\C#\Uno\VentoyTool\VentoyTool\VentoyTool.Shared\MainPage.xaml.cs  29  Active
Error   XDG0062 Type Microsoft.UI.Xaml.Controls.NavigationView cannot be created in XAML. Building the project may help.    VentoyTool.UWP  D:\User_files\Projekty\C#\Uno\VentoyTool\VentoyTool\VentoyTool.Shared\MainPage.xaml 11  
Error   XDG0062 Type Microsoft.UI.Xaml.Controls.NavigationViewItem cannot be created in XAML. Building the project may help.    VentoyTool.UWP  D:\User_files\Projekty\C#\Uno\VentoyTool\VentoyTool\VentoyTool.Shared\MainPage.xaml 13  
Error   XDG0062 Type Microsoft.UI.Xaml.Controls.NavigationViewItem cannot be created in XAML. Building the project may help.    VentoyTool.UWP  D:\User_files\Projekty\C#\Uno\VentoyTool\VentoyTool\VentoyTool.Shared\MainPage.xaml 14  
Error   XDG0062 Type Microsoft.UI.Xaml.Controls.NavigationViewItem cannot be created in XAML. Building the project may help.    VentoyTool.UWP  D:\User_files\Projekty\C#\Uno\VentoyTool\VentoyTool\VentoyTool.Shared\MainPage.xaml 15  
Error   XDG0062 Type Microsoft.UI.Xaml.Controls.NavigationViewItem cannot be created in XAML. Building the project may help.    VentoyTool.UWP  D:\User_files\Projekty\C#\Uno\VentoyTool\VentoyTool\VentoyTool.Shared\MainPage.xaml 16  
Error   CS1061  'MainPage' does not contain a definition for 'InitializeComponent' and no accessible extension method 'InitializeComponent' accepting a first argument of type 'MainPage' could be found (are you missing a using directive or an assembly reference?)  VentoyTool.iOS, VentoyTool.macOS    D:\User_files\Projekty\C#\Uno\VentoyTool\VentoyTool\VentoyTool.Shared\MainPage.xaml.cs  27  Active
Warning CS8785  Generator 'XamlCodeGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'ArgumentException' with message 'The path is not of a legal form.'   VentoyTool.UWP  D:\User_files\Projekty\C#\Uno\VentoyTool\VentoyTool\VentoyTool.UWP\CSC  1   Active
Warning     PRI257: 0xdef00522 - Resources found for language(s) 'en' but no resources found for default language(s): 'en-US'. Change the default language or qualify resources with the default language. http://go.microsoft.com/fwlink/?LinkId=231899    VentoyTool.UWP  D:\User_files\Projekty\C#\Uno\VentoyTool\VentoyTool\VentoyTool.UWP\GENERATEPROJECTPRIFILE       
Warning NU1701  Package 'SkiaSharp.Views 2.80.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v3.1'. This package may not be fully compatible with your project.    VentoyTool.Skia.Wpf.Host    D:\User_files\Projekty\C#\Uno\VentoyTool\VentoyTool\VentoyTool.Skia.Wpf.Host\VentoyTool.Skia.Wpf.Host.csproj    1   
Warning NU1701  Package 'SkiaSharp.Views 2.80.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework 'net5.0'. This package may not be fully compatible with your project.  VentoyTool.Skia.Gtk D:\User_files\Projekty\C#\Uno\VentoyTool\VentoyTool\VentoyTool.Skia.Gtk\VentoyTool.Skia.Gtk.csproj  1   

Environment

Nuget Package:

Affected platform(s):

IDE:

Relevant plugins:

Anything else we need to know?

I disabled solution wide analysis on ReSharper. It is a bit frustrating because I really love the idea of the UNO platform, but at the same time it is incredibly difficult to just get an empty template that does not throw warnings and errors at every step, with or without ReSharper.

jeromelaban commented 3 years ago

Thanks for the report!

A few questions:

Luk164 commented 3 years ago

@jeromelaban

  1. It does not build at all, the problem was already mentioned in https://github.com/unoplatform/uno/issues/5468
  2. Yes, Android, IOS, Mac, WPF, and more. Everything the template plugin generates is present.
jeromelaban commented 3 years ago

Thanks for the update.

For 1., are you still getting the error of #5468 even with Uno 3.7 ?

For the errors you're seeing in 2. , the only way to get rid of those is to build all projects once, close visual studio and open it again. It's a Visual Studio issue we have no control over, but we expect that .NET 6 will reduce the errors significantly.

Luk164 commented 3 years ago

@jeromelaban

  1. Screenshots are worth a 1000 words right? image image

  2. They seem to have persisted with restarts but disappeared when I manually wiped the cache. Also unrelated but ReSharper seems to get a stroke anytime I use UNO. Support ticket exists but it does not look like they are putting much effort into it. Did anyone think about creating a 3rd party plugin for resharper?

jeromelaban commented 3 years ago

Thanks for the update.

  1. Does the build error happen when disabling resharper (particularly their custom build tooling ?), and does the error happen when building on the CLI with dotnet new ? If so can you run dotnet build /bl and post the msbuild.binlog file ?
  2. We have not considered creating a resharper plugin yet.
Luk164 commented 3 years ago

@jeromelaban The resharper builder was already disabled, I only use it rarely anyway. I am not very experienced with dotnet CLI so just to make sure I do not mess up can you please post full commands for me to try out?

Regarding the ReSharper, should I add a feature ticket, or is it too expensive to even consider?

jeromelaban commented 3 years ago

Apologies for the command line mistake I fixed it above, but basically, using a command prompt:

cd myApp\myApp.Wasm
dotnet build /bl

This will create a msbuild.binlog file that you can post here (zipped).

Luk164 commented 3 years ago

@jeromelaban Here are the logs, 0 errors for both WASM and GTK. 2 errors for GTK with that property group commented out. logs.zip

jeromelaban commented 3 years ago

Thanks for the reports. I've found the issue here, and it's unfortunately related to this Roslyn issue https://github.com/dotnet/roslyn/issues/44596, and is caused by the folder name of your solution (it contains C# in the path). https://github.com/unoplatform/uno/pull/5978 will work around it in Uno, but it will prevent hotreload from working properly until the path keeps containing a #.

Luk164 commented 3 years ago

@jeromelaban Ok, for now I just renamed my projects folder to CSharp, hopefully that will break only some of my projects... Maybe I will add a C# folder with a symlink to CSharp.

Youssef1313 commented 1 year ago

@jeromelaban I don't think we can do anything here. Should we close?

jeromelaban commented 1 year ago

Indeed, we cannot do anything we'll have to wait for roslyn updates.