Need a return after the NotFound call in Blazor CRUD Edit components
- Dominant language
- C#
- Stars
- 818
- Forks
- 260
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 10
Description
Request for a code change per the discussion at https://github.com/dotnet/AspNetCore.Docs/issues/37581, specifically per @ilonatommy's request here 👉 https://github.com/dotnet/AspNetCore.Docs/issues/37581#issuecomment-5604203561.
For SQLite adopters, there's an async timing situation that can result in Not Found failing to serve. SQL Server's `SaveChangesAsync` yields, while SQLite's [completes synchronously](https://learn.microsoft.com/en-us/dotnet/standard/data/sqlite/async). With SQLite and the current code in the `Edit` component derived from the template, Not Found no-ops. A `return` statement should be placed after `NotFound` is called in the following `Edit.tt` files for .NET 10 and 11 releases ...
* https://github.com/dotnet/Scaffolding/blob/e68176578a1fc1bf6a3dd966e95176f1f3a25dd3/src/dotnet-scaffolding/dotnet-scaffold/AspNet/Templates/net10.0/BlazorCrud/Edit.tt#L113
* https://github.com/dotnet/Scaffolding/blob/e68176578a1fc1bf6a3dd966e95176f1f3a25dd3/src/dotnet-scaffolding/dotnet-scaffold/AspNet/Templates/net11.0/BlazorCrud/Edit.tt#L113
* https://github.com/dotnet/Scaffolding/blob/e68176578a1fc1bf6a3dd966e95176f1f3a25dd3/src/Scaffolding/VS.Web.CG.Mvc/Templates/Blazor/Edit.tt#L111
What I'm going to do on the Blazor side is ...
* Update the Blazor sample app (only .NET 10 at this time b/c we don't have the .NET 11 version up yet) to include the `return` statement.
* Provide temporary guidance in the Movie dB tutorial (.NET 10 or later) to SQLite adopters to add the `return` statement after scaffolding. I'll track with a follow-up docs issue to keep an 👁️ on this issue to version-out the instruction when this is resolved and the updated scaffolder goes public.
* Cover this scenario in our [Not Found coverage](https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/navigation?view=aspnetcore-10.0#not-found-responses), along with some unrelated updates. We'll keep permanent coverage there because devs will want to understand why `return` is being called.
Contributor guide
Research direction
Start with the three named Blazor Edit.tt templates under the net10.0, net11.0, and VS.Web.CG.Mvc template directories, focusing on the NotFound call around the referenced lines. Compare the generated Edit component behavior for SQLite timing, and consider the work done when each template places a return after NotFound.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, sqlite
- Domain
- tooling, web-dev
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100