docs: add culture management migration warnings for Server/Auto

Prepare for Blazor Server/Auto migration by documenting current
WASM-specific culture initialization approach and providing
detailed migration checklist in COPILOT_CONTEXT.md.
This commit is contained in:
2026-06-18 12:50:45 +02:00
parent 45018d04b1
commit 6fe99d0cd0
2 changed files with 104 additions and 21 deletions

View File

@@ -50,7 +50,25 @@ ReportStorageWebExtension.RegisterExtensionGlobal(new InMemoryReportStorageWebEx
var host = builder.Build();
// Initialize culture BEFORE running the app
// ⚠️ IMPORTANT: BLAZOR WASM-SPECIFIC CULTURE INITIALIZATION
// This approach sets DefaultThreadCurrentCulture globally, which is SAFE for WebAssembly
// because each user runs their own isolated app instance in their browser.
//
// ⚠️ TODO: REMOVE/REFACTOR WHEN MIGRATING TO BLAZOR SERVER/AUTO
// In Server/Auto render modes, this is DANGEROUS because:
// - Server runs a single shared instance for all users
// - Setting global culture affects ALL connected users simultaneously
// - Race conditions and culture conflicts will occur
//
// Migration Guide:
// - Option 1: Use RequestLocalizationMiddleware for per-request culture
// - Option 2: Use CascadingParameter with per-circuit culture state
// - See: https://learn.microsoft.com/aspnet/core/blazor/globalization-localization
//
// Related files to update on migration:
// - LanguageSelector.razor (remove manual culture setting)
// - App.razor (may need CascadingValue for culture)
// - Startup/Program.cs (add middleware)
var cultureService = host.Services.GetRequiredService<CultureService>();
var culture = await cultureService.InitializeCultureAsync();
CultureInfo.DefaultThreadCurrentCulture = culture;