Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@
<GrpcNetClientVersion>2.64.0</GrpcNetClientVersion>
<GrpcToolsVersion>2.64.0</GrpcToolsVersion>
<MessagePackVersion>2.5.187</MessagePackVersion>
<!-- Extensions packages for Blazor WASM Service Defaults -->
<MicrosoftExtensionsHttpResilienceVersion>10.0.0</MicrosoftExtensionsHttpResilienceVersion>

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.

What's the plan for keeping these updated? We already have a subscription from dotnet/extensions that currently gives us the 10.4.x versions of packages (see

<!-- dotnet-extensions dependencies -->
<MicrosoftExtensionsCachingHybridPackageVersion>10.4.1</MicrosoftExtensionsCachingHybridPackageVersion>
<MicrosoftExtensionsDiagnosticsTestingPackageVersion>10.4.1</MicrosoftExtensionsDiagnosticsTestingPackageVersion>
<MicrosoftExtensionsTimeProviderTestingPackageVersion>10.4.1</MicrosoftExtensionsTimeProviderTestingPackageVersion>
)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fair question. For GA, the OTel packages should come from the dotnet/extensions subscription (which already provides 10.4.x versions). The nightly MyGet feed packages used during prototyping need to be replaced with the subscription-managed versions once the async WASM support lands in the official packages.

Short-term: these manual version pins are needed while the template uses custom exporters. Once we switch to standard AddOtlpExporter() (which relies on upstream OTel SDK fixes), the versions should be managed by the existing dotnet/extensions subscription.

<MicrosoftExtensionsServiceDiscoveryVersion>10.0.0</MicrosoftExtensionsServiceDiscoveryVersion>
<MicrosoftIdentityWebVersion>3.14.1</MicrosoftIdentityWebVersion>
<MicrosoftIdentityWebGraphServiceClientVersion>3.14.1</MicrosoftIdentityWebGraphServiceClientVersion>
<MicrosoftIdentityWebUIVersion>3.14.1</MicrosoftIdentityWebUIVersion>
Expand All @@ -161,6 +164,11 @@
<NewtonsoftJsonBsonVersion>1.0.2</NewtonsoftJsonBsonVersion>
<NewtonsoftJsonVersion>13.0.3</NewtonsoftJsonVersion>
<NSwagApiDescriptionClientVersion>13.0.4</NSwagApiDescriptionClientVersion>
<!-- OpenTelemetry packages for Blazor WASM Service Defaults -->
<OpenTelemetryExporterOpenTelemetryProtocolVersion>1.10.0</OpenTelemetryExporterOpenTelemetryProtocolVersion>
<OpenTelemetryExtensionsHostingVersion>1.10.0</OpenTelemetryExtensionsHostingVersion>
<OpenTelemetryInstrumentationHttpVersion>1.10.0</OpenTelemetryInstrumentationHttpVersion>
<OpenTelemetryInstrumentationRuntimeVersion>1.10.0</OpenTelemetryInstrumentationRuntimeVersion>
<PhotinoNETVersion>2.5.2</PhotinoNETVersion>
<MicrosoftPlaywrightVersion>1.58.0</MicrosoftPlaywrightVersion>
<PollyExtensionsHttpVersion>3.0.0</PollyExtensionsHttpVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.AspNetCore.Components;

/// <summary>
/// Configuration that flows from the server to the Blazor client in the browser
/// via a DOM comment. Only serializable options; callbacks stay with JS initializers.
/// </summary>
public sealed class BrowserConfiguration
{
/// <summary>
/// The log level for the Blazor JS runtime. Applies to all render modes.
/// Maps to <c>WebStartOptions.logLevel</c>.
/// </summary>
public int? LogLevel { get; set; }

/// <summary>WebAssembly-specific options.</summary>
public WebAssemblyBrowserOptions WebAssembly { get; set; } = new();

/// <summary>Server/Circuit-specific options.</summary>
public ServerBrowserOptions Server { get; set; } = new();

/// <summary>SSR-specific options.</summary>
public SsrBrowserOptions Ssr { get; set; } = new();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.AspNetCore.Components;

/// <summary>
/// Serializable subset of <c>CircuitStartOptions</c>.
/// Non-serializable options (<c>configureSignalR</c>, <c>reconnectionHandler</c>,
/// <c>circuitHandlers</c>) must use <c>Blazor.start()</c> or JS initializers.
/// </summary>
public sealed class ServerBrowserOptions
{
/// <summary>
/// Maximum reconnection attempts before giving up.
/// Maps to <c>CircuitStartOptions.reconnectionOptions.maxRetries</c>.
/// </summary>
public int? ReconnectionMaxRetries { get; set; }

/// <summary>
/// Base interval in milliseconds between reconnection attempts (scalar form).
/// The function form <c>(retryCount, currentMs) => number</c> requires JS.
/// Maps to <c>CircuitStartOptions.reconnectionOptions.retryIntervalMilliseconds</c>.
/// </summary>
public int? ReconnectionRetryIntervalMilliseconds { get; set; }

/// <summary>
/// CSS ID of the reconnection dialog element.
/// Maps to <c>CircuitStartOptions.reconnectionOptions.dialogId</c>.
/// </summary>
public string? ReconnectionDialogId { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.AspNetCore.Components;

/// <summary>
/// Serializable subset of <c>SsrStartOptions</c>.
/// </summary>
public sealed class SsrBrowserOptions
{
/// <summary>
/// When true, disables DOM preservation during enhanced navigation.
/// Maps to <c>SsrStartOptions.disableDomPreservation</c>.
/// </summary>
public bool? DisableDomPreservation { get; set; }

/// <summary>
/// Timeout in milliseconds before an inactive circuit is disposed.
/// Maps to <c>SsrStartOptions.circuitInactivityTimeoutMs</c>.
/// </summary>
public int? CircuitInactivityTimeoutMs { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.AspNetCore.Components;

/// <summary>
/// Serializable subset of <c>WebAssemblyStartOptions</c>.
/// Non-serializable options (<c>loadBootResource</c>, <c>configureRuntime</c>,
/// <c>initializers</c>) must use <c>Blazor.start()</c> or JS initializers.
/// </summary>
public sealed class WebAssemblyBrowserOptions
{
/// <summary>
/// Hosting environment name (e.g., "Development", "Production").
/// Maps to <c>WebAssemblyStartOptions.environment</c>.
/// </summary>
public string? EnvironmentName { get; set; }

/// <summary>
/// Application culture in BCP 47 format (e.g., "en-US").
/// Maps to <c>WebAssemblyStartOptions.applicationCulture</c>.
/// </summary>
public string? ApplicationCulture { get; set; }

/// <summary>
/// Environment variables for the .NET WebAssembly runtime.
/// Use for OTEL endpoints, service URLs, etc.
/// </summary>
public Dictionary<string, string> EnvironmentVariables { get; set; } = new();
}
32 changes: 32 additions & 0 deletions src/Components/Components/src/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,35 @@ Microsoft.AspNetCore.Components.IComponentPropertyActivator.GetActivator(System.
*REMOVED*Microsoft.AspNetCore.Components.ResourceAsset.ResourceAsset(string! url, System.Collections.Generic.IReadOnlyList<Microsoft.AspNetCore.Components.ResourceAssetProperty!>? properties) -> void
*REMOVED*Microsoft.AspNetCore.Components.Routing.Router.PreferExactMatches.get -> bool
*REMOVED*Microsoft.AspNetCore.Components.Routing.Router.PreferExactMatches.set -> void
Microsoft.AspNetCore.Components.BrowserConfiguration
Microsoft.AspNetCore.Components.BrowserConfiguration.BrowserConfiguration() -> void
Microsoft.AspNetCore.Components.BrowserConfiguration.LogLevel.get -> int?
Microsoft.AspNetCore.Components.BrowserConfiguration.LogLevel.set -> void
Microsoft.AspNetCore.Components.BrowserConfiguration.Server.get -> Microsoft.AspNetCore.Components.ServerBrowserOptions!
Microsoft.AspNetCore.Components.BrowserConfiguration.Server.set -> void
Microsoft.AspNetCore.Components.BrowserConfiguration.Ssr.get -> Microsoft.AspNetCore.Components.SsrBrowserOptions!
Microsoft.AspNetCore.Components.BrowserConfiguration.Ssr.set -> void
Microsoft.AspNetCore.Components.BrowserConfiguration.WebAssembly.get -> Microsoft.AspNetCore.Components.WebAssemblyBrowserOptions!
Microsoft.AspNetCore.Components.BrowserConfiguration.WebAssembly.set -> void
Microsoft.AspNetCore.Components.ServerBrowserOptions
Microsoft.AspNetCore.Components.ServerBrowserOptions.ServerBrowserOptions() -> void
Microsoft.AspNetCore.Components.ServerBrowserOptions.ReconnectionDialogId.get -> string?
Microsoft.AspNetCore.Components.ServerBrowserOptions.ReconnectionDialogId.set -> void
Microsoft.AspNetCore.Components.ServerBrowserOptions.ReconnectionMaxRetries.get -> int?
Microsoft.AspNetCore.Components.ServerBrowserOptions.ReconnectionMaxRetries.set -> void
Microsoft.AspNetCore.Components.ServerBrowserOptions.ReconnectionRetryIntervalMilliseconds.get -> int?
Microsoft.AspNetCore.Components.ServerBrowserOptions.ReconnectionRetryIntervalMilliseconds.set -> void
Microsoft.AspNetCore.Components.SsrBrowserOptions
Microsoft.AspNetCore.Components.SsrBrowserOptions.SsrBrowserOptions() -> void
Microsoft.AspNetCore.Components.SsrBrowserOptions.CircuitInactivityTimeoutMs.get -> int?
Microsoft.AspNetCore.Components.SsrBrowserOptions.CircuitInactivityTimeoutMs.set -> void
Microsoft.AspNetCore.Components.SsrBrowserOptions.DisableDomPreservation.get -> bool?
Microsoft.AspNetCore.Components.SsrBrowserOptions.DisableDomPreservation.set -> void
Microsoft.AspNetCore.Components.WebAssemblyBrowserOptions
Microsoft.AspNetCore.Components.WebAssemblyBrowserOptions.WebAssemblyBrowserOptions() -> void
Microsoft.AspNetCore.Components.WebAssemblyBrowserOptions.ApplicationCulture.get -> string?
Microsoft.AspNetCore.Components.WebAssemblyBrowserOptions.ApplicationCulture.set -> void
Microsoft.AspNetCore.Components.WebAssemblyBrowserOptions.EnvironmentName.get -> string?
Microsoft.AspNetCore.Components.WebAssemblyBrowserOptions.EnvironmentName.set -> void
Microsoft.AspNetCore.Components.WebAssemblyBrowserOptions.EnvironmentVariables.get -> System.Collections.Generic.Dictionary<string!, string!>!
Microsoft.AspNetCore.Components.WebAssemblyBrowserOptions.EnvironmentVariables.set -> void
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.AspNetCore.Components;

namespace Microsoft.AspNetCore.Http;

/// <summary>
/// Extension methods on <see cref="HttpContext"/> for accessing <see cref="BrowserConfiguration"/>.
/// </summary>
public static class BrowserConfigurationHttpContextExtensions
{
private static readonly object Key = new();

/// <summary>
/// Gets the <see cref="BrowserConfiguration"/> for the current request.
/// If not already set, seeds from endpoint metadata or creates a new instance.
/// </summary>
/// <param name="context">The <see cref="HttpContext"/>.</param>
/// <returns>The <see cref="BrowserConfiguration"/> for the current request.</returns>
public static BrowserConfiguration GetBrowserConfiguration(this HttpContext context)
{
if (!context.Items.TryGetValue(Key, out var result))
{
// Seed from endpoint metadata if available
var metadataConfig = context.GetEndpoint()?.Metadata.GetMetadata<BrowserConfiguration>();
var config = metadataConfig ?? new BrowserConfiguration();
context.Items[Key] = config;
return config;
}

return (BrowserConfiguration)result!;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.AspNetCore.Http;

namespace Microsoft.AspNetCore.Components;

/// <summary>
/// A component that configures the Blazor browser runtime by merging
/// configuration into the <see cref="BrowserConfiguration"/> on the current
/// <see cref="HttpContext"/>. The merged configuration is emitted as
/// a <c>&lt;!--Blazor-Configuration:{...}--&gt;</c> DOM comment by the renderer.
/// </summary>
public sealed class ConfigureBrowser : IComponent
{
private RenderHandle _renderHandle;

/// <summary>
/// Gets or sets the <see cref="BrowserConfiguration"/> to merge.
/// </summary>
[Parameter, EditorRequired]
public BrowserConfiguration Configuration { get; set; } = default!;

/// <summary>
/// Gets or sets the <see cref="HttpContext"/> for the current request.
/// </summary>
[CascadingParameter]
public HttpContext? HttpContext { get; set; }

void IComponent.Attach(RenderHandle renderHandle)
{
_renderHandle = renderHandle;
}

Task IComponent.SetParametersAsync(ParameterView parameters)
{
parameters.SetParameterProperties(this);

if (HttpContext is not null)
{
var existing = HttpContext.GetBrowserConfiguration();
MergeInto(existing, Configuration);
}

return Task.CompletedTask;
}

internal static void MergeInto(BrowserConfiguration target, BrowserConfiguration source)
{
target.LogLevel = source.LogLevel ?? target.LogLevel;

// WebAssembly
target.WebAssembly.EnvironmentName = source.WebAssembly.EnvironmentName ?? target.WebAssembly.EnvironmentName;
target.WebAssembly.ApplicationCulture = source.WebAssembly.ApplicationCulture ?? target.WebAssembly.ApplicationCulture;
foreach (var kvp in source.WebAssembly.EnvironmentVariables)
{
target.WebAssembly.EnvironmentVariables[kvp.Key] = kvp.Value;
}

// Server
target.Server.ReconnectionMaxRetries = source.Server.ReconnectionMaxRetries ?? target.Server.ReconnectionMaxRetries;
target.Server.ReconnectionRetryIntervalMilliseconds = source.Server.ReconnectionRetryIntervalMilliseconds ?? target.Server.ReconnectionRetryIntervalMilliseconds;
target.Server.ReconnectionDialogId = source.Server.ReconnectionDialogId ?? target.Server.ReconnectionDialogId;

// SSR
target.Ssr.DisableDomPreservation = source.Ssr.DisableDomPreservation ?? target.Ssr.DisableDomPreservation;
target.Ssr.CircuitInactivityTimeoutMs = source.Ssr.CircuitInactivityTimeoutMs ?? target.Ssr.CircuitInactivityTimeoutMs;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,29 @@ public static RazorComponentsEndpointConventionBuilder WithStaticAssets(

return builder;
}

/// <summary>
/// Configures a <see cref="BrowserConfiguration"/> that will be emitted as a DOM comment
/// to the browser for all Razor component endpoints.
/// </summary>
/// <param name="builder">The <see cref="RazorComponentsEndpointConventionBuilder"/>.</param>
/// <param name="configure">An action to configure the <see cref="BrowserConfiguration"/>.</param>
/// <returns>The <see cref="RazorComponentsEndpointConventionBuilder"/>.</returns>
public static RazorComponentsEndpointConventionBuilder WithBrowserConfiguration(
this RazorComponentsEndpointConventionBuilder builder,
Action<BrowserConfiguration> configure)
{
ArgumentNullException.ThrowIfNull(builder);
ArgumentNullException.ThrowIfNull(configure);

var config = new BrowserConfiguration();
configure(config);

builder.Add(endpointBuilder =>
{
endpointBuilder.Metadata.Add(config);
});

return builder;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public static IRazorComponentsBuilder AddRazorComponents(this IServiceCollection
services.AddSupplyValueFromQueryProvider();
services.AddSupplyValueFromPersistentComponentStateProvider();
services.TryAddCascadingValue(sp => sp.GetRequiredService<EndpointHtmlRenderer>().HttpContext);
services.TryAddScoped<WebAssemblySettingsEmitter>();
services.TryAddScoped<ResourcePreloadService>();
services.AddTempData();
Comment on lines 72 to 76

Copilot AI Mar 29, 2026

Copy link

Choose a reason for hiding this comment

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

WebAssemblySettingsEmitter is no longer registered and its output is no longer emitted by the renderer, but the type still exists in the codebase and appears unused. After removing this service registration, consider deleting the unused emitter type (and updating any remaining tests/regexes that referenced the old Blazor-WebAssembly comment) to avoid dead code.

Copilot uses AI. Check for mistakes.

Expand Down

This file was deleted.

9 changes: 9 additions & 0 deletions src/Components/Endpoints/src/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,12 @@ Microsoft.AspNetCore.Components.ITempData.Get(string! key) -> object?
Microsoft.AspNetCore.Components.ITempData.Keep() -> void
Microsoft.AspNetCore.Components.ITempData.Keep(string! key) -> void
Microsoft.AspNetCore.Components.ITempData.Peek(string! key) -> object?
Microsoft.AspNetCore.Components.ConfigureBrowser
Microsoft.AspNetCore.Components.ConfigureBrowser.ConfigureBrowser() -> void
Microsoft.AspNetCore.Components.ConfigureBrowser.Configuration.get -> Microsoft.AspNetCore.Components.BrowserConfiguration!
Microsoft.AspNetCore.Components.ConfigureBrowser.Configuration.set -> void
Microsoft.AspNetCore.Components.ConfigureBrowser.HttpContext.get -> Microsoft.AspNetCore.Http.HttpContext?
Microsoft.AspNetCore.Components.ConfigureBrowser.HttpContext.set -> void
Microsoft.AspNetCore.Http.BrowserConfigurationHttpContextExtensions
static Microsoft.AspNetCore.Http.BrowserConfigurationHttpContextExtensions.GetBrowserConfiguration(this Microsoft.AspNetCore.Http.HttpContext! context) -> Microsoft.AspNetCore.Components.BrowserConfiguration!
static Microsoft.AspNetCore.Builder.RazorComponentsEndpointConventionBuilderExtensions.WithBrowserConfiguration(this Microsoft.AspNetCore.Builder.RazorComponentsEndpointConventionBuilder! builder, System.Action<Microsoft.AspNetCore.Components.BrowserConfiguration!>! configure) -> Microsoft.AspNetCore.Builder.RazorComponentsEndpointConventionBuilder!
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Text.Json.Serialization;

namespace Microsoft.AspNetCore.Components;

[JsonSourceGenerationOptions(
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
[JsonSerializable(typeof(BrowserConfiguration))]
internal partial class BrowserConfigurationJsonContext : JsonSerializerContext
{
}
Loading
Loading