Comments (13)
Unfortunately, I don't think we ever formalized our Blazor style guide, but in product code (templates, scaffolding, etc) I think we generally only prefix with @
when required. I wouldn't jump to update the docs to do this just yet though.
from scaffolding.
In this file ...
Shouldn't ...
public @Model.DbContextTypeName (DbContextOptions<@Model.DbContextTypeName> options)
... be ...
public @(Model.DbContextTypeName)(DbContextOptions<@Model.DbContextTypeName> options)
... because I see a stray space in the code ...
public BlazorWebAppMoviesContext (DbContextOptions<BlazorWebAppMoviesContext> options)
from scaffolding.
More NITs 😈 ...
-
Remove the blank line at https://github.com/dotnet/Scaffolding/blob/main/src/Scaffolding/VS.Web.CG.Mvc/Templates/Blazor/Create.tt#L62.
-
Add an explicit
private
access modifier to the following lines to match our Blazor conventions (purple NOTE box) ...- https://github.com/dotnet/Scaffolding/blob/main/src/Scaffolding/VS.Web.CG.Mvc/Templates/Blazor/Details.tt#L60
- https://github.com/dotnet/Scaffolding/blob/main/src/Scaffolding/VS.Web.CG.Mvc/Templates/Blazor/Delete.tt#L62
- https://github.com/dotnet/Scaffolding/blob/main/src/Scaffolding/VS.Web.CG.Mvc/Templates/Blazor/Edit.tt#L116
-
Throughout the project, including in
Program.cs
, theusing
/@using
statements/directives are out of order. See 👉 https://learn.microsoft.com/en-us/aspnet/core/blazor/components/?view=aspnetcore-8.0#razor-syntax for the docs conventions, which I hope we can match to avoid an obvious inconsistency between code and docs.
from scaffolding.
In the file ...
... the model isn't lowercased to match what's done for the other components of the set ...
- @page "/<#= pluralModel #>/edit"
+ @page "/<#= pluralModelLowerInv #>/edit"
Because of it, the path comes out (for example using a movies database example) ...
@page "/Movies/edit"
... instead of the expected ...
@page "/movies/edit"
from scaffolding.
The following cross-links will need to be removed because TryUpdateModelAsync
, which is a focus of the cross-linked content, is Mvc.ControllerBase
/RazorPages.PageBase
API of MVC/RP and not available for Razor components to use.
- https://github.com/dotnet/Scaffolding/blob/main/src/Scaffolding/VS.Web.CG.Mvc/Templates/Blazor/Create.tt#L66
- https://github.com/dotnet/Scaffolding/blob/main/src/Scaffolding/VS.Web.CG.Mvc/Templates/Blazor/Edit.tt#L91-L92
- https://github.com/dotnet/Scaffolding/blob/main/src/Scaffolding/VS.Web.CG.Mvc/Templates/Blazor/Create.cs#L99-L100
- https://github.com/dotnet/Scaffolding/blob/main/src/Scaffolding/VS.Web.CG.Mvc/Templates/Blazor/Edit.cs#L134-L135
WRT documentation coverage: The Blazor Web App tutorial (in progress) will touch on overposting with a short section, and I think we're going to have a special Blazor static SSR form overposting section in our Blazor forms article coverage. If so, I'll open a follow-up issue on this repo to get a new link placed that points to the new coverage.
UPDATE
Opened ...
Add Blazor forms overposting coverage
dotnet/AspNetCore.Docs#32733
... to place Blazor-specific overposting coverage. After coverage goes live, I'll open a new scaffolder repo issue to get the Blazor cross-links into the Blazor bits here and remove the main doc set cross-link. The main doc set coverage will be linked via the Blazor coverage, so devs will still be able to reach it for more info.
from scaffolding.
Not sure @danroth27 on this one: I thought you said that you were aligning the PU and doc conventions. I see in the scaffolded code ...
<QuickGrid Class="table" Items="DB.Movie">
... but I expected ...
<QuickGrid Class="table" Items="@DB.Movie">
... to match the doc convention, which always calls for @
to avoid ambiguity with string literals for component param values.
However, I also recall a convo where it was said that @
would only prefix when required. I probably said at the time that to make the docs adopt that convention that it's a big job. It's been the convention in docs going back to Blazor ancient times 👴 ... worked out with Ryan and/or Pranav IIRC 🤔, and I don't have an open issue or work item on the docs side to change the convention (yet 😄).
from scaffolding.
There are also extra spaces in the Razor markup files of the CRUD components.
from scaffolding.
Missing private
access modifier from the Edit
component's {MODEL NAME}Exists
method, which is explicitly stated for doc coverage by convention ...
- bool <#= modelName #>Exists(<#= primaryKeyShortTypeName #> <#= primaryKeyNameLowerInv #>)
+ private bool <#= modelName #>Exists(<#= primaryKeyShortTypeName #> <#= primaryKeyNameLowerInv #>)
from scaffolding.
I'm not sure where this is located (probably over in the main repo actually), but there isn't a return on the last line of the appsettings.json
file ...
I'll go look now and see if this is in the project template over there. BRB ....................
The serviceDependencies.json
file has the same problem ...
... and this one ...
Those are the only ones. Every other file is fine.
I'm not sure where those are located, here or back on the main repo. I'll leave this comment here in case the PU engineer wants to hunt them down and put in a fix for them.
from scaffolding.
Related Issues (20)
- If Program.Main calls extension methods, dotnet aspnet-codegenerator -dc fails with "Could not get the reflection type for DbContext" HOT 4
- Can't get CRUD scaffolding to work after running Reverse Engineer from EF Core Power Tools, throws breaking error HOT 2
- Input select not being generated from Enum HOT 1
- Input Check styling HOT 1
- Input Text Accessibility HOT 1
- List Grid & Updating data
- Update the Blazor CRUD scaffolder to use IDbContextFactory instead of injecting the DbContext directly in to components HOT 1
- Scaffolding exceptions for Blazor Web App HOT 8
- Question: How can one roll their own scaffolders based on this tooling?
- Latest 6.* and 7.* versions of Microsoft.VisualStudio.Web.CodeGeneration.Design result in vulnerable version of NuGet.Packaging being installed CVE-2024-0057. HOT 1
- Microsoft Identity 8.0.2 HOT 2
- Update the Blazor Identity scaffolder to exclude scaffolded pages from interactive routing when targeting .NET 9
- Update Blazor Identity scaffolder to use built-in AuthenticationStateProviders once available
- API Scaffolding Fails for ASP.Net Core Api Controller
- Make all projects nullable friendly
- Converge `Microsoft.DotNet.Scaffolding.Shared` and `Microsoft.DotNet.Scaffolding.Helpers`
- Identity (not `msidentity`) scaffolding doens't work with `InteractiveServer` render mode on Blazor server
- Lowercase the model path segment for the Edit component of the CRUD set HOT 1
- Scaffolding in Blazor is unaware of (implicit inheritance?)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scaffolding.