Skip to content

Reshape BrowserOptions server-to-client configuration API per review - #67918

Merged
ilonatommy merged 3 commits into
mainfrom
copilot/api-proposal-browseroptions
Jul 24, 2026
Merged

Reshape BrowserOptions server-to-client configuration API per review#67918
ilonatommy merged 3 commits into
mainfrom
copilot/api-proposal-browseroptions

Conversation

Copilot AI commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Applies the approved API review decisions for the Blazor BrowserOptions surface that flows host configuration to the browser client via the <!--Blazor-Configuration:{...}--> DOM comment. The wire format is preserved through JSON converters/attributes, so no JS changes are required.

Description

  • Render-mode property renames on BrowserOptions (get-only, pre-initialized), with [JsonPropertyName] keeping the existing wire keys:
    • ServerInteractiveServer (server)
    • SsrStaticServer (ssr)
    • WebAssemblyInteractiveWebAssembly (webAssembly)
  • Type renames: SsrBrowserOptionsStaticServerBrowserOptions, WebAssemblyBrowserOptionsInteractiveWebAssemblyBrowserOptions (InteractiveServerBrowserOptions unchanged).
  • Accessor moved off HttpContext: removed BrowserOptionsHttpContextExtensions; GetBrowserOptions is now a static method BrowserOptions.GetBrowserOptions(HttpContext).
  • ConfigureBrowser: the HttpContext cascading parameter is now internal, removing it from the public API while remaining functional.
  • Updated internal consumers (EndpointHtmlRenderer, Server.AutoPause, test server startup, Root.razor) and PublicAPI.Unshipped.txt.
  • Added BrowserOptionsTest covering wire-key preservation, TimeSpan→ms conversion, negated PreserveDomdisableDomPreservation, extension-data flattening, GetBrowserOptions caching/metadata seeding, and MergeInto semantics.
app.MapRazorComponents<App>()
    .WithBrowserOptions(options =>
    {
        options.LogLevel = LogLevel.Warning;
        options.InteractiveServer.ReconnectionMaxRetries = 10;
        options.InteractiveServer.ReconnectionRetryInterval = TimeSpan.FromSeconds(1.5);
        options.StaticServer.PreserveDom = true;
        options.InteractiveWebAssembly.EnvironmentName = "Staging";
        options.InteractiveWebAssembly.EnvironmentVariables["OTEL_ENDPOINT"] = "https://...";
    });

Fixes #66393.

Copilot AI and others added 2 commits July 20, 2026 18:38
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Copilot AI changed the title [WIP] Update API for BrowserOptions configuration Reshape BrowserOptions server-to-client configuration API per review Jul 20, 2026
Copilot AI requested a review from javiercn July 20, 2026 18:42
@javiercn
javiercn marked this pull request as ready for review July 24, 2026 08:13
@javiercn
javiercn requested a review from a team as a code owner July 24, 2026 08:13
Copilot AI review requested due to automatic review settings July 24, 2026 08:13

Copilot AI 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 BrowserOptions server-to-client configuration API (used for the <!--Blazor-Configuration:{...}--> payload) to match the approved API review: renamed render-mode option properties/types while preserving existing wire keys, and moved GetBrowserOptions off HttpContext extensions onto BrowserOptions.

Changes:

  • Renamed BrowserOptions sub-option properties to InteractiveServer, StaticServer, and InteractiveWebAssembly, using [JsonPropertyName] to preserve server, ssr, and webAssembly wire keys.
  • Replaced BrowserOptionsHttpContextExtensions.GetBrowserOptions(HttpContext) with BrowserOptions.GetBrowserOptions(HttpContext) and updated call sites.
  • Updated public API declarations and added tests validating serialization/wire compatibility and option merging/caching behavior.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Components/test/testassets/Components.TestServer/RazorComponentEndpointsStartup.cs Updates test server configuration to use InteractiveWebAssembly property.
src/Components/Server.AutoPause/src/AutoPauseBrowserOptionsExtensions.cs Updates auto-pause option injection to target InteractiveServer extensions.
src/Components/Endpoints/test/BrowserOptionsTest.cs Adds tests for wire-key preservation, converters, extension-data flattening, caching, and merge semantics.
src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.Streaming.cs Switches to BrowserOptions.GetBrowserOptions(HttpContext) and updates WebAssembly defaults to InteractiveWebAssembly.
src/Components/Endpoints/src/PublicAPI.Unshipped.txt Reflects public API renames and removes the HttpContext extension API surface.
src/Components/Endpoints/src/BrowserConfiguration/StaticServerBrowserOptions.cs Renames SsrBrowserOptions to StaticServerBrowserOptions and updates docs.
src/Components/Endpoints/src/BrowserConfiguration/InteractiveWebAssemblyBrowserOptions.cs Renames WebAssemblyBrowserOptions to InteractiveWebAssemblyBrowserOptions.
src/Components/Endpoints/src/BrowserConfiguration/ConfigureBrowser.cs Makes the cascading HttpContext parameter internal and updates merge logic to new property names.
src/Components/Endpoints/src/BrowserConfiguration/BrowserOptionsHttpContextExtensions.cs Removes the HttpContext extension-based accessor.
src/Components/Endpoints/src/BrowserConfiguration/BrowserOptions.cs Introduces BrowserOptions.GetBrowserOptions(HttpContext) and applies JsonPropertyName to preserve existing wire keys.

@ilonatommy
ilonatommy merged commit c635db7 into main Jul 24, 2026
27 checks passed
@ilonatommy
ilonatommy deleted the copilot/api-proposal-browseroptions branch July 24, 2026 14:19
@ilonatommy ilonatommy added the area-blazor Includes: Blazor, Razor Components label Jul 24, 2026
@ilonatommy ilonatommy added this to the 11.0-rc1 milestone Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Includes: Blazor, Razor Components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API Proposal: BrowserOptions for server-to-client configuration

4 participants