Update AnalyzerConfig.cs s_propertyMatcherPattern regex key#78459
Update AnalyzerConfig.cs s_propertyMatcherPattern regex key#78459GweltazEFi wants to merge 2 commits intodotnet:mainfrom
Conversation
Going to need unit tests for this change in our code base. |
|
My general concern is that regexes are complex, and i do not have any innate sense of confidence that this isn't breaking some case we're not considering. Seems risky. TBH, i'm somewhat surprised we're using a regex here (unless it's a regex advised by the spec), as otherwise, the idea of splitting a string on |
|
(Reduced quote)
I do agree. My goal was not to tear appart the subject, only to make it work for #55431.
General differences:
@CyrusNajmabadi: Would it be a non-regex based change, could it be filed as a separate refactorization topic, to let the 3+ year old issue be closed in the meantime? |
|
Ready for review. |
Hello @jaredpar, are the tests provided here enough, or is there anything more you'd want to see tested? |
@jaredpar: Are you still waiting on tests? In the meantime, I asked Copilot for a review:
In case previous message isn't detailed enough, that's Copilot breaking down the new regex:
To rephrase Copilot: if you have anything in mind, please let me know. |
Removed most of the redundant tests from the explicit test coverage. Spaced keys were already tested: previously disallowed, now allowed. Added tests for Values looking like keys to ensure regex do end at the leftmost of those break points. Added tests for Values looking like config options without being them.
|
My account will be suspended or deleted in the near future, this code is free to use. |
Closes dotnet#55431 Allows space characters in the key name as per [specification](https://spec.editorconfig.org/#file-format). Regex testings: https://regex101.com/r/l0FeUH/9 (Changed `\s` to `[^\S\r\n]` there only to account for multiline context, see notes) PR related to issue [dotnet#55431 (comment)](dotnet#55431 (comment)) Closes PR [!78459](dotnet#78459) Notes: * To NOT break [current](https://github.com/dotnet/roslyn/blob/1e14d8a2f9eb04b0c9b4076fdc8a7f02d5d53ab1/src/Compilers/Core/Portable/CommandLine/AnalyzerConfig.cs#L25) implementation parsing, inline comments are still available. Removing the trailing `([#;].*)?` part would solve the issue. * It's a single-line evaluation process implementation, I changed `\s` to `[^\S\r\n]` only in the multiline testing context * `[\w\.\-_]` ["a word character, or a dot, or a hyphen, or an underscore"] is much slower than (the previously proposed) `[^=:\s]` ["any non-whitespace character or equal or double dot"], and can't be parsed on multiline online tools with the evaluation list linked above, I thus kept the regex testings link as it was initially @dotnet-policy-service agree
Closes dotnet#55431 Allows space characters in the key name as per [specification](https://spec.editorconfig.org/#file-format). Regex testings: https://regex101.com/r/l0FeUH/9 (Changed `\s` to `[^\S\r\n]` there only to account for multiline context, see notes) PR related to issue [dotnet#55431 (comment)](dotnet#55431 (comment)) Closes PR [!78459](dotnet#78459) Notes: * To NOT break [current](https://github.com/dotnet/roslyn/blob/1e14d8a2f9eb04b0c9b4076fdc8a7f02d5d53ab1/src/Compilers/Core/Portable/CommandLine/AnalyzerConfig.cs#L25) implementation parsing, inline comments are still available. Removing the trailing `([#;].*)?` part would solve the issue. * It's a single-line evaluation process implementation, I changed `\s` to `[^\S\r\n]` only in the multiline testing context * `[\w\.\-_]` ["a word character, or a dot, or a dash, or an underscore"] is much slower than (the previously proposed) `[^=:\s]` ["any non-whitespace character or equal or double dot"], and can't be parsed on multiline online tools with the evaluation list linked above, I thus kept the regex testings link as it was initially
Closes #55431
Allowed any character in the key name as per specification, including spaces, excluding
:and=characters.Changed
\s*to[^\S\r\n]to account for multiline contextRegex testings: https://regex101.com/r/l0FeUH/9
PR related to issue #55431 (comment)
Notes:
([#;].*)?part would solve the issue.@dotnet-policy-service agree