.NET Web Worker template update to Blazor Web Worker template#66070
Open
ilonatommy wants to merge 11 commits intodotnet:mainfrom
Open
.NET Web Worker template update to Blazor Web Worker template#66070ilonatommy wants to merge 11 commits intodotnet:mainfrom
ilonatommy wants to merge 11 commits intodotnet:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Cleans up the .NET Web Worker project template output by removing license headers from generated files and simplifying the WebWorkerClient template code comments while adding a void-invocation helper.
Changes:
- Removed .NET Foundation license headers from generated Web Worker template JS/C# files.
- Condensed
WebWorkerClient’s heavy XML documentation into shorter inline comments. - Added
WebWorkerClient.InvokeVoidAsyncand updated theJSDisconnectedExceptioncomment to be WebWorker-appropriate.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/ProjectTemplates/Web.ProjectTemplates/content/WebWorker-CSharp/wwwroot/dotnet-web-worker.js | Removes license header from generated worker bootstrap script. |
| src/ProjectTemplates/Web.ProjectTemplates/content/WebWorker-CSharp/wwwroot/dotnet-web-worker-client.js | Removes license header from generated client-side worker wrapper module. |
| src/ProjectTemplates/Web.ProjectTemplates/content/WebWorker-CSharp/WebWorkerClient.cs | Simplifies template docs, adds InvokeVoidAsync, updates disconnect comment. |
Comments suppressed due to low confidence (1)
src/ProjectTemplates/Web.ProjectTemplates/content/WebWorker-CSharp/WebWorkerClient.cs:33
- The PR description says "Fixes #65937", but this change set appears to address only a subset of the issue items (license header removal, doc/comment cleanup, and adding InvokeVoidAsync). Items like an initialization timeout for worker startup and the parseIfJson behavior are still present. Consider updating the PR description (e.g., remove "Fixes"/mark as partial) or including the remaining fixes before merging so the issue isn’t closed prematurely.
public static async Task<WebWorkerClient> CreateAsync(IJSRuntime jsRuntime)
{
await using var module = await jsRuntime.InvokeAsync<IJSObjectReference>(
"import", "./_content/Company.WebWorker1/dotnet-web-worker-client.js");
…sInterop-like form.
9fe7142 to
efc73fb
Compare
This was referenced Mar 30, 2026
Open
danroth27
requested changes
Apr 1, 2026
Member
danroth27
left a comment
There was a problem hiding this comment.
Looks good! A few comments.
src/ProjectTemplates/Web.ProjectTemplates/content/WebWorker-CSharp/WebWorkerClient.cs
Outdated
Show resolved
Hide resolved
src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWebWorker-CSharp/WebWorkerClient.cs
Show resolved
Hide resolved
...tTemplates/Web.ProjectTemplates/content/WebWorker-CSharp/wwwroot/dotnet-web-worker-client.js
Outdated
Show resolved
Hide resolved
src/ProjectTemplates/Web.ProjectTemplates/content/WebWorker-CSharp/wwwroot/dotnet-web-worker.js
Show resolved
Hide resolved
danroth27
reviewed
Apr 3, 2026
...Templates/Web.ProjectTemplates/content/BlazorWebWorker-CSharp/.template.config/template.json
Outdated
Show resolved
Hide resolved
This was referenced Apr 3, 2026
This was referenced Apr 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Done in efc73fb. See #65937 (comment)
If we do it for
createwe could also do it forinvoke, they have similar level of risk. If user's exported method never resolves, it will also hang forever. We should align both to use cancellation tokens and timeouts.Done in 2119dd8.
Done in 4d00bab. See: #65937 (comment).
Done in 036d9cf.
After offline discussion we decided to make the supported template more Blazor-focused, with default support of web worker running the C# code located in web worker project (not only in the host project). This update contains:
dotnet new blazorwebworker.assemblyNameparameter to initialization method that is populated by default with web worker's assembly name inWebWorkerClient. In JS we load exports from both: host project and from web worker project.WorkerMethods.cs. It's a boilerplate for removal but blazor web template also ships such an easy-to-remove files likeCounter.razor. That file documents how to call exported method from host project and shows the place where to embed other methods for the web worker.Fixes #65937