Skip to content

Commit

Permalink
Fallback gracefully when running on runtimes that only support the In…
Browse files Browse the repository at this point in the history
…variant culture
  • Loading branch information
CyrusNajmabadi committed Sep 23, 2023
1 parent 64dbd52 commit b8d0446
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 b8d0446

Please sign in to comment.