Skip to content

Fix MA0194 invalid pattern merges#1212

Merged
meziantou merged 2 commits into
mainfrom
codex/fix-ma0194-invalid-pattern-merge
Jul 3, 2026
Merged

Fix MA0194 invalid pattern merges#1212
meziantou merged 2 commits into
mainfrom
codex/fix-ma0194-invalid-pattern-merge

Conversation

@meziantou

Copy link
Copy Markdown
Owner

Summary

Fix MA0194 so it does not report or offer a merge when the resulting pattern would be invalid because a variable designation would be placed inside a not or or pattern.

The analyzer now carries pattern syntax with merge candidates and validates the merged pattern shape before reporting. The fixer uses the same guard before creating a merged pattern.

Validation

  • dotnet test tests/Meziantou.Analyzer.Test/Meziantou.Analyzer.Test.csproj --filter FullyQualifiedName~MergeIsPatternChecksAnalyzerTests
  • dotnet test tests/Meziantou.Analyzer.Test/Meziantou.Analyzer.Test.csproj /p:RoslynVersion=roslyn4.2 --filter FullyQualifiedName~MergeIsPatternChecksAnalyzerTests
  • dotnet run --project src/DocumentationGenerator
  • dotnet build Meziantou.Analyzer.slnx /p:TreatWarningsAsErrors=true /p:TreatsWarningsAsErrors=true

@meziantou meziantou changed the title [codex] Fix MA0194 invalid pattern merges Fix MA0194 invalid pattern merges Jul 3, 2026
@meziantou
meziantou force-pushed the codex/fix-ma0194-invalid-pattern-merge branch from 2c46148 to 286aa44 Compare July 3, 2026 15:46
@meziantou
meziantou marked this pull request as ready for review July 3, 2026 16:02
@meziantou
meziantou merged commit 7c2e36a into main Jul 3, 2026
13 checks passed
@meziantou
meziantou deleted the codex/fix-ma0194-invalid-pattern-merge branch July 3, 2026 16:08
This was referenced Jul 3, 2026
This was referenced Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant