Repository navigation
Description
Current behavior π
TL;DR β On .NET 11, C# 15 is the default language version for net11.0 projects, but the DevServer compiles Hot Reload changes with Roslyn 5.6, which stops at C# 14. One line of C# 15 anywhere in a project blocks every Hot Reload edit to that project, XAML-only edits included, while the project itself builds fine.
Basically, the DevServer's compiler is a language version behind the SDK it serves, and a Roslyn bump for the net11.0 host would settle it.
A XAML-only edit, changing a TextBlock's Text in MainPage.xaml, gives this in the DevServer output:
Emit status: Blocked
Found 0 metadata updates after 00:00:01.19
Hot reload blocked by 6 compilation error(s) in Cs15Check (edited: MainPage.xaml).
Grid15.cs(15,30): error CS1002: ; expected
Grid15.cs(21,27): error CS1002: ; expected
Plus CS0103 and CS0201 on the same two lines, which hold a labeled continue outer; and break outer;. dotnet build of the same project reports 0 errors. With that file rewritten in C# 14, the same kind of edit gives Found 1 metadata updates.
Expected behavior π―
Hot Reload compiles with the language version the build uses. Until it can, it should say the project's language version is newer than the DevServer supports, instead of listing compile errors the build doesn't have.
How to reproduce it (as minimally and precisely as possible) π¬
dotnet new unoapp -tfm net11.0 -platforms desktop -preset blank(Uno.Sdk 7.0.5).- Add a file that uses any C# 15 syntax, for example:
public static class Grid15 { public static void Walk() { outer: for (var i = 0; i < 3; i++) for (var j = 0; j < 3; j++) if (j == 1) continue outer; } }
dotnet buildsucceeds:LangVersionis 15.0 by default onnet11.0.- Run the app in Debug with the DevServer, then change any text in
MainPage.xaml. - The DevServer output shows "Hot reload blocked by N compilation error(s)", pointing at the C# 15 lines.
Workaround π οΈ
Target net10.0, or keep C# 15 syntax out of the projects you hot reload.
Affected platforms π±π»π₯οΈ
Desktop (Skia), on macOS. I only ran desktop, but the block happens in the DevServer's compile step, so it should apply to every target the DevServer compiles for.
Uno.Sdk version (and other relevant versions) π¦
Uno.Sdk 7.0.5 (Uno.WinUI 7.0.32, Uno.WinUI.DevServer 7.0.32), .NET SDK 11.0.100.
IDE version π§βπ»
None: the DevServer was started from the command line. Not tested in Visual Studio, where VS compiles the change itself.
Anything else we need to know? π¬
src/Uno.DevServer.Roslyn.propspinsDevServerRoslynVersion5.6.0 for the net11.0 host. SDK 11.0.100 ships Roslyn 5.12.- Spec 053's R2 says each host flavor embeds the latest Roslyn line of the SDK it serves. The net11.0 flavor can't yet, because nuget.org has no Roslyn 5.12 package; the newest stable is 5.9.0, which also stops at C# 14.
- The Hot Reload test app wouldn't catch this: it targets
net11.0but inheritsLangVersion13.0 fromsrc/Directory.Build.props. - I tested labeled
continue/break. Unions, closed hierarchies,with(...)in collection expressions and extension indexers are also C# 15 syntax and should hit the same wall.
Activity
build(hr): Scope the dotnet-tools feed to HR projects
feat(hr): Explain blocked reloads on newer C#
docs(hr): Record spec 061 validation and fixes
test(hr): Hot reload an edit inside C# 15 code
test(hr): Link the C# 15 runtime test to its issue
docs(hr): Add spec 061 for the net11 Roslyn bump
fix(hr): Embed Roslyn 5.12 in the net11 dev-server
feat(hr): Warn when C# is newer than the HR compiler
test(hr): Compile C# 15 syntax in HRApp