Skip to content

Hot Reload is blocked in any net11.0 project that uses C# 15 syntaxΒ #26316

Closed

Description

@Jen-Uno

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) πŸ”¬

  1. dotnet new unoapp -tfm net11.0 -platforms desktop -preset blank (Uno.Sdk 7.0.5).
  2. 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;
        }
    }
  3. dotnet build succeeds: LangVersion is 15.0 by default on net11.0.
  4. Run the app in Debug with the DevServer, then change any text in MainPage.xaml.
  5. 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.props pins DevServerRoslynVersion 5.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.0 but inherits LangVersion 13.0 from src/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.

Metadata

Metadata

Assignees

Labels

triage/untriaged

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions