Skip to content

Reshape BrowserConfiguration API per review (BrowserOptions) while preserving the JS wire format - #67337

Merged
javiercn merged 3 commits into
mainfrom
copilot/api-review-browser-configuration
Jun 22, 2026
Merged

Reshape BrowserConfiguration API per review (BrowserOptions) while preserving the JS wire format#67337
javiercn merged 3 commits into
mainfrom
copilot/api-review-browser-configuration

Conversation

CopilotAI commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

API-review feedback on the server-to-client Blazor browser configuration (#66393): rename/reshape the public surface to match ASP.NET Core options conventions, while keeping the serialized <!--Blazor-Configuration:...--> payload aligned with the existing Web.JS consumer.

Description

  • Root model: BrowserConfigurationBrowserOptions. LogLevel is now Microsoft.Extensions.Logging.LogLevel? (JS enum values are identical, 0–6). Server/Ssr/WebAssembly are get-only and pre-initialized to avoid NREs on the common path.
  • InteractiveServerBrowserOptions (was ServerBrowserOptions): ReconnectionRetryIntervalMilliseconds (int?) → ReconnectionRetryInterval (TimeSpan?).
  • SsrBrowserOptions: CircuitInactivityTimeoutMsCircuitInactivityTimeout (TimeSpan?); DisableDomPreservation → positive PreserveDom (bool?).
  • WebAssemblyBrowserOptions: EnvironmentVariables is now a get-only, non-null IDictionary<string, string>.
  • ConfigureBrowser: Configuration parameter → Options.
  • Assembly placement: BrowserOptions and the InteractiveServerBrowserOptions/SsrBrowserOptions/WebAssemblyBrowserOptions types now live in Microsoft.AspNetCore.Components.Endpoints (the public namespace stays Microsoft.AspNetCore.Components), alongside the related ConfigureBrowser component and helpers, since they are written by the ASP.NET Core host during SSR and only read by JS.
  • HttpContext accessor: BrowserConfigurationHttpContextExtensions.GetBrowserConfigurationBrowserOptionsHttpContextExtensions.GetBrowserOptions.
  • Endpoint builder: WithBrowserConfigurationWithBrowserOptions (configureOptions).
  • Wire format: instead of a separate wire model, BrowserOptions is serialized directly with [JsonPropertyName] plus small internal JsonConverters that adapt the idiomatic C# shapes to the JS-expected JSON (TimeSpan → milliseconds, positive PreserveDomdisableDomPreservation, LogLevel → int). JS remains the source of truth and is kept in sync with the .NET bits. No TypeScript changes required.
  • Updated PublicAPI.Unshipped.txt for both assemblies and the E2E test-asset startup.

All types are sealed (as they already were). ConfigureBrowser retains [Parameter, EditorRequired] on Options and [CascadingParameter] on HttpContext.

app.MapRazorComponents<App>().WithBrowserOptions(options =>{options.LogLevel=LogLevel.Warning;options.Server.ReconnectionMaxRetries=10;options.Server.ReconnectionRetryInterval=TimeSpan.FromSeconds(1.5);options.Ssr.PreserveDom=true;options.WebAssembly.EnvironmentVariables["OTEL_ENDPOINT"]="https://...";});

…tions, reshape API, preserve wire format)
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
CopilotAI changed the title [WIP] Review feedback on BrowserConfiguration shape and placementReshape BrowserConfiguration API per review (BrowserOptions) while preserving the JS wire formatJun 21, 2026
CopilotAI requested a review from javiercnJune 21, 2026 09:24

@javiercnjaviercn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot here is some feedback for you to address

Comment threadsrc/Components/Endpoints/src/Rendering/BrowserConfigurationWireModel.cs Outdated
… the model
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
CopilotAI requested a review from javiercnJune 21, 2026 10:08
@javiercn
javiercn marked this pull request as ready for review June 21, 2026 13:44
@javiercn
javiercn requested a review from a team as a code ownerJune 21, 2026 13:44
CopilotAI review requested due to automatic review settings June 21, 2026 13:44

@javiercnjaviercn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. @copilot update the original api review issue so the description reflects the new api shape.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Reshapes the Blazor server-to-browser configuration surface to follow ASP.NET Core “options” conventions (renaming BrowserConfigurationBrowserOptions, adjusting option types), while keeping the serialized <!--Blazor-Configuration:...--> payload compatible with the existing JS consumer.

Changes:

  • Renames/reshapes the public API surface (WithBrowserConfigurationWithBrowserOptions, GetBrowserConfigurationGetBrowserOptions, ConfigureBrowser.Configuration.Options) and updates option types (TimeSpan?, LogLevel?, positive PreserveDom).
  • Serializes BrowserOptions directly using source-generated JsonSerializerContext plus internal converters to preserve the existing JS wire format.
  • Moves/removes the old public types from Components and introduces the new public types in Components.Endpoints (public namespace remains Microsoft.AspNetCore.Components).

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

Show a summary per file
FileDescription
src/Components/test/testassets/Components.TestServer/RazorComponentEndpointsStartup.csUpdates test-asset endpoint setup to use WithBrowserOptions.
src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.Streaming.csSwitches runtime emission to GetBrowserOptions() and BrowserOptionsJsonContext.
src/Components/Endpoints/src/Rendering/BrowserOptionsJsonContext.csRenames/moves the source-gen JSON context to target BrowserOptions.
src/Components/Endpoints/src/PublicAPI.Unshipped.txtUpdates public API tracking for the new/moved types and members.
src/Components/Endpoints/src/Builder/RazorComponentsEndpointConventionBuilderExtensions.csRenames endpoint builder API to WithBrowserOptions(...).
src/Components/Endpoints/src/BrowserConfiguration/WebAssemblyBrowserOptions.csMakes EnvironmentVariables get-only/non-null and changes type to IDictionary<,>.
src/Components/Endpoints/src/BrowserConfiguration/SsrBrowserOptions.csIntroduces SSR options with converters for JS wire compatibility (PreserveDom, TimeSpan).
src/Components/Endpoints/src/BrowserConfiguration/InteractiveServerBrowserOptions.csRenames server options type and switches retry interval to TimeSpan? with ms converter.
src/Components/Endpoints/src/BrowserConfiguration/ConfigureBrowser.csRenames parameter to Options and updates merge behavior for new shapes.
src/Components/Endpoints/src/BrowserConfiguration/BrowserOptionsJsonConverters.csAdds internal converters to adapt idiomatic C# shapes to the existing JS payload format.
src/Components/Endpoints/src/BrowserConfiguration/BrowserOptionsHttpContextExtensions.csRenames HttpContext accessor to GetBrowserOptions().
src/Components/Endpoints/src/BrowserConfiguration/BrowserOptions.csAdds the new root options model with get-only nested option objects.
src/Components/Components/src/PublicAPI.Unshipped.txtRemoves the old API entries from the Components assembly public API tracking.
src/Components/Components/src/BrowserConfiguration/SsrBrowserOptions.csRemoves old SSR options shape from Components.
src/Components/Components/src/BrowserConfiguration/BrowserConfiguration.csRemoves old root configuration model from Components.
Comments suppressed due to low confidence (2)

src/Components/Endpoints/src/Rendering/BrowserOptionsJsonContext.cs:12

  • BrowserOptions is declared in Microsoft.AspNetCore.Components, but this file is in Microsoft.AspNetCore.Components.Endpoints and doesn’t import the parent namespace. As written, [JsonSerializable(typeof(BrowserOptions))] won’t compile because BrowserOptions can’t be resolved from this namespace.
    src/Components/Endpoints/src/BrowserConfiguration/BrowserOptionsHttpContextExtensions.cs:32
  • GetBrowserOptions currently returns the BrowserOptions instance stored in endpoint metadata directly. Since BrowserOptions (and its nested options/dictionaries) are mutable and callers/components merge into it per request, this can cause cross-request state leakage and concurrency issues. Clone into a per-request instance before storing it in HttpContext.Items.

Comment on lines 345 to 348
_browserConfigurationEmitted = true;

var config = _httpContext.GetBrowserConfiguration();
var config = _httpContext.GetBrowserOptions();

@javiercn
javiercn merged commit d5a6efd into mainJun 22, 2026
26 checks passed
@javiercn
javiercn deleted the copilot/api-review-browser-configuration branch June 22, 2026 06:37
@dotnet-milestone-botdotnet-milestone-botBot added this to the 11.0-preview6 milestone Jun 23, 2026
danroth27 added a commit to dotnet/core that referenced this pull request Jul 14, 2026
…eature
WithBrowserOptions flows client-side Blazor.start configuration from the server
in C# (log level, Server reconnection, SSR DOM preservation, WASM environment),
serialized to the client across Server/WebAssembly/Auto render modes. Introduced
in Preview 4 (server-to-browser config via DOM comment) and reshaped in Preview 6
(dotnet/aspnetcore#67337, proposal #66393). Includes the reshape/rename migration
for earlier adopters. Sample build-verified on 11.0.100-preview.6.26359.118.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
rbhanda added a commit to dotnet/core that referenced this pull request Jul 14, 2026
* [release-notes] .NET 11 Preview 6 base metadata
changes.json, features.json, build-metadata.json, and README for the
.NET 11 Preview 6 milestone (VMR base v11.0.0-preview.5.26302.115 ->
head release/11.0.1xx-preview6).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* [release-notes] C# in .NET 11 Preview 6 (#10460)
* [release-notes] C# in .NET 11 Preview 6
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Update release-notes/11.0/preview/preview6/csharp.md
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Bill Wagner <wiwagn@microsoft.com>
* [release-notes] MSBuild in .NET 11 Preview 6 (#10463)
* [release-notes] MSBuild in .NET 11 Preview 6
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Add bug-fix note for architecture-agnostic Runtime=NET task host handshake (dotnet/msbuild#13890)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Remove HTML comments from Preview 6 MSBuild release notes
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Chet Husk <chusk3@gmail.com>
* [release-notes] NuGet in .NET 11 Preview 6 (#10464)
* [release-notes] NuGet in .NET 11 Preview 6
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix STJ feature-flag env var value and remove VS reference
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Chet Husk <chusk3@gmail.com>
* [release-notes] .NET SDK in .NET 11 Preview 6 (#10459)
* [release-notes] .NET SDK in .NET 11 Preview 6
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Clarify NativeAOT CLI updates in preview6/sdk.md
Updated the NativeAOT CLI section to clarify the unification of managed and NativeAOT parsers, and removed filtered content related to internal changes.
* Add live running-tests display to dotnet test notes
Document the in-flight test progress panel (dotnet/sdk#54486) and fix
pre-existing trailing-space lint errors in the NativeAOT section.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Chet Husk <baronfel@users.noreply.github.com>
Co-authored-by: Chet Husk <chusk3@gmail.com>
* [release-notes] Windows Forms in .NET 11 Preview 6 (#10465)
* [release-notes] Windows Forms in .NET 11 Preview 6
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Revise Windows Forms release notes for Preview 6
Updated release notes for .NET 11 Preview 6 to include bug fixes and improvements for various Windows Forms components.
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Klaus Löffelmann <9663150+KlausLoeffelmann@users.noreply.github.com>
* [release-notes] .NET MAUI in .NET 11 Preview 6 (#10467)
* [release-notes] .NET MAUI in .NET 11 Preview 6
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Draft .NET MAUI and friends notes for .NET 11 Preview 6
Combined highlights for .NET MAUI, .NET for Android, and .NET for iOS,
Mac Catalyst, macOS, and tvOS: CollectionView2 on Windows, handler-based
Shell on Android, Compatibility package removal, AOT-safe HybridWebView,
Geolocation minimum-distance filter, a reliability wave, the
AndroidMessageHandler HTTP-contract work, and the Apple platform toolchain
and NSUrlSessionHandler updates.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Add Preview 6 items from MAUI maintainer review
Incorporates jfversluis review feedback on #10467:
- Android MediaPicker result recovery APIs (dotnet/maui#35455)
- HybridWebView Android message-source filtering (dotnet/maui#35717)
- XAML C# expression source generator CS1061 fix (dotnet/maui#35922)
- Testable permissions via IPermissions/Permissions.Current (dotnet/maui#35987)
- XA0149 warning for legacy __AndroidEnvironment__ resources (dotnet/android#11700)
- Skip library proguard.txt with disallowed R8 global options (dotnet/android#11709)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: David Ortinau <david.ortinau@microsoft.com>
* [release-notes] EF Core in .NET 11 Preview 6 (#10462)
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
* [release-notes] F# in .NET 11 Preview 6 (#10461)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* [release-notes] Containers in .NET 11 Preview 6 (#10468)
* [release-notes] Containers in .NET 11 Preview 6
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Update release notes
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Logan Bussell <loganbussell@microsoft.com>
* [release-notes] .NET Libraries in .NET 11 Preview 6 (#10457)
* [release-notes] .NET Libraries in .NET 11 Preview 6
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix async DataAnnotations sample after testing on the Preview 6 SDK
AsyncValidationAttribute is overridden via the protected IsValidAsync
(and IsValid) members, not GetValidationResultAsync (which is the public
method the framework calls and is not virtual). Verified the corrected
sample compiles and runs against the Preview 6 build.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Verify Preview 6 library samples and fix inaccuracies
- Stream adapters: read from the read-only stream via StreamContent/PostAsync instead of copying HttpContent into it
- Cross-lane vectors: replace nonexistent Concat with ConcatLowerLower/LowerUpper/UpperLower/UpperUpper and drop preexisting Shuffle/ShuffleNative
- Async validation: swap the unique-username example for a VAT registry lookup, layer StringLength and RegularExpression sync rules with the async rule, and add a server-side validation note
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Jeff Handley <jeffhandley@users.noreply.github.com>
* [release-notes] ASP.NET Core in .NET 11 Preview 6 (#10456)
* [release-notes] WPF in .NET 11 Preview 6 (#10466)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Apply suggestions from code review
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Throw InvalidOperationException for sync validation of async validator
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Apply late review suggestions from #10456 to the ASP.NET Core notes
- OpenAPI unions: correct the third-party generator claim (ApiExplorer does not
detect unions via JsonTypeInfoKind.Union; Swashbuckle/NSwag don't yet
recognize unions). Per @DeagleGross review on #10456.
- Blazor Virtualize: note that a user scroll during ScrollToIndexAsync wins.
Per @ilonatommy review on #10456.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Add P6 Blazor items to align with docs (dotnet/AspNetCore.Docs#37322)
- CSRF: note that Blazor Web App templates no longer call app.UseAntiforgery().
- Bug fixes/Blazor: Virtualize is now CSP-compliant (#66680); session cookie is
issued before streaming SSR for [SupplyParameterFromSession]/TempData (#66832).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Document 'Configure Blazor client behavior from the server' as a P6 feature
WithBrowserOptions flows client-side Blazor.start configuration from the server
in C# (log level, Server reconnection, SSR DOM preservation, WASM environment),
serialized to the client across Server/WebAssembly/Auto render modes. Introduced
in Preview 4 (server-to-browser config via DOM comment) and reshaped in Preview 6
(dotnet/aspnetcore#67337, proposal #66393). Includes the reshape/rename migration
for earlier adopters. Sample build-verified on 11.0.100-preview.6.26359.118.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Correct Virtualize CSP note: data-blazor-virtualize-reserved-height
Reviewing dotnet/AspNetCore.Docs#37322 surfaced that the attribute is
data-blazor-virtualize-reserved-height (only the server-computed spacer height),
not the generic data-blazor-style. Verified in the P6 source (Virtualize.cs /
Virtualize.ts). @ilonatommy corrected the same wording on the docs PR.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* [release-notes] .NET Runtime in .NET 11 Preview 6 (#10458)
* [release-notes] .NET Runtime in .NET 11 Preview 6
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Enrich Preview 6 runtime notes with additional verified features
Fold verified .NET 11 Preview 6 runtime changes into runtime.md
(JIT improvements, in-process crash logging, NativeAOT interface
dispatch, SIMD lane APIs, and an expanded bug-fix list), and rebuild
the TOC to match the current sections.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ade796bb-8052-4946-b204-a88518267e77
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Rich Lander <2608468+richlander@users.noreply.github.com>
* fix markdown lint in preview6 containers note
Co-authored-by: jongalloway <68539+jongalloway@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Bill Wagner <wiwagn@microsoft.com>
Co-authored-by: Chet Husk <chusk3@gmail.com>
Co-authored-by: Chet Husk <baronfel@users.noreply.github.com>
Co-authored-by: Klaus Löffelmann <9663150+KlausLoeffelmann@users.noreply.github.com>
Co-authored-by: David Ortinau <david.ortinau@microsoft.com>
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Co-authored-by: Logan Bussell <loganbussell@microsoft.com>
Co-authored-by: Jeff Handley <jeffhandley@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Rich Lander <2608468+richlander@users.noreply.github.com>
Co-authored-by: Rahul Bhandari <rbhanda@microsoft.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jongalloway <68539+jongalloway@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@pavelsavara@javiercn