Improve usability of "enable nullable reference types" refactoring#58316
Improve usability of "enable nullable reference types" refactoring#58316sharwell merged 3 commits intodotnet:mainfrom
Conversation
|
|
||
| // Only the input solution contains '#nullable enable' | ||
| if (!document.GetTextSynchronously(CancellationToken.None).ToString().Contains("#nullable enable")) | ||
| if (!Regex.IsMatch(document.GetTextSynchronously(CancellationToken.None).ToString(), "#nullable ?enable")) |
There was a problem hiding this comment.
❓My regex fu is limited. Is this matching 0 or 1 spaces before enable? Or is the ? applied to enable somehow?
There was a problem hiding this comment.
yeah, i don't quite get the need for this. afaict, this is allowing for either one or two spaces after #nullable. Is that really needed?
There was a problem hiding this comment.
maybe + or \s+ if you want to match any amount of whitespace?
There was a problem hiding this comment.
Spaces between # and nullable are allowed by the compiler (it's a test code anyway, so probably doesn't matter).
There was a problem hiding this comment.
afaict, this is allowing for either one or two spaces after #nullable. Is that really needed?
Yes. All of the tests have one space except for one test that has two spaces. I'll update the comment.
There was a problem hiding this comment.
➡️ Comment is now updated
There was a problem hiding this comment.
This whole method is a workaround for the fact that the test library can't cleanly represent a code action that changes compilation options. Considering a few options and this will be updated after.
92787bd to
b885da9
Compare
See #57476