Skip to content

Commit c34e0f2

Browse files
Copilotstephentoub
andcommitted
Consolidate test cases into existing test file per guidance
Co-authored-by: stephentoub <[email protected]>
1 parent d5b0c8e commit c34e0f2

File tree

2 files changed

+32
-155
lines changed

2 files changed

+32
-155
lines changed

src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/UpgradeToGeneratedRegexAnalyzerTests.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,38 @@ public static void Main(string[] args)
471471
[GeneratedRegex("""", Options)]
472472
private static partial Regex MyRegex();
473473
}" };
474+
475+
// Test options as external constant field
476+
yield return new object[] { @"using System.Text.RegularExpressions;
477+
478+
public class RegexConstants
479+
{
480+
public const RegexOptions DefaultOptions = RegexOptions.IgnoreCase | RegexOptions.CultureInvariant;
481+
}
482+
483+
public class Program
484+
{
485+
public static void Main(string[] args)
486+
{
487+
var isMatch = [|" + ConstructRegexInvocation(invocationType, "\"\"", "RegexConstants.DefaultOptions") + @"|]" + isMatchInvocation + @";
488+
}
489+
}", @"using System.Text.RegularExpressions;
490+
491+
public class RegexConstants
492+
{
493+
public const RegexOptions DefaultOptions = RegexOptions.IgnoreCase | RegexOptions.CultureInvariant;
494+
}
495+
496+
public partial class Program
497+
{
498+
public static void Main(string[] args)
499+
{
500+
var isMatch = MyRegex().IsMatch("""");
501+
}
502+
503+
[GeneratedRegex("""", RegexConstants.DefaultOptions)]
504+
private static partial Regex MyRegex();
505+
}" };
474506
}
475507
}
476508

src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/UpgradeToGeneratedRegexConstantPreservationTests.cs

Lines changed: 0 additions & 155 deletions
This file was deleted.

0 commit comments

Comments
 (0)