Skip to content

Localization: Avoid satellite assembly probing under non-English cultures - #13466

Merged
danielchalmers merged 3 commits into
MudBlazor:devfrom
danielchalmers:claude/mudblazor-13461-e9b922
Jul 13, 2026
Merged

Localization: Avoid satellite assembly probing under non-English cultures#13466
danielchalmers merged 3 commits into
MudBlazor:devfrom
danielchalmers:claude/mudblazor-13461-e9b922

Conversation

@danielchalmers

@danielchalmers danielchalmers commented Jul 13, 2026

Copy link
Copy Markdown
Member

The built-in English resources are looked up through a ResourceManagerStringLocalizer that resolves under the ambient CurrentUICulture. MudBlazor ships only the neutral LanguageResource.resx (no satellite assemblies), so a non-English culture makes ResourceManager walk the fallback chain (sv-SEsv → invariant) and probe for a missing MudBlazor.resources satellite, throwing a caught first-chance FileNotFoundException on each fresh lookup.

  • Mostly invisible at runtime, but crippling under the Visual Studio managed Blazor WebAssembly debugger: every caught exception stalls the debugger agent, so a small MudDataGrid renders in ~14-15s instead of ~100ms.
  • The interceptor/localizer are registered transient and injected per component, so each localized component builds a fresh ResourceManager and re-probes; the cost scales with the number of localized components.
  • Affects any non-English culture, including en-US (which probes en-US and en).

Fixes #13461 by wrapping the built-in localizer in DefaultLanguageResourceReader so its lookups resolve under InvariantCulture, which reads the embedded neutral resource with no satellite probing.

  • Only CurrentUICulture is pinned, synchronously with no await gap, so CurrentCulture still formats arguments in the user's culture.
  • Applied only to the built-in English resource; a custom IStringLocalizer (other constructor) and a custom MudLocalizer keep the app's current UI culture.

…ures

The built-in English resources are looked up under the ambient CurrentUICulture.
MudBlazor ships no satellite assemblies, so a non-English culture makes
ResourceManager probe for a missing MudBlazor.resources satellite and throw a
first-chance FileNotFoundException on every fresh lookup. That is mostly invisible
at runtime but severely slows the Blazor WebAssembly debugger, where each caught
exception stalls the debugger agent (a small MudDataGrid takes ~14-15s vs ~100ms).

Pin the built-in resource lookup to the invariant culture so the embedded neutral
resource is returned with no satellite probing. Only CurrentUICulture is pinned, so
argument formatting still honors the user's culture, and custom IStringLocalizer or
MudLocalizer sources keep the app's current UI culture.

Fixes MudBlazor#13461
@mudbot mudbot Bot added bug Unexpected behavior or functionality not working as intended localization Translations, locale formats, RTL layout, calendars labels Jul 13, 2026
@danielchalmers

Copy link
Copy Markdown
Member Author

The transient lifetime of the interceptor/localizer still builds a fresh ResourceManager per localized component (now exception-free but churny). Making the interceptor a singleton is a reasonable follow-up, out of scope here.

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

This PR prevents repeated MudBlazor.resources satellite assembly probing (and the resulting caught FileNotFoundExceptions) when the app runs under a non-English CurrentUICulture, by forcing lookups of MudBlazor’s built-in neutral English LanguageResource.resx to resolve under InvariantCulture.

Changes:

  • Wrap the built-in ResourceManagerStringLocalizer with an IStringLocalizer implementation that temporarily pins CultureInfo.CurrentUICulture to InvariantCulture for each lookup.
  • Materialize GetAllStrings() results inside the pinned-culture scope to avoid deferred enumeration after the culture is restored.
  • Add a regression unit test ensuring a non-English UI culture does not trigger MudBlazor.resources satellite probing (via AppDomain.AssemblyResolve observation).

Reviewed changes

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

File Description
src/MudBlazor/Services/Localization/AbstractLocalizationInterceptor.cs Wraps the default LanguageResource localizer so built-in English resources resolve under InvariantCulture, avoiding missing-satellite probing.
src/MudBlazor.UnitTests/Services/Localization/DefaultLocalizationInterceptorTests.cs Adds a regression test asserting no satellite probing occurs under sv-SE while still returning the expected English fallback.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@danielchalmers
danielchalmers merged commit b2579af into MudBlazor:dev Jul 13, 2026
10 checks passed
@danielchalmers
danielchalmers deleted the claude/mudblazor-13461-e9b922 branch July 13, 2026 17:49
@ScarletKuro

Copy link
Copy Markdown
Member

I would prefer more if that was created once via additional service that is registered as singleton, then it would be rather a one time thing.

This was referenced Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Unexpected behavior or functionality not working as intended localization Translations, locale formats, RTL layout, calendars

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Repeated MudBlazor.resources FileNotFoundExceptions cause severe Blazor WebAssembly debugger slowdown

3 participants