Closed
Description
Description
When using the "Convert to GeneratedRegexAttribute" fixer in VS, it mangles constant RegexOptions.
Reproduction Steps
Use this code:
const RegexOptions MyOptions = RegexOptions.Compiled | RegexOptions.IgnoreCase;
static Regex RX = new("asdf", MyOptions);
And apply the fixer. You now have the following:
const RegexOptions MyOptions = RegexOptions.Compiled | RegexOptions.IgnoreCase;
static Regex RX = MyRegex();
[GeneratedRegex("asdf", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-US")]
private static partial Regex MyRegex();
You'll notice that the constant, MyOptions
, is not used in the generated regex but is now expanded.
Expected behavior
I should get this code:
const RegexOptions MyOptions = RegexOptions.Compiled | RegexOptions.IgnoreCase;
static Regex RX = MyRegex();
[GeneratedRegex("asdf", MyOptions, "en-US")]
private static partial Regex MyRegex();
Actual behavior
You'll notice that the constant, MyOptions
, is not used in the generated regex but is now expanded.
Regression?
No response
Known Workarounds
Manually edit the "Fixed" code.
Configuration
VS 17.11.5