diff --git a/ChangeLog.md b/ChangeLog.md index 1c29948fd5..d01f44d805 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- [CLI] Fix loading of `slnf` files ([PR](https://github.com/dotnet/roslynator/pull/1447)) + ## [4.12.1] - 2024-04-15 ### Changed diff --git a/src/CommandLine/CommandLineHelpers.cs b/src/CommandLine/CommandLineHelpers.cs index fab8b94cf8..3e53226221 100644 --- a/src/CommandLine/CommandLineHelpers.cs +++ b/src/CommandLine/CommandLineHelpers.cs @@ -20,7 +20,8 @@ public static bool IsGlobPatternForProject(string pattern) public static bool IsGlobPatternForSolution(string pattern) { - return pattern.EndsWith(".sln", StringComparison.OrdinalIgnoreCase); + return pattern.EndsWith(".sln", StringComparison.OrdinalIgnoreCase) + || pattern.EndsWith(".slnf", StringComparison.OrdinalIgnoreCase); } public static void WaitForKeyPress(string message = null) diff --git a/src/CommandLine/Commands/MSBuildWorkspaceCommand.cs b/src/CommandLine/Commands/MSBuildWorkspaceCommand.cs index 566287a62b..b836d9be22 100644 --- a/src/CommandLine/Commands/MSBuildWorkspaceCommand.cs +++ b/src/CommandLine/Commands/MSBuildWorkspaceCommand.cs @@ -72,7 +72,7 @@ public async Task ExecuteAsync(IEnumerable paths, strin { if (path.Origin == PathOrigin.PipedInput) { - Matcher matcher = (string.Equals(Path.GetExtension(path.Path), ".sln", StringComparison.OrdinalIgnoreCase)) + Matcher matcher = (IsSolutionFile(path.Path)) ? ProjectFilter.SolutionMatcher : ProjectFilter.Matcher; @@ -225,7 +225,7 @@ protected virtual void WorkspaceFailed(object sender, WorkspaceDiagnosticEventAr IProgress progress = null, CancellationToken cancellationToken = default) { - bool isSolution = string.Equals(Path.GetExtension(path), ".sln", StringComparison.OrdinalIgnoreCase); + bool isSolution = IsSolutionFile(path); WriteLine($"Loading {((isSolution) ? "solution" : "project")} '{path}'...", Verbosity.Minimal); @@ -405,6 +405,14 @@ private protected bool IsMatch(Project project) } } + private static bool IsSolutionFile(string path) + { + string extension = Path.GetExtension(path); + + return string.Equals(extension, ".sln", StringComparison.OrdinalIgnoreCase) + || string.Equals(extension, ".slnf", StringComparison.OrdinalIgnoreCase); + } + protected class ConsoleProgressReporter : IProgress { public static ConsoleProgressReporter Default { get; } = new();