Skip to content

Handle Windows backslashes in ConfigurationUpdater header regex construction#83646

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-invalid-regex-configuration-updater
Draft

Handle Windows backslashes in ConfigurationUpdater header regex construction#83646
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-invalid-regex-configuration-updater

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 11, 2026

ConfigurationUpdater was building a regex directly from .editorconfig header text and did not handle Windows-style \ path separators. In VS Code quick-fix flows (for analyzer severity configuration), this could throw RegexParseException (for example, \h escape) instead of applying/updating configuration.

  • Product fix: normalize header path separators before regex translation

    • In ConfigurationUpdater.CheckIfRuleExistsAndReplaceInFile, header path text now normalizes \ to / before wildcard/extension regex expansion.
    • This avoids invalid escape sequences while preserving existing matching behavior against normalized relative paths.
  • Regression coverage: backslash-heavy header scenario

    • Added a focused test in CategoryBasedSeverityConfigurationTests to cover a header containing Windows-style backslashes.
    • The test ensures configuration update proceeds through the code action path that previously failed with invalid regex parsing.
// Before translating header text into regex fragments:
fileName = fileName.Replace('\\', '/');
fileName = fileName.Replace(".", @"\.");
fileName = fileName.Replace("*", ".*");

Copilot AI and others added 2 commits May 11, 2026 17:46
Agent-Logs-Url: https://github.com/dotnet/roslyn/sessions/44f1c0cb-6ee3-44a5-991f-964315a06c1d

Co-authored-by: phil-allen-msft <32652734+phil-allen-msft@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/roslyn/sessions/44f1c0cb-6ee3-44a5-991f-964315a06c1d

Co-authored-by: phil-allen-msft <32652734+phil-allen-msft@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix invalid regex handling for Windows paths in ConfigurationUpdater Handle Windows backslashes in ConfigurationUpdater header regex construction May 11, 2026
Copilot AI requested a review from phil-allen-msft May 11, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid regex in ConfigurationUpdater

2 participants