Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ CancellationToken cancellationToken
{
if (!fs.FileExists(_solution.FullName))
{
_logger.LogError("Could not find the solution file {SolutionFile} in the file system", _solution.FullName);
throw new FileNotFoundException("Could not find the solution file in the file system", _solution.FullName);
_logger.LogWarning("Could not find the solution file {SolutionFile} in the file system, assuming empty", _solution.FullName);
return [];
}

await using var stream = fs.GetFileStream(
Expand Down
4 changes: 0 additions & 4 deletions src/dotnet-proj-diff/ProjectDiffCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ public sealed class ProjectDiffCommand : RootCommand
{
x.AddError("{x.Argument.Name} must be specified");
}
else if (!f.Exists)
{
x.AddError($"File '{f.FullName}' does not exist.");
}
else if (f.Extension is not (".sln" or ".slnx"))
{
x.AddError($"File '{f.FullName}' is not a valid sln file.");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
path: Sample/Sample.csproj,
name: Sample,
status: Added
}
]
18 changes: 18 additions & 0 deletions test/ProjectDiff.Tests/Tool/ProjectDiffTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,24 @@ public async Task DetectsAddedProjectsWithDirectoryScan()
await VerifyJson(output);
}

[Fact]
public async Task NewSolutionMarksProjectAsAdded()
{

using var repo = await TestRepository.SetupAsync(static async r =>
{
r.CreateDirectory("Sample");
r.CreateProject("Sample/Sample.csproj");
await r.WriteAllTextAsync("Sample/MyClass.cs", "// Some content");
}
);

var sln = await repo.CreateSolutionAsync("Sample.sln", sln => sln.AddProject("Sample/Sample.csproj"));

var output = await ExecuteAndReadStdout(repo, $"--solution={sln}");
await VerifyJson(output);
}

private static async Task<string> ExecuteAndReadStdout(
TestRepository repository,
params string[] args
Expand Down
Loading