diff --git a/ChangeLog.md b/ChangeLog.md index cd73a99478..ae18faed37 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix enum contained flags check for partial matches in [RCS1258](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1258) ([PR](https://github.com/dotnet/roslynator/pull/1740) by @ovska) - Fix analyzer [RCS1146](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1146) ([PR](https://github.com/dotnet/roslynator/pull/1747)) - Fix analyzer [RCS1194](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1194) ([PR](https://github.com/dotnet/roslynator/pull/1733)) +- [CLI] Fix `fix` command ignoring `--include` / `--exclude` file filter ([PR](https://github.com/dotnet/roslynator/pull/1758) by @hashiiiii) ## [4.15.0] - 2025-12-14 diff --git a/src/Workspaces.Core/CodeFixes/CodeFixer.cs b/src/Workspaces.Core/CodeFixes/CodeFixer.cs index 4d58974c86..fdc7e2d31a 100644 --- a/src/Workspaces.Core/CodeFixes/CodeFixer.cs +++ b/src/Workspaces.Core/CodeFixes/CodeFixer.cs @@ -294,12 +294,16 @@ ImmutableArray GetFixableDiagnostics( IEnumerable fixableCompilerDiagnostics = compilerDiagnostics .Where(f => f.Severity != DiagnosticSeverity.Error && !Options.IgnoredCompilerDiagnosticIds.Contains(f.Id) - && fixersById.ContainsKey(f.Id)); + && fixersById.ContainsKey(f.Id) + && (f.Location.SourceTree is null + || Options.FileSystemFilter?.IsMatch(f.Location.SourceTree.FilePath) != false)); return diagnostics .Where(f => f.IsEffective(Options, project.CompilationOptions) && analyzersById.ContainsKey(f.Id) - && fixersById.ContainsKey(f.Id)) + && fixersById.ContainsKey(f.Id) + && (f.Location.SourceTree is null + || Options.FileSystemFilter?.IsMatch(f.Location.SourceTree.FilePath) != false)) .Concat(fixableCompilerDiagnostics) .ToImmutableArray(); } @@ -357,7 +361,10 @@ private async Task FixDiagnosticsAsync( } diagnostics = diagnostics - .Where(f => f.Id == descriptor.Id && f.Severity >= Options.SeverityLevel) + .Where(f => f.Id == descriptor.Id + && f.Severity >= Options.SeverityLevel + && (f.Location.SourceTree is null + || Options.FileSystemFilter?.IsMatch(f.Location.SourceTree.FilePath) != false)) .ToImmutableArray(); if (fixKind == DiagnosticFixKind.CompilerError)