Skip to content

Upgrade the app to .NET 10 and confirm compilation#218

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/upgrade-to-dotnet-10
Draft

Upgrade the app to .NET 10 and confirm compilation#218
Copilot wants to merge 3 commits intomainfrom
copilot/upgrade-to-dotnet-10

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 18, 2026

Upgrades BlazorInteractive from .NET 7.0 to .NET 10.

Changes Made

  • global.json: Updated SDK version from 7.0.408 to 10.0.102
  • All 6 .csproj files: Updated TargetFramework from net7.0 to net10.0
  • Package upgrades:
    • Microsoft.AspNetCore.Components.WebAssembly + DevServer: 7.0.2010.0.5
    • Microsoft.Extensions.Http: 7.0.1310.0.5
    • Microsoft.Extensions.Logging / .Abstractions: 8.0.x10.0.5
    • Microsoft.CodeAnalysis.CSharp: 4.14.05.3.0
    • Microsoft.CodeAnalysis.CSharp.Scripting: added at 5.3.0
    • NuGet.Protocol: 6.14.07.3.0
    • BlazorMonaco: 3.3.03.4.0
    • Removed Microsoft.Web.LibraryManager.Build (Monaco editor is already served via _content/BlazorMonaco/ in index.html)
  • BlazorInteractive.csproj: Added <WasmEnableWebcil>false</WasmEnableWebcil> so assemblies are published as plain PE .dll files (required for MetadataReference.CreateFromImage); <PublishTrimmed>false</PublishTrimmed> retained to preserve Roslyn reflection paths
  • EditorComponent.razor: Fixed CS0618 warning — updated obsolete Global.SetTheme(string) to inject IJSRuntime and use the Global.SetTheme(JSRuntime, theme) overload
  • BootstrapResources.cs: Added CoreAssembly dictionary property — in .NET 10, System.Private.CoreLib moved to a separate coreAssembly category in the manifest
  • BootstrapInfo.cs: Assemblies() now merges both Assembly and CoreAssembly categories; without both, Roslyn throws "Predefined type 'System.Object' is not defined"
  • BlazorReferenceFilter.cs: Updated to handle the .NET 10 format — the assembly manifest is now embedded in _framework/dotnet.js between /*json-start*/ and /*json-end*/ markers; falls back to _framework/blazor.boot.json for .NET 8 backward-compatibility
  • CSharpCompilationBuilder.cs: Switched from CSharpCompilation.Create to CreateScriptCompilationAssembly.Location is always empty in a WASM host, so explicit MetadataReference.CreateFromImage(bytes) objects are used instead
  • CSharpCompiler.cs: Parses user source with SourceCodeKind.Script to match script compilation mode
  • IAssemblyInvoker.cs + AssemblyInvoker.cs: Changed to Task<string?> InvokeAsync(Assembly) — locates the Roslyn-generated <Factory> entry point on Submission#0 via reflection and awaits it; Console.SetOut redirects output to the panel
  • Index.razor: Removed the class/namespace wrapper (script compilation handles top-level statements directly); updated invocation to await AssemblyInvoker.InvokeAsync

Testing

  • dotnet build succeeds with 0 errors
  • ✅ 19/21 tests pass (2 pre-existing NuGetPackageGetter failures — issue NuGet Packages #19, NotImplementedException)
Original prompt

This section details on the original issue you should resolve

<issue_title>.NET 10</issue_title>
<issue_description>Upgrade the app to .NET 10.
Make any necessary changes an confirm it compiles.
Update any necessary tests, add any missing.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

@AlexHedley
Copy link
Copy Markdown
Collaborator

AlexHedley commented Mar 19, 2026

@copilot complete tasks

… fix obsolete API

Co-authored-by: AlexHedley <1573469+AlexHedley@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Mar 19, 2026

@copilot complete tasks

Completed in commit a7420db. Here's a summary of all changes made:

  • global.json: Updated SDK from 7.0.40810.0.102
  • All 6 .csproj files: Updated TargetFramework from net7.0net10.0
  • Package upgrades:
    • Microsoft.AspNetCore.Components.WebAssembly + DevServer: 7.0.2010.0.5
    • Microsoft.Extensions.Http: 7.0.1310.0.5
    • Microsoft.Extensions.Logging / .Abstractions: 8.0.x10.0.5
    • Microsoft.CodeAnalysis.CSharp: 4.14.05.3.0
    • NuGet.Protocol: 6.14.07.3.0
    • BlazorMonaco: 3.3.03.4.0
    • Removed Microsoft.Web.LibraryManager.Build (Monaco editor is already served via _content/BlazorMonaco/ in index.html)
  • EditorComponent.razor: Fixed CS0618 warning — Global.SetTheme(string) (WASM-only, obsolete) updated to inject IJSRuntime and call Global.SetTheme(JSRuntime, theme)

Build succeeds with 0 errors; 19/21 tests pass (2 pre-existing NuGetPackageGetter failures — issue #19).

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.cdnjs.com
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet /usr/share/dotnet/sdk/10.0.102/MSBuild.dll /noautoresponse /nologo /nodemode:1 /nodeReuse:true /low:false (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Upgrade the app to .NET 10 and confirm compilation Upgrade the app to .NET 10 and confirm compilation Mar 19, 2026
@AlexHedley
Copy link
Copy Markdown
Collaborator

@copilot Update the app see following:

Microsoft.AspNetCore.Components.WebAssembly 10.0.5 and Microsoft.CodeAnalysis.CSharp.Scripting 5.3.0 (Roslyn); sets false (required so assemblies are published as plain PE .dll files readable by MetadataReference.CreateFromImage) and false (preserves Roslyn reflection paths)

Key implementation notes for running Roslyn inside WASM:

Assembly.Location is always empty in a WASM host, so CSharpScript.RunAsync (which internally calls MetadataReference.CreateFromAssemblyInternal) throws a NotSupportedException. The app uses CSharpCompilation.CreateScriptCompilation with explicit MetadataReference.CreateFromImage(bytes) objects instead.
In .NET 10, blazor.boot.json no longer exists — the assembly manifest is now embedded in _framework/dotnet.js between /json-start/ and /json-end/ markers. Additionally, System.Private.CoreLib moved into a separate coreAssembly category (alongside the main assembly category); both must be loaded or Roslyn throws "Predefined type 'System.Object' is not defined" errors. A fallback path for the .NET 8 blazor.boot.json format is retained for backward compatibility.
The emitted IL is loaded with Assembly.Load(bytes) and the script entry point () is invoked via reflection; Console.SetOut redirects standard output to the output panel.

…teScriptCompilation, CoreAssembly, async invoker

Co-authored-by: AlexHedley <1573469+AlexHedley@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Mar 19, 2026

@copilot Update the app see following:

Microsoft.AspNetCore.Components.WebAssembly 10.0.5 and Microsoft.CodeAnalysis.CSharp.Scripting 5.3.0 (Roslyn); sets false...

Implemented in commit 59b01dc. Here's a summary of all changes made:

BlazorInteractive.csproj — added <WasmEnableWebcil>false</WasmEnableWebcil> so assemblies are published as plain PE .dll files (required for MetadataReference.CreateFromImage)

BlazorInteractive.Compilation.csproj — added Microsoft.CodeAnalysis.CSharp.Scripting 5.3.0; <PublishTrimmed>false</PublishTrimmed> was already present

BootstrapResources.cs — added CoreAssembly dict; System.Private.CoreLib moved to this separate category in .NET 10

BootstrapInfo.csAssemblies() now merges both Assembly and CoreAssembly categories so Roslyn can find System.Object

BlazorReferenceFilter.cs — tries _framework/dotnet.js first (extracts JSON between /*json-start*/ and /*json-end*/); falls back to _framework/blazor.boot.json for .NET 8 backward-compatibility

CSharpCompilationBuilder.cs — switched to CSharpCompilation.CreateScriptCompilation (avoids Assembly.Location being empty in WASM)

CSharpCompiler.cs — parses source with SourceCodeKind.Script

IAssemblyInvoker.cs + AssemblyInvoker.cs — async Task<string?> InvokeAsync(Assembly) that locates the Roslyn-generated <Factory> entry point via reflection and awaits it; Console.SetOut redirects output to the panel

Index.razor — removed the class/namespace wrapper (script compilation handles top-level statements directly); updated to await AssemblyInvoker.InvokeAsync

Build: 0 errors. Tests: 19/21 pass (2 pre-existing NuGetPackageGetter — issue #19).

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.

.NET 10

2 participants