Skip to content

Commit

Permalink
Fix loading of slnf (#1447)
Browse files Browse the repository at this point in the history
  • Loading branch information
josefpihrt committed Apr 23, 2024
1 parent db09e15 commit 3dadfbf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/CommandLine/CommandLineHelpers.cs
Expand Up @@ -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)
Expand Down
12 changes: 10 additions & 2 deletions src/CommandLine/Commands/MSBuildWorkspaceCommand.cs
Expand Up @@ -72,7 +72,7 @@ public async Task<CommandStatus> ExecuteAsync(IEnumerable<PathInfo> 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;

Expand Down Expand Up @@ -225,7 +225,7 @@ protected virtual void WorkspaceFailed(object sender, WorkspaceDiagnosticEventAr
IProgress<ProjectLoadProgress> 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);

Expand Down Expand Up @@ -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<ProjectLoadProgress>
{
public static ConsoleProgressReporter Default { get; } = new();
Expand Down

0 comments on commit 3dadfbf

Please sign in to comment.