Description
CSharpier 1.3.0 crashes when parsing a .gitignore file containing certain glob patterns from the standard GitHub macOS .gitignore template. The CLI throws an unhandled RegexParseException during ignore rule compilation, preventing the formatter from running.
Steps to Reproduce
- Create or update a
.gitignore file with patterns from the latest GitHub macOS .gitignore template (https://github.com/github/gitignore/blob/main/Global/macOS.gitignore)
- Run
dotnet csharpier format . (or csharpier format .)
Expected Behavior
CSharpier should either:
- Successfully parse the
.gitignore file and ignore the specified patterns, OR
- Emit a clear, actionable error message indicating which pattern is invalid and needs to be fixed
Actual Behavior
The formatter crashes with an unhandled exception:
Unhandled exception: System.Text.RegularExpressions.RegexParseException: Invalid pattern '^Icon(?!/)[$' at offset 12. Unterminated [] set.
at System.Text.RegularExpressions.RegexParser.ScanCharClass(Boolean caseInsensitive, Boolean scanOnly)
at System.Text.RegularExpressions.RegexParser.CountCaptures(RegexOptions& optionsFoundInPattern)
at System.Text.RegularExpressions.RegexParser.Parse(String pattern, RegexOptions options, CultureInfo culture)
at System.Text.RegularExpressions.Regex..ctor(String pattern, RegexOptions options, TimeSpan matchTimeout, CultureInfo culture)
Description
CSharpier 1.3.0 crashes when parsing a
.gitignorefile containing certain glob patterns from the standard GitHub macOS.gitignoretemplate. The CLI throws an unhandledRegexParseExceptionduring ignore rule compilation, preventing the formatter from running.Steps to Reproduce
.gitignorefile with patterns from the latest GitHub macOS.gitignoretemplate (https://github.com/github/gitignore/blob/main/Global/macOS.gitignore)dotnet csharpier format .(orcsharpier format .)Expected Behavior
CSharpier should either:
.gitignorefile and ignore the specified patterns, ORActual Behavior
The formatter crashes with an unhandled exception: