Skip to content

Commit

Permalink
Fix CharInClass reference in regex emitter (#61559)
Browse files Browse the repository at this point in the history
We've tried to consistently use global:: whenever referring to core library types in the regex generator emitted code.  I'd missed these two.

(That said, these make the code a lot harder to read, especially in places where we're unable to use extension methods as extensions, so we'll want to revisit this policy.)
  • Loading branch information
stephentoub authored Nov 15, 2021
1 parent a53e489 commit e85de53
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3419,8 +3419,8 @@ private static string MatchCharacterClass(bool hasTextInfo, RegexOptions options
// characters other than that some might be included, for example if the character class
// were [\w\d], so since ch >= 128, we need to fall back to calling CharInClass.
return invariant ?
$"((ch = {chExpr}) < 128 ? ({Literal(bitVectorString)}[ch >> 4] & (1 << (ch & 0xF))) != 0 : CharInClass(char.ToLowerInvariant((char)ch), {Literal(charClass)}))" :
$"((ch = {chExpr}) < 128 ? ({Literal(bitVectorString)}[ch >> 4] & (1 << (ch & 0xF))) != 0 : CharInClass((char)ch, {Literal(charClass)}))";
$"((ch = {chExpr}) < 128 ? ({Literal(bitVectorString)}[ch >> 4] & (1 << (ch & 0xF))) != 0 : global::System.Text.RegularExpressions.RegexRunner.CharInClass(char.ToLowerInvariant((char)ch), {Literal(charClass)}))" :
$"((ch = {chExpr}) < 128 ? ({Literal(bitVectorString)}[ch >> 4] & (1 << (ch & 0xF))) != 0 : global::System.Text.RegularExpressions.RegexRunner.CharInClass((char)ch, {Literal(charClass)}))";
}

private static string Literal(char c) => SymbolDisplay.FormatLiteral(c, quote: true);
Expand Down

0 comments on commit e85de53

Please sign in to comment.