-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make RenderTreeBuilder.AddComponentRenderMode's renderMode parameter nullable #51170
Comments
Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:
|
I'm suddenly getting the error while building RC1 Blazor. Without changing anything since the day before.
|
API Review Notes:
Without any further feedback, I updated #51134 to have API Approved! namespace Microsoft.AspNetCore.Components.Rendering;
public sealed class RenderTreeBuilder : IDisposable
{
- public void AddComponentRenderMode(IComponentRenderMode renderMode);
+ public void AddComponentRenderMode(IComponentRenderMode? renderMode);
} |
## Description This PR addresses a large amount of feedback from #50722 which was merged before they could all be addressed to unblock Accessibility Testing effort. The primary impacts are: #### Runtime changes - Public API change to make `AddComponentRenderMode`'s `renderMode` param nullable to support disabling interactivity on a per-page basis with the help of `@rendermode="null"` (effectively). - **IMPORTANT:** This will need follow up in the Razor Compiler. See dotnet/razor#9343 - API Proposal issue: #51170 - This is a e necessary to support the changes to add global interactivity to Identity components @SteveSandersonMS made in #50920 and have now been included in this PR. - [Add antiforgery token to forms rendered interactively on the server](425bd12) - This bug fix is necessary to make the logout button work without throwing antiforgery errors when it is rendered interactively on the server. #### Template changes - Fix compilation error due to missing `using` in `Program.cs` when the individual auth option is selected with no interactivity. - Add support for global (`--all-interactive`) instead of just per-page interactivity to the new Identity components. - Fix "Apply Migrations" link on the `DatabaseErrorPage` by calling `UseMigrationsEndPoint()` when necessary. - Add support for non-root base paths to the new Identity components. - Improve folder layout by putting most of the additional auth and Identity related files in the same /Account folder. - Use the new `IEmailSender<ApplicationUser>` API instead of `IEmailSender` for easier customization of emails. - Remove usage of `IHttpContextAccessor` from the template because that is generally regarded as bad practice due to the unnecessary reliance on `AsyncLocal`. - Remove underscore (`_`) from private field names. - Reduce usage of `null!` and `default!`. - Use normal `<button>` for logout link in nav bar rather than `<a onclick="document.getElementById('logout-form').submit();">`, and remove separate `LogoutForm.razor`. ## Customer Impact This fixes several bugs in the Blazor project template when choosing the individual auth option and makes several runtime fixes that will be beneficial to any global interactive Blazor application that needs to include some components that must always be statically rendered. ## Regression? - [ ] Yes - [x] No ## Risk - [ ] High - [ ] Medium - [x] Low Obviously, we would rather not make such a large change after RC2. Particularly when it's a change that touches public API. Fortunately, the runtime changes are very small, and only to parts of the runtime that were last updated in RC2 (see #50181 and #50946). The vast majority of the changes in the PR only affect the Blazor project template when the non-default individual auth option is selected. This was merged very late in RC2 (#50722) with the expectation that we would make major changes prior to GA. ## Verification - [x] Manual (required) - [x] Automated ## Packaging changes reviewed? - [ ] Yes - [ ] No - [x] N/A
Background and Motivation
To support disabling interactivity on a per-page basis with the help of
@rendermode="null"
for use in our project templates when generating a Blazor app with individual auth and global interactivity. See #51134.Proposed API
Usage Examples
App.razor
Alternative Designs
We could add a new
RenderMode.StaticServer
to mean the same thing thatnull
does with this proposal.We could also look at other public API that accept a non-nullable render mode like
RenderModeAttribute
:This could be useful for forcing a component to only render statically.
Risks
It's risky making API changes after RC2 because that means we have no opportunity to change the API again based on customer feedback. I think this risk is minimized because it's only a change to the nullability annotation and it makes it more relaxed.
Perhaps the bigger risk is that it locks us into
null
representing a non-interactive renter mode. This is already the case internally, but that could be confusing if we wanted to add something likeRenderMode.StaticServer
in the future to represent the same thing. At least that could still work though.The text was updated successfully, but these errors were encountered: