Improve Blazor project template#52234
Conversation
|
Hi @halter73. If this is not a tell-mode PR, please make sure to follow the instructions laid out in the servicing process document. |
|
@guardrex Regarding the following from #51084
I don't have a huge preference one way or the other. I think @SteveSandersonMS chose |
|
|
||
| namespace BlazorWeb_CSharp.Client; | ||
|
|
||
| class Program |
There was a problem hiding this comment.
Unlike the server template, this does not have an accessibility modifier. Neither does the Main method. I would have made both the class and public like we do for the server project, but this made the @typeof(Program).Assembly reference in Routes.razor ambiguous.
I could change that to be @typeof(BlazorWeb_CSharp.Program).Assembly instead and make this public. And then only qualify it when you've disabled top level statements.
Does anyone prefer that, or is everyone fine the way it is?
|
@halter73 Can you update Routes.razor as well to remove the unnecessary leading <Router AppAssembly="typeof(Program).Assembly">
<Found Context="routeData">
<RouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)" />
<FocusOnNavigate RouteData="routeData" Selector="h1" />
</Found>
</Router> |
|
@danroth27, we discussed the delta that removing those |
|
@halter73 ... In addition to any template change, I've opened a doc issue to improve additional assemblies coverage at ...
BTW, I don't think that section title is accurate ...
Shouldn't that just state ...
|
@guardrex Yeah, we're trying to standardize on a consistent style here. The style we're going with is to only include the |
|
Hi @halter73. Please make sure you've updated the PR description to use the Shiproom Template. Also, make sure this PR is not marked as a draft and is ready-to-merge. To learn more about how to prepare a servicing PR click here. |
|
@halter73 @javiercn ... Passing note and ❓ before we go here. These definitions are similar WRT locating components ...
Summary ...
Remark ...
Two questions ...
UPDATE: I placed a PR with draft improved language at dotnet/AspNetCore.Docs#31131. |
|
@guardrex I believe you need to specify |
|
@danroth27 ... Thanks. I understand. I'll make further updates shortly and ping for review on the PR. |
|
Mmmmmmmm 🤔 ... Idk ... that doesn't sound like it matches the behavior. HOLD for a sec. I need to research further. I lost a test app. I'll post back in a bit. |
|
Ok ... I think I get it now. I'll make the updates the PR and ping for review. |
|
Hi @halter73. This PR was just approved to be included in the upcoming servicing release. Somebody from the @dotnet/aspnet-build team will get it merged when the branches are open. Until then, please make sure all the CI checks pass and the PR is reviewed. |
# Use consistent code style in Blazor project templates - Removed usage of top-level statements in client project if "Do not use top-level statements" is selected - Removed extra "@" in `@render-mode` values - Always use `typeof(Namespace._Imports).Assembly` instead of `typeof(Counter).Assembly` so the compilation does not break when the sample Counter component is removed, and so the code is more consistent with how it is when no sample content is generated - Added Account/AccessDenied endpoint to individual auth option to match Identity UI razor pages. This is shown when the user is authenticated but unauthorized by default. Fixes #52079 Fixes #52084 Fixes #52167 ## Customer Impact In addition to not using top-level statements when the customer requests that we don't, this improves code style consistency within the Blazor project template and with the Blazor docs. ## Regression? - [ ] Yes - [x] No ## Risk - [ ] High - [ ] Medium - [x] Low These are small stylistic changes to the Blazor project templates. ## Verification - [x] Manual (required) - [ ] Automated ## Packaging changes reviewed? - [ ] Yes - [ ] No - [x] N/A
Use consistent code style in Blazor project templates
@render-modevaluestypeof(Namespace._Imports).Assemblyinstead oftypeof(Counter).Assemblyso the compilation does not break when the sample Counter component is removed, and so the code is more consistent with how it is when no sample content is generatedFixes #52079
Fixes #52084
Fixes #52167
Customer Impact
In addition to not using top-level statements when the customer requests that we don't, this improves code style consistency within the Blazor project template and with the Blazor docs.
Regression?
Risk
These are small stylistic changes to the Blazor project templates.
Verification
Packaging changes reviewed?