Uh oh!
There was an error while loading. Please reload this page.
Fix regex fixer to maintain string literal syntax - #78172
Conversation
ghost
commented
Nov 10, 2022
Tagging subscribers to this area: @dotnet/area-system-text-regularexpressions Issue DetailsFixes #78113
|
Uh oh!
There was an error while loading. Please reload this page.
joperezr
commented
Nov 10, 2022
Unless I'm missing something, this will generate code that won't compile sometimes. For example, the case of: usingSystem.Text.RegularExpressions;partialclassProgram{staticvoidMain(string[]args){conststringpattern=@"a|b\s\n";conststringpattern2=$"{pattern}2";Regexregex=newRegex(pattern2);}}If I'm following correctly, this will generate the new static method and pass in pattern2 as the argument to the GeneratedRegex attribute, which is not in scope so code won't compile. This is why today we instead have to evaluate the constant value and then use that as the argument to the attribute. If I'm correct with my assumption here, I'm not sure why we don't have a test that checks that, but we should add one if we don't. |
stephentoub
commented
Nov 10, 2022
We don't :) |
Uh oh!
There was an error while loading. Please reload this page.
joperezr
left a comment
There was a problem hiding this comment.
Thanks for fixing this @stephentoub and thanks for the help @Youssef1313!

Fixes#78113