Skip to content

Commit 7c79d3b

Browse files
committed
Changed opt-in to opt-out
1 parent 0acb3d9 commit 7c79d3b

File tree

5 files changed

+21
-28
lines changed

5 files changed

+21
-28
lines changed

src/Components/WebAssembly/Server/src/PublicAPI.Shipped.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,3 @@ static Microsoft.AspNetCore.Builder.ComponentsWebAssemblyApplicationBuilderExten
2929
static Microsoft.AspNetCore.Builder.WebAssemblyNetDebugProxyAppBuilderExtensions.UseWebAssemblyDebugging(this Microsoft.AspNetCore.Builder.IApplicationBuilder! app) -> void
3030
static Microsoft.AspNetCore.Builder.WebAssemblyRazorComponentsEndpointConventionBuilderExtensions.AddInteractiveWebAssemblyRenderMode(this Microsoft.AspNetCore.Builder.RazorComponentsEndpointConventionBuilder! builder, System.Action<Microsoft.AspNetCore.Components.WebAssembly.Server.WebAssemblyComponentsEndpointOptions!>? callback = null) -> Microsoft.AspNetCore.Builder.RazorComponentsEndpointConventionBuilder!
3131
static Microsoft.Extensions.DependencyInjection.WebAssemblyRazorComponentsBuilderExtensions.AddAuthenticationStateSerialization(this Microsoft.Extensions.DependencyInjection.IRazorComponentsBuilder! builder, System.Action<Microsoft.AspNetCore.Components.WebAssembly.Server.AuthenticationStateSerializationOptions!>? configure = null) -> Microsoft.Extensions.DependencyInjection.IRazorComponentsBuilder!
32-
static Microsoft.Extensions.DependencyInjection.WebAssemblyRazorComponentsBuilderExtensions.AddInteractiveWebAssemblyComponents(this Microsoft.Extensions.DependencyInjection.IRazorComponentsBuilder! builder) -> Microsoft.Extensions.DependencyInjection.IRazorComponentsBuilder!
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#nullable enable
2-
static Microsoft.Extensions.DependencyInjection.WebAssemblyRazorComponentsBuilderExtensions.EnforceServerCultureOnClient(this Microsoft.Extensions.DependencyInjection.IRazorComponentsBuilder! builder) -> Microsoft.Extensions.DependencyInjection.IRazorComponentsBuilder!
2+
static Microsoft.Extensions.DependencyInjection.WebAssemblyRazorComponentsBuilderExtensions.AddInteractiveWebAssemblyComponents(this Microsoft.Extensions.DependencyInjection.IRazorComponentsBuilder! builder, bool pesistCultureFromServer = true) -> Microsoft.Extensions.DependencyInjection.IRazorComponentsBuilder!

src/Components/WebAssembly/Server/src/WebAssemblyRazorComponentsBuilderExtensions.cs

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,28 @@ public static class WebAssemblyRazorComponentsBuilderExtensions
2222
/// Adds services to support rendering interactive WebAssembly components.
2323
/// </summary>
2424
/// <param name="builder">The <see cref="IRazorComponentsBuilder"/>.</param>
25+
/// <param name="pesistCultureFromServer">If set to <c>true</c>, the culture from the server is persisted and restored on the client.</param>
2526
/// <returns>An <see cref="IRazorComponentsBuilder"/> that can be used to further customize the configuration.</returns>
26-
public static IRazorComponentsBuilder AddInteractiveWebAssemblyComponents(this IRazorComponentsBuilder builder)
27+
public static IRazorComponentsBuilder AddInteractiveWebAssemblyComponents(this IRazorComponentsBuilder builder, bool pesistCultureFromServer = true)
2728
{
2829
ArgumentNullException.ThrowIfNull(builder, nameof(builder));
2930

3031
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<RenderModeEndpointProvider, WebAssemblyEndpointProvider>());
3132
builder.Services.TryAddScoped<LazyAssemblyLoader>();
3233

34+
if (pesistCultureFromServer)
35+
{
36+
builder.Services.TryAddScoped(_ =>
37+
{
38+
var provider = new CultureStateProvider();
39+
provider.CaptureCurrentCulture();
40+
return provider;
41+
});
42+
RegisterPersistentComponentStateServiceCollectionExtensions.AddPersistentServiceRegistration<CultureStateProvider>(
43+
builder.Services,
44+
RenderMode.InteractiveWebAssembly);
45+
}
46+
3347
return builder;
3448
}
3549

@@ -51,25 +65,4 @@ public static IRazorComponentsBuilder AddAuthenticationStateSerialization(this I
5165

5266
return builder;
5367
}
54-
55-
/// <summary>
56-
/// Adds services to enforce Server culture on the Client side.
57-
/// </summary>
58-
/// <param name="builder">The <see cref="IRazorComponentsBuilder"/>.</param>
59-
/// <returns>An <see cref="IRazorComponentsBuilder"/> that can be used to further customize the configuration.</returns>
60-
public static IRazorComponentsBuilder EnforceServerCultureOnClient(this IRazorComponentsBuilder builder)
61-
{
62-
ArgumentNullException.ThrowIfNull(builder);
63-
64-
builder.Services.TryAddScoped(_ =>
65-
{
66-
var provider = new CultureStateProvider();
67-
provider.CaptureCurrentCulture();
68-
return provider;
69-
});
70-
RegisterPersistentComponentStateServiceCollectionExtensions.AddPersistentServiceRegistration<CultureStateProvider>(
71-
builder.Services,
72-
RenderMode.InteractiveWebAssembly);
73-
return builder;
74-
}
7568
}

src/Components/test/testassets/Components.TestServer/RazorComponentEndpointsStartup.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public void ConfigureServices(IServiceCollection services)
4343
.RegisterPersistentService<InteractiveServerService>(RenderMode.InteractiveServer)
4444
.RegisterPersistentService<InteractiveAutoService>(RenderMode.InteractiveAuto)
4545
.RegisterPersistentService<InteractiveWebAssemblyService>(RenderMode.InteractiveWebAssembly)
46-
.AddInteractiveWebAssemblyComponents()
4746
.AddInteractiveServerComponents(options =>
4847
{
4948
if (Configuration.GetValue<bool>("DisableReconnectionCache"))
@@ -61,7 +60,11 @@ public void ConfigureServices(IServiceCollection services)
6160

6261
if (Configuration.GetValue<bool>("EnforceServerCultureOnClient"))
6362
{
64-
razorComponentsBuilder.EnforceServerCultureOnClient();
63+
razorComponentsBuilder.AddInteractiveWebAssemblyComponents();
64+
}
65+
else
66+
{
67+
razorComponentsBuilder.AddInteractiveWebAssemblyComponents(pesistCultureFromServer: false);
6568
}
6669

6770
if (Configuration.GetValue<bool>("UseHybridCache"))

src/Mvc/test/Mvc.FunctionalTests/RazorRuntimeCompilationHostingStartupTest.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public override void Dispose()
4949
public HttpClient Client { get; private set; }
5050

5151
[Fact]
52-
[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/56553")]
5352
public async Task RazorViews_CanBeServedAndUpdatedViaRuntimeCompilation()
5453
{
5554
// Arrange
@@ -87,7 +86,6 @@ public async Task RazorViews_CanBeServedAndUpdatedViaRuntimeCompilation()
8786
}
8887

8988
[Fact]
90-
[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/56553")]
9189
public async Task RazorPages_CanBeServedAndUpdatedViaRuntimeCompilation()
9290
{
9391
// Arrange

0 commit comments

Comments
 (0)