Simplify UpgradeToRegexGenerator#72538
Conversation
|
Tagging subscribers to this area: @dotnet/area-system-text-regularexpressions Issue Detailsnull
|
|
Marking as a draft. Not ready for review until #72534 is merged and this branch is rebased. |
There was a problem hiding this comment.
This should be renamed to something like FormatRegexOptions. It's not clear what it does by the name and parameter type.
There was a problem hiding this comment.
Probably stringifiedRegexOptions to make it clear this is a RegexOptions that we called ToString on?
6549876 to
8dab54b
Compare
8dab54b to
b896c4a
Compare
|
@joperezr Can you take a look please? Thanks! |
|
Thanks for the PR @Youssef1313. Since you are changing this, one of the comments from the original PR that added the analyzer was particularly suggesting that ideally we shouldn't have the analyzer send any info into the fixer if possible in order to have both be easier to understand and maintain. Here is the relevant part of the comment by @mavasani:
I think if we are changing this now, we should re-evaluate that comment and perhaps moving the logic of grabbing the values out to the fixer itself. Thoughts? |
|
Sure. I'll try with that approach. |
|
@joperezr I applied the suggestion. The PR is ready for another look. |
|
|
||
| // Validate that arguments pattern and options are constant and timeout was not passed in. | ||
| if (!TryValidateParametersAndExtractArgumentIndices(invocationOperation.Arguments, ref patternArgumentIndex, ref optionsArgumentIndex)) | ||
| if (!TryValidateParametersAndExtractArgumentIndices(invocationOperation.Arguments)) |
There was a problem hiding this comment.
Small NIT: The name of the method is technically not accurate any longer, now we are only doing validation of the Parameters so we could rename to ValidateParameters
| /// source generation. | ||
| /// </summary> | ||
| [ExportCodeFixProvider(LanguageNames.CSharp)] | ||
| [ExportCodeFixProvider(LanguageNames.CSharp), Shared] |
There was a problem hiding this comment.
Looks like in other similar places we aren't adding this attribute, like:
I'm not saying adding the attribute is wrong, but it also isn't very related to this PR so we should probably live that to a follow up PR.
src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorCodeFixer.cs
Show resolved
Hide resolved
joperezr
left a comment
There was a problem hiding this comment.
Thanks for the contribution @Youssef1313 !
src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorCodeFixer.cs
Outdated
Show resolved
Hide resolved
…xGeneratorCodeFixer.cs
|
Will merge as soon as Build is green. |
Previously, analyzer reported argument indices in its properties. Then codefix will get the argument values from the indices in
GetNode. I changed the analyzer to report the values directly, which simplifies things a little bit.