Skip to content

Commit 3dadfbf

Browse files
authored
Fix loading of slnf (#1447)
1 parent db09e15 commit 3dadfbf

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

ChangeLog.md

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- [CLI] Fix loading of `slnf` files ([PR](https://github.com/dotnet/roslynator/pull/1447))
13+
1014
## [4.12.1] - 2024-04-15
1115

1216
### Changed

src/CommandLine/CommandLineHelpers.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ public static bool IsGlobPatternForProject(string pattern)
2020

2121
public static bool IsGlobPatternForSolution(string pattern)
2222
{
23-
return pattern.EndsWith(".sln", StringComparison.OrdinalIgnoreCase);
23+
return pattern.EndsWith(".sln", StringComparison.OrdinalIgnoreCase)
24+
|| pattern.EndsWith(".slnf", StringComparison.OrdinalIgnoreCase);
2425
}
2526

2627
public static void WaitForKeyPress(string message = null)

src/CommandLine/Commands/MSBuildWorkspaceCommand.cs

+10-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public async Task<CommandStatus> ExecuteAsync(IEnumerable<PathInfo> paths, strin
7272
{
7373
if (path.Origin == PathOrigin.PipedInput)
7474
{
75-
Matcher matcher = (string.Equals(Path.GetExtension(path.Path), ".sln", StringComparison.OrdinalIgnoreCase))
75+
Matcher matcher = (IsSolutionFile(path.Path))
7676
? ProjectFilter.SolutionMatcher
7777
: ProjectFilter.Matcher;
7878

@@ -225,7 +225,7 @@ private static async Task<ProjectOrSolution> OpenProjectOrSolutionAsync(
225225
IProgress<ProjectLoadProgress> progress = null,
226226
CancellationToken cancellationToken = default)
227227
{
228-
bool isSolution = string.Equals(Path.GetExtension(path), ".sln", StringComparison.OrdinalIgnoreCase);
228+
bool isSolution = IsSolutionFile(path);
229229

230230
WriteLine($"Loading {((isSolution) ? "solution" : "project")} '{path}'...", Verbosity.Minimal);
231231

@@ -405,6 +405,14 @@ private protected async Task<ImmutableArray<Compilation>> GetCompilationsAsync(
405405
}
406406
}
407407

408+
private static bool IsSolutionFile(string path)
409+
{
410+
string extension = Path.GetExtension(path);
411+
412+
return string.Equals(extension, ".sln", StringComparison.OrdinalIgnoreCase)
413+
|| string.Equals(extension, ".slnf", StringComparison.OrdinalIgnoreCase);
414+
}
415+
408416
protected class ConsoleProgressReporter : IProgress<ProjectLoadProgress>
409417
{
410418
public static ConsoleProgressReporter Default { get; } = new();

0 commit comments

Comments
 (0)