Fix SvgSource invariant globalization startup failure#542
Merged
wieslawsoltes merged 2 commits intoJun 15, 2026
Conversation
This was referenced Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #541 by making
SvgServicesafe to initialize when .NET runs in invariant globalization mode.The previous
SvgServicestatic field eagerly calledCultureInfo.GetCultureInfo("en-US"). In invariant globalization mode, named culture lookup throwsCultureNotFoundException, which caused the wholeSvgServicetype initializer to fail before an SVG could be loaded. That surfaced throughSvg.Controls.Skia.Avaloniaas aTypeInitializationExceptionfromSvgSource.Load(...).This change keeps the existing deterministic
en-USdefault for SVGsystemLanguagematching, but avoids doing a throwing named-culture lookup during static initialization. If the runtime cannot create the named culture,SvgServicefalls back to the language tag string for conditional processing while still allowing tests and callers to overrides_systemLanguageOverride.Changes
en-USsystem language.en-USbehavior.Svg.Controls.Skia.Avalonia.SvgSource.systemLanguage="en-US"still selects the expected branch under invariant globalization.Validation
dotnet format Svg.Skia.slnx --no-restoredotnet build Svg.Skia.slnx -c Releasedotnet test Svg.Skia.slnx -c Releasedotnet test tests/Svg.Controls.Skia.Avalonia.InvariantGlobalization.UnitTests/Svg.Controls.Skia.Avalonia.InvariantGlobalization.UnitTests.csproj -c Release --filter "FullyQualifiedName~SvgSourceInvariantGlobalizationTests"dotnet test tests/Svg.Model.UnitTests/Svg.Model.UnitTests.csproj -f net10.0 -c Release --no-restore --filter "FullyQualifiedName~SvgConditionalProcessingTests"