Skip to content

Commit

Permalink
Merge pull request #70096 from CyrusNajmabadi/cultureFallback
Browse files Browse the repository at this point in the history
Fallback gracefully when running on runtimes that only support the Invariant culture
  • Loading branch information
CyrusNajmabadi authored Sep 25, 2023
2 parents 6f6e89f + b8d0446 commit 3888717
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/Features/Core/Portable/Completion/PatternMatchHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,25 @@ namespace Microsoft.CodeAnalysis.Completion
/// </summary>
internal sealed class PatternMatchHelper(string pattern) : IDisposable
{
private static readonly CultureInfo EnUSCultureInfo;

static PatternMatchHelper()
{
try
{
EnUSCultureInfo = new("en-US");
}
catch (CultureNotFoundException)
{
// See https://github.com/microsoft/vscode-dotnettools/issues/386
// This can happen when running on a runtime that is setup for culture invariant mode only.
EnUSCultureInfo = CultureInfo.InvariantCulture;
}
}

private readonly object _gate = new();
private readonly Dictionary<(CultureInfo, bool includeMatchedSpans), PatternMatcher> _patternMatcherMap = new();

private static readonly CultureInfo EnUSCultureInfo = new("en-US");

public string Pattern { get; } = pattern;

public ImmutableArray<TextSpan> GetHighlightedSpans(string text, CultureInfo culture)
Expand Down

0 comments on commit 3888717

Please sign in to comment.