diff --git a/.editorconfig b/.editorconfig index 92beff4..4286c12 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,4 +1,6 @@ -# Verify settings +root = true + +# Verify settings [*.{received,verified}.{json,txt,xml}] charset = utf-8 end_of_line = lf @@ -6,4 +8,16 @@ indent_size = unset indent_style = unset insert_final_newline = false tab_width = unset -trim_trailing_whitespace = false \ No newline at end of file +trim_trailing_whitespace = false + + +[*.cs] +end_of_line = crlf +indent_size = 4 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true +charset = utf-8 + +[*.sh] +end_of_line = lf diff --git a/src/ProjectDiff.Core/BuildGraph.cs b/src/ProjectDiff.Core/BuildGraph.cs index 092ae0d..0632344 100644 --- a/src/ProjectDiff.Core/BuildGraph.cs +++ b/src/ProjectDiff.Core/BuildGraph.cs @@ -1,7 +1,7 @@ -namespace ProjectDiff.Core; +namespace ProjectDiff.Core; public sealed class BuildGraph { public required IReadOnlyCollection Projects { get; init; } - -} \ No newline at end of file + +} diff --git a/src/ProjectDiff.Core/BuildGraphDiff.cs b/src/ProjectDiff.Core/BuildGraphDiff.cs index ebe8c19..37d8584 100644 --- a/src/ProjectDiff.Core/BuildGraphDiff.cs +++ b/src/ProjectDiff.Core/BuildGraphDiff.cs @@ -1,4 +1,6 @@ -using System.Collections.Frozen; +using System.Collections.Frozen; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; namespace ProjectDiff.Core; @@ -7,10 +9,12 @@ public static class BuildGraphDiff public static IEnumerable Diff( BuildGraph previous, BuildGraph current, - IEnumerable modifiedFiles + IEnumerable modifiedFiles, + ILoggerFactory? loggerFactory = null ) { - var instance = new GraphDiffInstance(current); + loggerFactory ??= NullLoggerFactory.Instance; + var instance = new GraphDiffInstance(current, loggerFactory.CreateLogger()); return instance.Execute(previous, modifiedFiles.ToFrozenSet()); } @@ -19,20 +23,24 @@ private sealed class GraphDiffInstance { private readonly BuildGraph _graph; private readonly Dictionary _modifiedProjects; + private readonly ILogger _logger; - public GraphDiffInstance(BuildGraph graph) + public GraphDiffInstance(BuildGraph graph, ILogger logger) { _modifiedProjects = new Dictionary(graph.Projects.Count); _graph = graph; + _logger = logger; } public IEnumerable Execute(BuildGraph previous, FrozenSet modifiedFiles) { foreach (var currentProject in _graph.Projects) { - var previousProject = previous.Projects.FirstOrDefault(it => it.Matches(currentProject)); + using var scope = _logger.BeginScope(currentProject.FullPath); + var previousProject = previous.Projects.FirstOrDefault(it => it.FullPath == currentProject.FullPath); if (previousProject is null) { + _logger.LogDebug("Project not found in previous graph, marking as added"); yield return new DiffProject { Path = currentProject.FullPath, @@ -42,6 +50,7 @@ public IEnumerable Execute(BuildGraph previous, FrozenSet m } else if (HasProjectChanged(previousProject, currentProject, modifiedFiles)) { + _logger.LogDebug("Project has changed, marking as modified"); yield return new DiffProject { Path = currentProject.FullPath, @@ -51,6 +60,7 @@ public IEnumerable Execute(BuildGraph previous, FrozenSet m } else if (HasProjectReferencesChanged(previousProject, currentProject, modifiedFiles)) { + _logger.LogDebug("Project references have changed, marking as reference changed"); yield return new DiffProject { Path = currentProject.FullPath, @@ -62,9 +72,10 @@ public IEnumerable Execute(BuildGraph previous, FrozenSet m foreach (var previousProject in previous.Projects) { - var existsInCurrent = _graph.Projects.Any(it => it.Matches(previousProject)); + var existsInCurrent = _graph.Projects.Any(it => it.FullPath == previousProject.FullPath); if (!existsInCurrent) { + _logger.LogDebug("Project {Path} not found in current graph, marking as removed", previousProject.FullPath); yield return new DiffProject { Path = previousProject.FullPath, @@ -96,7 +107,7 @@ FrozenSet modifiedFiles return false; } - private static bool HasProjectInputFilesChanged( + private bool HasProjectInputFilesChanged( IReadOnlyCollection previous, IReadOnlyCollection current, FrozenSet modifiedFiles @@ -104,6 +115,11 @@ FrozenSet modifiedFiles { if (previous.Count != current.Count) { + _logger.LogDebug( + "Input files count changed: {PreviousCount} -> {CurrentCount}", + previous.Count, + current.Count + ); return true; } @@ -111,11 +127,13 @@ FrozenSet modifiedFiles { if (!previous.Contains(file)) { + _logger.LogInformation("Input file {File} added", file); return true; } if (modifiedFiles.Contains(file)) { + _logger.LogInformation("Input file {File} modified", file); return true; } } @@ -124,6 +142,7 @@ FrozenSet modifiedFiles { if (!current.Contains(file)) { + _logger.LogInformation("Input file {File} removed", file); return true; } } @@ -140,6 +159,11 @@ FrozenSet modifiedFiles { if (previous.References.Count != current.References.Count) { + _logger.LogDebug( + "References count changed: {PreviousCount} -> {CurrentCount}", + previous.References.Count, + current.References.Count + ); return true; } @@ -147,6 +171,7 @@ FrozenSet modifiedFiles { if (!previous.References.Contains(reference)) { + _logger.LogInformation("Reference {Reference} added", reference); return true; } @@ -155,6 +180,7 @@ FrozenSet modifiedFiles if (HasProjectChanged(previousReference, currentReference, modifiedFiles)) { + _logger.LogInformation("Referenced project {Reference} modified", reference); return true; } } @@ -163,6 +189,7 @@ FrozenSet modifiedFiles { if (!current.References.Contains(reference)) { + _logger.LogInformation("Referenced project {Reference} removed", reference); return true; } } @@ -170,4 +197,4 @@ FrozenSet modifiedFiles return false; } } -} \ No newline at end of file +} diff --git a/src/ProjectDiff.Core/BuildGraphFactory.cs b/src/ProjectDiff.Core/BuildGraphFactory.cs index 00be02a..6954cc8 100644 --- a/src/ProjectDiff.Core/BuildGraphFactory.cs +++ b/src/ProjectDiff.Core/BuildGraphFactory.cs @@ -1,4 +1,5 @@ -using System.Diagnostics; +using System.Diagnostics; +using LibGit2Sharp; using Microsoft.Build.Execution; using Microsoft.Build.Graph; using Microsoft.Build.Prediction; @@ -10,13 +11,14 @@ public static class BuildGraphFactory { private static readonly IProjectGraphPredictor[] ProjectGraphPredictors = ProjectPredictors .AllProjectGraphPredictors + // We create the build graph ourselves, we don't want referenced csproj files to be part of the input files .Where(it => it is not ProjectFileAndImportsGraphPredictor) .ToArray(); - public static BuildGraph CreateForProjectGraph( ProjectGraph graph, - IReadOnlyCollection changedFiles + Repository repository, + IReadOnlyCollection ignoredFiles ) { var executor = new ProjectGraphPredictionExecutor( @@ -24,7 +26,7 @@ IReadOnlyCollection changedFiles ProjectPredictors.AllProjectPredictors ); - var collector = new BuildGraphPredictionCollector(graph, changedFiles); + var collector = new BuildGraphPredictionCollector(graph, repository, ignoredFiles); executor.PredictInputsAndOutputs(graph, collector); @@ -34,13 +36,19 @@ IReadOnlyCollection changedFiles private sealed class BuildGraphPredictionCollector : IProjectPredictionCollector { private readonly ProjectGraph _projectGraph; + private readonly Repository _repository; + private readonly IReadOnlyCollection _ignoredFiles; private readonly Dictionary _collectors; - private readonly IReadOnlyCollection _changedFiles; - public BuildGraphPredictionCollector(ProjectGraph projectGraph, IReadOnlyCollection changedFiles) + public BuildGraphPredictionCollector( + ProjectGraph projectGraph, + Repository repository, + IReadOnlyCollection ignoredFiles + ) { _projectGraph = projectGraph; - _changedFiles = changedFiles; + _repository = repository; + _ignoredFiles = ignoredFiles; _collectors = new Dictionary(_projectGraph.ProjectNodes.Count); foreach (var node in _projectGraph.ProjectNodes) { @@ -51,6 +59,7 @@ public BuildGraphPredictionCollector(ProjectGraph projectGraph, IReadOnlyCollect } } + public void AddInputFile(string path, ProjectInstance projectInstance, string predictorName) { if (!Path.IsPathRooted(path)) @@ -58,7 +67,21 @@ public void AddInputFile(string path, ProjectInstance projectInstance, string pr path = Path.GetFullPath(path, projectInstance.Directory); } - if (!_changedFiles.Contains(path)) + // Only include files that are part of this repository + if (!path.StartsWith(_repository.Info.WorkingDirectory)) + { + return; + } + + // Ignore files that are in the ignored files list + if (_ignoredFiles.Count > 0 && _ignoredFiles.Any(it => it.FullName == path)) + { + return; + } + + // Ignore any files that are ignored by .gitignore + var relativePath = Path.GetRelativePath(_repository.Info.WorkingDirectory, path).Replace('\\', '/'); + if (_repository.Ignore.IsPathIgnored(relativePath)) { return; } @@ -152,4 +175,4 @@ public BuildGraphProject ToBuildGraphProject() } } } -} \ No newline at end of file +} diff --git a/src/ProjectDiff.Core/BuildGraphProject.cs b/src/ProjectDiff.Core/BuildGraphProject.cs index 1b5d1e0..72f4d81 100644 --- a/src/ProjectDiff.Core/BuildGraphProject.cs +++ b/src/ProjectDiff.Core/BuildGraphProject.cs @@ -1,4 +1,4 @@ -namespace ProjectDiff.Core; +namespace ProjectDiff.Core; public sealed class BuildGraphProject { @@ -16,9 +16,4 @@ IReadOnlyCollection references public string FullPath { get; } public IReadOnlyCollection InputFiles { get; } public IReadOnlyCollection References { get; } - - public bool Matches(BuildGraphProject other) - { - return FullPath == other.FullPath; - } -} \ No newline at end of file +} diff --git a/src/ProjectDiff.Core/DiffProject.cs b/src/ProjectDiff.Core/DiffProject.cs index 5e459a4..6f837f6 100644 --- a/src/ProjectDiff.Core/DiffProject.cs +++ b/src/ProjectDiff.Core/DiffProject.cs @@ -1,10 +1,10 @@ -namespace ProjectDiff.Core; +namespace ProjectDiff.Core; public sealed record DiffProject { public required string Path { get; init; } + public string Name => System.IO.Path.GetFileNameWithoutExtension(Path); public required DiffStatus Status { get; init; } - - + public required IReadOnlyCollection ReferencedProjects { get; init; } = []; -} \ No newline at end of file +} diff --git a/src/ProjectDiff.Core/DiffStatus.cs b/src/ProjectDiff.Core/DiffStatus.cs index 3fba9ce..6b4a655 100644 --- a/src/ProjectDiff.Core/DiffStatus.cs +++ b/src/ProjectDiff.Core/DiffStatus.cs @@ -1,4 +1,4 @@ -namespace ProjectDiff.Core; +namespace ProjectDiff.Core; public enum DiffStatus { @@ -6,4 +6,4 @@ public enum DiffStatus Removed, Modified, ReferenceChanged, -} \ No newline at end of file +} diff --git a/src/ProjectDiff.Core/Entrypoints/DirectoryScanEntrypointProvider.cs b/src/ProjectDiff.Core/Entrypoints/DirectoryScanEntrypointProvider.cs index e0c7db4..7d49309 100644 --- a/src/ProjectDiff.Core/Entrypoints/DirectoryScanEntrypointProvider.cs +++ b/src/ProjectDiff.Core/Entrypoints/DirectoryScanEntrypointProvider.cs @@ -1,6 +1,7 @@ -using Microsoft.Build.FileSystem; +using Microsoft.Build.FileSystem; using Microsoft.Build.Graph; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; namespace ProjectDiff.Core.Entrypoints; @@ -8,9 +9,10 @@ public sealed class DirectoryScanEntrypointProvider : IEntrypointProvider { private readonly ILogger _logger; - public DirectoryScanEntrypointProvider(ILogger logger) + + public DirectoryScanEntrypointProvider(ILogger? logger = null) { - _logger = logger; + _logger = logger ?? NullLogger.Instance; } public Task> GetEntrypoints( @@ -26,4 +28,4 @@ CancellationToken cancellationToken return Task.FromResult(entrypoints); } -} \ No newline at end of file +} diff --git a/src/ProjectDiff.Core/Entrypoints/IEntrypointProvider.cs b/src/ProjectDiff.Core/Entrypoints/IEntrypointProvider.cs index 81be964..f9226cf 100644 --- a/src/ProjectDiff.Core/Entrypoints/IEntrypointProvider.cs +++ b/src/ProjectDiff.Core/Entrypoints/IEntrypointProvider.cs @@ -1,4 +1,4 @@ -using Microsoft.Build.FileSystem; +using Microsoft.Build.FileSystem; using Microsoft.Build.Graph; namespace ProjectDiff.Core.Entrypoints; @@ -10,4 +10,4 @@ Task> GetEntrypoints( MSBuildFileSystemBase fs, CancellationToken cancellationToken ); -} \ No newline at end of file +} diff --git a/src/ProjectDiff.Core/Entrypoints/SolutionEntrypointProvider.cs b/src/ProjectDiff.Core/Entrypoints/SolutionEntrypointProvider.cs index ab48992..47baf46 100644 --- a/src/ProjectDiff.Core/Entrypoints/SolutionEntrypointProvider.cs +++ b/src/ProjectDiff.Core/Entrypoints/SolutionEntrypointProvider.cs @@ -1,4 +1,4 @@ -using Microsoft.Build.FileSystem; +using Microsoft.Build.FileSystem; using Microsoft.Build.Graph; using Microsoft.Extensions.Logging; using Microsoft.VisualStudio.SolutionPersistence.Serializer; @@ -36,50 +36,15 @@ CancellationToken cancellationToken ); - return await GetProjectEntrypoints(_solution, stream, cancellationToken); - } - - - private async Task> GetProjectEntrypoints( - FileInfo solutionFile, - Stream stream, - CancellationToken cancellationToken - ) - { - switch (solutionFile.Extension) + var solutionModel = _solution.Extension switch { - case ".sln": - { - _logger.LogDebug("Reading {SolutionFile} as a .sln file", solutionFile.FullName); - var solutionModel = await SolutionSerializers.SlnFileV12.OpenAsync(stream, cancellationToken); - - _logger.LogDebug( - "Found {ProjectCount} projects in solution {SolutionFile}", - solutionModel.SolutionProjects.Count, - solutionFile.FullName - ); - return solutionModel.SolutionProjects - .Select(it => - new ProjectGraphEntryPoint(Path.GetFullPath(it.FilePath, solutionFile.DirectoryName!)) - ); - } - case ".slnx": - { - _logger.LogDebug("Reading {SolutionFile} as a .slnx file", solutionFile.FullName); - var solutionModel = await SolutionSerializers.SlnXml.OpenAsync(stream, cancellationToken); - - _logger.LogDebug( - "Found {ProjectCount} projects in solution {SolutionFile}", - solutionModel.SolutionProjects.Count, - solutionFile.FullName - ); - return solutionModel.SolutionProjects - .Select(it => - new ProjectGraphEntryPoint(Path.GetFullPath(it.FilePath, solutionFile.DirectoryName!)) - ); - } - default: - throw new NotSupportedException($"Solution file extension {solutionFile.Extension} not supported"); - } + ".sln" => await SolutionSerializers.SlnFileV12.OpenAsync(stream, cancellationToken), + ".slnx" => await SolutionSerializers.SlnXml.OpenAsync(stream, cancellationToken), + _ => throw new NotSupportedException($"Solution file extension {_solution.Extension} is not supported") + }; + return solutionModel.SolutionProjects + .Select(it => + new ProjectGraphEntryPoint(Path.GetFullPath(it.FilePath, _solution.DirectoryName!)) + ); } -} \ No newline at end of file +} diff --git a/src/ProjectDiff.Core/GitTreeFileSystem.cs b/src/ProjectDiff.Core/GitTreeFileSystem.cs index 61e0847..074b086 100644 --- a/src/ProjectDiff.Core/GitTreeFileSystem.cs +++ b/src/ProjectDiff.Core/GitTreeFileSystem.cs @@ -1,4 +1,4 @@ -using System.IO.Enumeration; +using System.IO.Enumeration; using System.Xml; using LibGit2Sharp; using Microsoft.Build.Construction; @@ -333,4 +333,4 @@ bool ShouldInclude(TreeEntry entry) return (entry.Target.Peel(), Path.GetFullPath(Path.Combine(_repository.Info.WorkingDirectory, relativePath))); } -} \ No newline at end of file +} diff --git a/src/ProjectDiff.Core/ProjectDiffExecutionStatus.cs b/src/ProjectDiff.Core/ProjectDiffExecutionStatus.cs index 05202c3..8ecd436 100644 --- a/src/ProjectDiff.Core/ProjectDiffExecutionStatus.cs +++ b/src/ProjectDiff.Core/ProjectDiffExecutionStatus.cs @@ -1,4 +1,4 @@ -namespace ProjectDiff.Core; +namespace ProjectDiff.Core; public enum ProjectDiffExecutionStatus { @@ -8,4 +8,4 @@ public enum ProjectDiffExecutionStatus BaseCommitNotFound, HeadCommitNotFound, MergeBaseNotFound, -} \ No newline at end of file +} diff --git a/src/ProjectDiff.Core/ProjectDiffExecutor.cs b/src/ProjectDiff.Core/ProjectDiffExecutor.cs index df49d71..03ce569 100644 --- a/src/ProjectDiff.Core/ProjectDiffExecutor.cs +++ b/src/ProjectDiff.Core/ProjectDiffExecutor.cs @@ -1,4 +1,4 @@ -using LibGit2Sharp; +using LibGit2Sharp; using Microsoft.Build.Graph; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; @@ -42,6 +42,10 @@ public async Task GetProjectDiff( _logger.LogDebug("Found repository at '{RepoPath}'", repoPath); using var repo = new Repository(repoPath); + if (repo.Info.IsShallow) + { + _logger.LogWarning("Repository at is shallow, some operations may not work as expected"); + } _logger.LogDebug("Looking up base commit '{BaseCommitRef}'", baseCommitRef); var baseCommit = repo.Lookup(baseCommitRef); @@ -148,7 +152,6 @@ public async Task GetProjectDiff( "Base project graph built with {NumProjects} projects", baseGraph.ProjectNodes.Count ); - _logger.LogDebug("Base project graph construction metrics: {Metrics}", baseGraph.ConstructionMetrics); ProjectGraph headGraph; if (headCommit is null) @@ -173,17 +176,27 @@ public async Task GetProjectDiff( "Head project graph built with {NumProjects} projects", headGraph.ProjectNodes.Count ); - _logger.LogDebug("Head project graph construction metrics: {Metrics}", headGraph.ConstructionMetrics); - var headBuildGraph = BuildGraphFactory.CreateForProjectGraph(headGraph, changedFiles); - var baseBuildGraph = BuildGraphFactory.CreateForProjectGraph(baseGraph, changedFiles); + var headBuildGraph = BuildGraphFactory.CreateForProjectGraph( + headGraph, + repo, + _options.IgnoreChangedFiles + ); + var baseBuildGraph = BuildGraphFactory.CreateForProjectGraph( + baseGraph, + repo, + _options.IgnoreChangedFiles + ); + var projects = BuildGraphDiff.Diff(baseBuildGraph, headBuildGraph, changedFiles, _loggerFactory) + .OrderBy(it => it.ReferencedProjects.Count) + .ThenBy(it => it.Name); return new ProjectDiffResult { Status = ProjectDiffExecutionStatus.Success, ChangedFiles = changedFiles, - Projects = BuildGraphDiff.Diff(baseBuildGraph, headBuildGraph, changedFiles), + Projects = projects, }; bool ShouldIncludeFile(string file) => @@ -208,4 +221,4 @@ private static IEnumerable GetGitModifiedFiles( yield return Path.GetFullPath(change.Path, repository.Info.WorkingDirectory); } } -} \ No newline at end of file +} diff --git a/src/ProjectDiff.Core/ProjectDiffExecutorOptions.cs b/src/ProjectDiff.Core/ProjectDiffExecutorOptions.cs index 5db6879..2d69d9f 100644 --- a/src/ProjectDiff.Core/ProjectDiffExecutorOptions.cs +++ b/src/ProjectDiff.Core/ProjectDiffExecutorOptions.cs @@ -1,7 +1,7 @@ -namespace ProjectDiff.Core; +namespace ProjectDiff.Core; public sealed class ProjectDiffExecutorOptions { public bool FindMergeBase { get; init; } public FileInfo[] IgnoreChangedFiles { get; init; } = []; -} \ No newline at end of file +} diff --git a/src/ProjectDiff.Core/ProjectDiffResult.cs b/src/ProjectDiff.Core/ProjectDiffResult.cs index 3cf5012..55c225d 100644 --- a/src/ProjectDiff.Core/ProjectDiffResult.cs +++ b/src/ProjectDiff.Core/ProjectDiffResult.cs @@ -1,8 +1,8 @@ -namespace ProjectDiff.Core; +namespace ProjectDiff.Core; public sealed record ProjectDiffResult { public required ProjectDiffExecutionStatus Status { get; init; } public IEnumerable Projects { get; init; } = []; public IReadOnlyCollection ChangedFiles { get; init; } = []; -} \ No newline at end of file +} diff --git a/src/ProjectDiff.Core/ProjectGraphFactory.cs b/src/ProjectDiff.Core/ProjectGraphFactory.cs index cd89ed4..90747ef 100644 --- a/src/ProjectDiff.Core/ProjectGraphFactory.cs +++ b/src/ProjectDiff.Core/ProjectGraphFactory.cs @@ -1,4 +1,4 @@ -using LibGit2Sharp; +using LibGit2Sharp; using Microsoft.Build.Definition; using Microsoft.Build.Evaluation; using Microsoft.Build.Evaluation.Context; @@ -104,4 +104,4 @@ public async Task BuildForWorkingDirectory( private sealed class DefaultFileSystem : MSBuildFileSystemBase; -} \ No newline at end of file +} diff --git a/src/dotnet-proj-diff/IConsole.cs b/src/dotnet-proj-diff/IConsole.cs index 2ca407a..3b8f2e8 100644 --- a/src/dotnet-proj-diff/IConsole.cs +++ b/src/dotnet-proj-diff/IConsole.cs @@ -1,4 +1,4 @@ -namespace ProjectDiff.Tool; +namespace ProjectDiff.Tool; public interface IConsole { @@ -7,4 +7,4 @@ public interface IConsole Stream OpenStandardOutput(); string WorkingDirectory { get; } -} \ No newline at end of file +} diff --git a/src/dotnet-proj-diff/Output.cs b/src/dotnet-proj-diff/Output.cs index a30b585..bcf1039 100644 --- a/src/dotnet-proj-diff/Output.cs +++ b/src/dotnet-proj-diff/Output.cs @@ -1,4 +1,4 @@ -namespace ProjectDiff.Tool; +namespace ProjectDiff.Tool; public sealed class Output(FileInfo? outputFile, IConsole console) { @@ -11,4 +11,4 @@ public Stream Open() public string NormalizePath(string path, bool absolutePaths) => absolutePaths ? path.Replace('\\', '/') : Path.GetRelativePath(RootDirectory, path).Replace('\\', '/'); -} \ No newline at end of file +} diff --git a/src/dotnet-proj-diff/OutputFormat.cs b/src/dotnet-proj-diff/OutputFormat.cs index 0abce81..960dfc6 100644 --- a/src/dotnet-proj-diff/OutputFormat.cs +++ b/src/dotnet-proj-diff/OutputFormat.cs @@ -1,4 +1,4 @@ -namespace ProjectDiff.Tool; +namespace ProjectDiff.Tool; public enum OutputFormat { @@ -6,4 +6,4 @@ public enum OutputFormat Json = 1, Slnf = 2, Traversal = 3, -} \ No newline at end of file +} diff --git a/src/dotnet-proj-diff/OutputFormatters/IOutputFormatter.cs b/src/dotnet-proj-diff/OutputFormatters/IOutputFormatter.cs index 525c91f..a76529e 100644 --- a/src/dotnet-proj-diff/OutputFormatters/IOutputFormatter.cs +++ b/src/dotnet-proj-diff/OutputFormatters/IOutputFormatter.cs @@ -1,4 +1,4 @@ -using ProjectDiff.Core; +using ProjectDiff.Core; namespace ProjectDiff.Tool.OutputFormatters; @@ -9,4 +9,4 @@ Task WriteAsync( Output output, CancellationToken cancellationToken = default ); -} \ No newline at end of file +} diff --git a/src/dotnet-proj-diff/OutputFormatters/JsonOutputFormatter.cs b/src/dotnet-proj-diff/OutputFormatters/JsonOutputFormatter.cs index 85acae2..33e8913 100644 --- a/src/dotnet-proj-diff/OutputFormatters/JsonOutputFormatter.cs +++ b/src/dotnet-proj-diff/OutputFormatters/JsonOutputFormatter.cs @@ -1,4 +1,4 @@ -using System.Text.Json; +using System.Text.Json; using ProjectDiff.Core; namespace ProjectDiff.Tool.OutputFormatters; @@ -21,21 +21,21 @@ public async Task WriteAsync( ) { projects = projects.Select(project => project with - { - Path = output.NormalizePath( + { + Path = output.NormalizePath( project.Path, _absolutePaths ), - ReferencedProjects = project.ReferencedProjects + ReferencedProjects = project.ReferencedProjects .Select(refProject => output.NormalizePath( refProject, _absolutePaths ) ).ToList() - } + } ); await using var stream = output.Open(); await JsonSerializer.SerializeAsync(stream, projects, _options, cancellationToken); } -} \ No newline at end of file +} diff --git a/src/dotnet-proj-diff/OutputFormatters/PlainOutputFormatter.cs b/src/dotnet-proj-diff/OutputFormatters/PlainOutputFormatter.cs index f31368a..bfaf069 100644 --- a/src/dotnet-proj-diff/OutputFormatters/PlainOutputFormatter.cs +++ b/src/dotnet-proj-diff/OutputFormatters/PlainOutputFormatter.cs @@ -1,4 +1,4 @@ -using ProjectDiff.Core; +using ProjectDiff.Core; namespace ProjectDiff.Tool.OutputFormatters; @@ -28,4 +28,4 @@ public async Task WriteAsync( await writer.WriteLineAsync(path); } } -} \ No newline at end of file +} diff --git a/src/dotnet-proj-diff/OutputFormatters/SlnfOutputFormatter.cs b/src/dotnet-proj-diff/OutputFormatters/SlnfOutputFormatter.cs index 0992f9d..370fdc1 100644 --- a/src/dotnet-proj-diff/OutputFormatters/SlnfOutputFormatter.cs +++ b/src/dotnet-proj-diff/OutputFormatters/SlnfOutputFormatter.cs @@ -1,4 +1,4 @@ -using System.Text.Json; +using System.Text.Json; using System.Text.Json.Nodes; using ProjectDiff.Core; @@ -47,4 +47,4 @@ public async Task WriteAsync( await using var stream = output.Open(); await JsonSerializer.SerializeAsync(stream, root, _options, cancellationToken); } -} \ No newline at end of file +} diff --git a/src/dotnet-proj-diff/OutputFormatters/TraversalOutputFormatter.cs b/src/dotnet-proj-diff/OutputFormatters/TraversalOutputFormatter.cs index 696322a..e18c2a9 100644 --- a/src/dotnet-proj-diff/OutputFormatters/TraversalOutputFormatter.cs +++ b/src/dotnet-proj-diff/OutputFormatters/TraversalOutputFormatter.cs @@ -1,4 +1,4 @@ -using Microsoft.Build.Construction; +using Microsoft.Build.Construction; using Microsoft.Build.Evaluation; using ProjectDiff.Core; @@ -39,4 +39,4 @@ public async Task WriteAsync( await using var writer = new StreamWriter(stream); element.Save(writer); } -} \ No newline at end of file +} diff --git a/src/dotnet-proj-diff/Program.cs b/src/dotnet-proj-diff/Program.cs index 9d1eb17..9513a67 100644 --- a/src/dotnet-proj-diff/Program.cs +++ b/src/dotnet-proj-diff/Program.cs @@ -1,8 +1,8 @@ -using Microsoft.Build.Locator; +using Microsoft.Build.Locator; using ProjectDiff.Tool; MSBuildLocator.RegisterDefaults(); var tool = ProjectDiffTool.BuildCli(new SystemConsole()); -return await tool.InvokeAsync(args); \ No newline at end of file +return await tool.InvokeAsync(args); diff --git a/src/dotnet-proj-diff/ProjectDiffCommand.cs b/src/dotnet-proj-diff/ProjectDiffCommand.cs index b49d7ee..f379349 100644 --- a/src/dotnet-proj-diff/ProjectDiffCommand.cs +++ b/src/dotnet-proj-diff/ProjectDiffCommand.cs @@ -1,4 +1,4 @@ -using System.CommandLine; +using System.CommandLine; using System.Text.Json; using System.Text.Json.Serialization; using Microsoft.Extensions.Logging; @@ -119,7 +119,7 @@ public sealed class ProjectDiffCommand : RootCommand private static readonly Option LogLevelOption = new("--log-level") { - DefaultValueFactory = _ => LogLevel.Information, + DefaultValueFactory = _ => LogLevel.Warning, Description = "Set the log level for the command", }; @@ -183,6 +183,7 @@ CancellationToken cancellationToken using var loggerFactory = LoggerFactory.Create(x => { x.AddConsole(c => c.LogToStandardErrorThreshold = LogLevel.Trace); // Log everything to stderr + x.AddSimpleConsole(x => x.IncludeScopes = true); x.SetMinimumLevel(settings.LogLevel); } ); @@ -246,8 +247,6 @@ CancellationToken cancellationToken var projects = result.Projects .Where(ShouldInclude) - .OrderBy(it => it.ReferencedProjects.Count) - .ThenBy(it => it.Path) .ToList(); logger.LogInformation("Found {Count} projects in diff", projects.Count); @@ -256,7 +255,7 @@ CancellationToken cancellationToken logger.LogDebug( "Diff projects: {Projects}", projects.Select(it => new - { it.Path, it.Status, ReferencedProjects = string.Join(',', it.ReferencedProjects) } + { it.Path, it.Status, ReferencedProjects = string.Join(',', it.ReferencedProjects) } ) ); } @@ -306,4 +305,4 @@ bool ShouldInclude(DiffProject project) => ".json" => OutputFormat.Json, _ => OutputFormat.Plain }; -} \ No newline at end of file +} diff --git a/src/dotnet-proj-diff/ProjectDiffSettings.cs b/src/dotnet-proj-diff/ProjectDiffSettings.cs index 5e35687..5f98dc7 100644 --- a/src/dotnet-proj-diff/ProjectDiffSettings.cs +++ b/src/dotnet-proj-diff/ProjectDiffSettings.cs @@ -1,4 +1,4 @@ -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; namespace ProjectDiff.Tool; @@ -18,4 +18,4 @@ public sealed class ProjectDiffSettings public required FileInfo[] IgnoreChangedFile { get; init; } = []; public string? MicrosoftBuildTraversalVersion { get; init; } public LogLevel LogLevel { get; init; } = LogLevel.Information; -} \ No newline at end of file +} diff --git a/src/dotnet-proj-diff/ProjectDiffTool.cs b/src/dotnet-proj-diff/ProjectDiffTool.cs index 9b5a40f..03ba845 100644 --- a/src/dotnet-proj-diff/ProjectDiffTool.cs +++ b/src/dotnet-proj-diff/ProjectDiffTool.cs @@ -1,4 +1,4 @@ -using System.CommandLine; +using System.CommandLine; namespace ProjectDiff.Tool; @@ -12,4 +12,4 @@ public static CommandLineConfiguration BuildCli(IConsole console) Output = console.Out, }; } -} \ No newline at end of file +} diff --git a/src/dotnet-proj-diff/SystemConsole.cs b/src/dotnet-proj-diff/SystemConsole.cs index 674b9fb..34c9792 100644 --- a/src/dotnet-proj-diff/SystemConsole.cs +++ b/src/dotnet-proj-diff/SystemConsole.cs @@ -1,4 +1,4 @@ -namespace ProjectDiff.Tool; +namespace ProjectDiff.Tool; public sealed class SystemConsole : IConsole { @@ -6,6 +6,5 @@ public sealed class SystemConsole : IConsole public TextWriter Out { get; } = Console.Out; public Stream OpenStandardOutput() => Console.OpenStandardOutput(); - public string WorkingDirectory { get; } = Directory.GetCurrentDirectory(); -} \ No newline at end of file +} diff --git a/test/ProjectDiff.Tests/Core/BranchTests.cs b/test/ProjectDiff.Tests/Core/BranchTests.cs index 9f46a75..4e7e29e 100644 --- a/test/ProjectDiff.Tests/Core/BranchTests.cs +++ b/test/ProjectDiff.Tests/Core/BranchTests.cs @@ -1,4 +1,4 @@ -using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Logging.Abstractions; using ProjectDiff.Core; using ProjectDiff.Core.Entrypoints; using ProjectDiff.Tests.Utils; @@ -182,4 +182,4 @@ public async Task ModifyProjectInBaseBranch_WithMergeBaseOption() Assert.Equal(ProjectDiffExecutionStatus.Success, result.Status); Assert.Empty(result.Projects); } -} \ No newline at end of file +} diff --git a/test/ProjectDiff.Tests/Core/BuildGraphDiffTests.cs b/test/ProjectDiff.Tests/Core/BuildGraphDiffTests.cs index a2ff20f..8fcb2b7 100644 --- a/test/ProjectDiff.Tests/Core/BuildGraphDiffTests.cs +++ b/test/ProjectDiff.Tests/Core/BuildGraphDiffTests.cs @@ -1,4 +1,4 @@ -using ProjectDiff.Core; +using ProjectDiff.Core; namespace ProjectDiff.Tests.Core; @@ -203,7 +203,7 @@ public void ReturnsProjectWhenInputFileIsAdded() Assert.Equal("/path/to/project1.csproj", project.Path); Assert.Equal(DiffStatus.Modified, project.Status); } - + [Fact] public void ReturnsProjectWhenInputFileIsRemoved() { @@ -220,7 +220,7 @@ public void ReturnsProjectWhenInputFileIsRemoved() Assert.Equal("/path/to/project1.csproj", project.Path); Assert.Equal(DiffStatus.Modified, project.Status); } - + [Fact] public void ReturnsProjectWhenInputFileIsChangedButNotModified() { @@ -237,7 +237,7 @@ public void ReturnsProjectWhenInputFileIsChangedButNotModified() Assert.Equal("/path/to/project1.csproj", project.Path); Assert.Equal(DiffStatus.Modified, project.Status); } - + [Fact] public void ReturnsProjectWhenReferenceIsChangedButNotModified() { @@ -254,4 +254,4 @@ public void ReturnsProjectWhenReferenceIsChangedButNotModified() Assert.Equal("/path/to/project1.csproj", project.Path); Assert.Equal(DiffStatus.ReferenceChanged, project.Status); } -} \ No newline at end of file +} diff --git a/test/ProjectDiff.Tests/Core/DirectoryBuildPropsTests.cs b/test/ProjectDiff.Tests/Core/DirectoryBuildPropsTests.cs index d37e9e2..905ff18 100644 --- a/test/ProjectDiff.Tests/Core/DirectoryBuildPropsTests.cs +++ b/test/ProjectDiff.Tests/Core/DirectoryBuildPropsTests.cs @@ -1,4 +1,4 @@ -using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Logging.Abstractions; using ProjectDiff.Core; using ProjectDiff.Core.Entrypoints; using ProjectDiff.Tests.Utils; @@ -217,4 +217,4 @@ private static Task GetProjectDiff(TestRepository repo) cancellationToken: TestContext.Current.CancellationToken ); } -} \ No newline at end of file +} diff --git a/test/ProjectDiff.Tests/Core/ErrorTests.cs b/test/ProjectDiff.Tests/Core/ErrorTests.cs index ca5e33a..1a66b8c 100644 --- a/test/ProjectDiff.Tests/Core/ErrorTests.cs +++ b/test/ProjectDiff.Tests/Core/ErrorTests.cs @@ -1,4 +1,4 @@ -using Microsoft.Build.FileSystem; +using Microsoft.Build.FileSystem; using Microsoft.Build.Graph; using ProjectDiff.Core; using ProjectDiff.Core.Entrypoints; @@ -77,4 +77,4 @@ CancellationToken cancellationToken return Task.FromResult(Enumerable.Empty()); } } -} \ No newline at end of file +} diff --git a/test/ProjectDiff.Tests/Core/GitTreeFileSystemTests.cs b/test/ProjectDiff.Tests/Core/GitTreeFileSystemTests.cs index b29212c..f039aad 100644 --- a/test/ProjectDiff.Tests/Core/GitTreeFileSystemTests.cs +++ b/test/ProjectDiff.Tests/Core/GitTreeFileSystemTests.cs @@ -1,4 +1,4 @@ -using System.Text; +using System.Text; using Microsoft.Build.Evaluation; using Microsoft.Extensions.Logging.Abstractions; using ProjectDiff.Core; @@ -504,4 +504,4 @@ public async Task EnumerateFiles_InSubdirectoryWithSearchOptionAllDirectoriesRet Assert.Equivalent(expectedFiles, files); } -} \ No newline at end of file +} diff --git a/test/ProjectDiff.Tests/Core/IgnoreChangesTests.cs b/test/ProjectDiff.Tests/Core/IgnoreChangesTests.cs index 6ae5a17..5c1ec53 100644 --- a/test/ProjectDiff.Tests/Core/IgnoreChangesTests.cs +++ b/test/ProjectDiff.Tests/Core/IgnoreChangesTests.cs @@ -1,4 +1,4 @@ -using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Logging.Abstractions; using ProjectDiff.Core; using ProjectDiff.Core.Entrypoints; using ProjectDiff.Tests.Utils; @@ -103,4 +103,4 @@ public async Task IgnoresDeletedFiles() Assert.Empty(diff.Projects); } -} \ No newline at end of file +} diff --git a/test/ProjectDiff.Tests/Core/MoveFileTests.cs b/test/ProjectDiff.Tests/Core/MoveFileTests.cs new file mode 100644 index 0000000..899403c --- /dev/null +++ b/test/ProjectDiff.Tests/Core/MoveFileTests.cs @@ -0,0 +1,143 @@ +using LibGit2Sharp; +using ProjectDiff.Core; +using ProjectDiff.Core.Entrypoints; +using ProjectDiff.Tests.Utils; + +namespace ProjectDiff.Tests.Core; + +public sealed class MoveFileTests +{ + [Fact] + public async Task MoveFileToReferencedProject() + { + using var repo = await TestRepository.SetupAsync(async r => + { + r.CreateDirectory("ProjectA"); + r.CreateProject("ProjectA/ProjectA.csproj"); + + r.CreateDirectory("ProjectB"); + r.CreateProject( + "ProjectB/ProjectB.csproj", + p => p.AddItem("ProjectReference", "../ProjectA/ProjectA.csproj") + ); + + await r.WriteAllTextAsync("ProjectB/FileA.cs", "File A content"); + } + ); + Commands.Move( + repo.Repository, + "ProjectB/FileA.cs", + "ProjectA/FileA.cs" + ); + var projects = await GetDiffProjects(repo); + + Assert.Collection( + projects, + p => + { + Assert.Equal("ProjectA", p.Name); + Assert.Equal(DiffStatus.Modified, p.Status); + }, + p => + { + Assert.Equal("ProjectB", p.Name); + Assert.Equal(DiffStatus.Modified, p.Status); + } + ); + } + + [Fact] + public async Task MoveFileFromReferencedProjects() + { + using var repo = await TestRepository.SetupAsync(async r => + { + r.CreateDirectory("ProjectA"); + r.CreateProject("ProjectA/ProjectA.csproj"); + await r.WriteAllTextAsync("ProjectA/FileA.cs", "File A content"); + + r.CreateDirectory("ProjectB"); + r.CreateProject( + "ProjectB/ProjectB.csproj", + p => p.AddItem("ProjectReference", "../ProjectA/ProjectA.csproj") + ); + } + ); + Commands.Move( + repo.Repository, + "ProjectA/FileA.cs", + "ProjectB/FileA.cs" + ); + var projects = await GetDiffProjects(repo); + + Assert.Collection( + projects, + p => + { + Assert.Equal("ProjectA", p.Name); + Assert.Equal(DiffStatus.Modified, p.Status); + }, + p => + { + Assert.Equal("ProjectB", p.Name); + Assert.Equal(DiffStatus.Modified, p.Status); + } + ); + } + + + [Fact] + public async Task MovingFileBetweenTwoUnreleatedProjects() + { + using var repo = await TestRepository.SetupAsync(async r => + { + r.CreateDirectory("ProjectA"); + r.CreateProject("ProjectA/ProjectA.csproj"); + await r.WriteAllTextAsync("ProjectA/FileA.cs", "File A content"); + + r.CreateDirectory("ProjectB"); + r.CreateProject("ProjectB/ProjectB.csproj"); + } + ); + + Commands.Move( + repo.Repository, + "ProjectA/FileA.cs", + "ProjectB/FileA.cs" + ); + var projects = await GetDiffProjects(repo); + Assert.Collection( + projects, + p => + { + Assert.Equal("ProjectA", p.Name); + Assert.Equal(DiffStatus.Modified, p.Status); + }, + p => + { + Assert.Equal("ProjectB", p.Name); + Assert.Equal(DiffStatus.Modified, p.Status); + } + ); + } + + private static async Task> GetDiffProjects(TestRepository repo) + { + var options = new ProjectDiffExecutorOptions + { + FindMergeBase = false, + IgnoreChangedFiles = [] + }; + + + var executor = new ProjectDiffExecutor(options); + var result = await executor.GetProjectDiff( + repo.WorkingDirectory, + new DirectoryScanEntrypointProvider(), + cancellationToken: TestContext.Current.CancellationToken + ); + + Assert.Equal(ProjectDiffExecutionStatus.Success, result.Status); + + return result.Projects; + } +} diff --git a/test/ProjectDiff.Tests/Core/MultiFrameworkTests.cs b/test/ProjectDiff.Tests/Core/MultiFrameworkTests.cs index 797e3ec..16b3e99 100644 --- a/test/ProjectDiff.Tests/Core/MultiFrameworkTests.cs +++ b/test/ProjectDiff.Tests/Core/MultiFrameworkTests.cs @@ -1,4 +1,4 @@ -using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Logging.Abstractions; using ProjectDiff.Core; using ProjectDiff.Core.Entrypoints; using ProjectDiff.Tests.Utils; @@ -40,4 +40,4 @@ public static async Task FileModifiedInMultiFrameworkProjectOnlyReturnsASinglePr Assert.Equal(DiffStatus.Modified, proj.Status); Assert.Equal(project, proj.Path); } -} \ No newline at end of file +} diff --git a/test/ProjectDiff.Tests/ModuleInit.cs b/test/ProjectDiff.Tests/ModuleInit.cs index e54c8c8..da72a37 100644 --- a/test/ProjectDiff.Tests/ModuleInit.cs +++ b/test/ProjectDiff.Tests/ModuleInit.cs @@ -1,4 +1,4 @@ -using System.Runtime.CompilerServices; +using System.Runtime.CompilerServices; using Microsoft.Build.Locator; namespace ProjectDiff.Tests; @@ -10,4 +10,4 @@ public static void Run() { MSBuildLocator.RegisterDefaults(); } -} \ No newline at end of file +} diff --git a/test/ProjectDiff.Tests/Tool/OutputFormatters/JsonOutputFormatterTests.WriteAsync_OutputsJson_absolutePaths=False.verified.txt b/test/ProjectDiff.Tests/Tool/OutputFormatters/JsonOutputFormatterTests.WriteAsync_OutputsJson_absolutePaths=False.verified.txt index e9c28a2..5c32d5b 100644 --- a/test/ProjectDiff.Tests/Tool/OutputFormatters/JsonOutputFormatterTests.WriteAsync_OutputsJson_absolutePaths=False.verified.txt +++ b/test/ProjectDiff.Tests/Tool/OutputFormatters/JsonOutputFormatterTests.WriteAsync_OutputsJson_absolutePaths=False.verified.txt @@ -1,10 +1,12 @@ [ { path: ProjectA, + name: ProjectA, status: Added }, { path: ProjectB, + name: ProjectB, status: ReferenceChanged, referencedProjects: [ ProjectA diff --git a/test/ProjectDiff.Tests/Tool/OutputFormatters/JsonOutputFormatterTests.WriteAsync_OutputsJson_absolutePaths=True.verified.txt b/test/ProjectDiff.Tests/Tool/OutputFormatters/JsonOutputFormatterTests.WriteAsync_OutputsJson_absolutePaths=True.verified.txt index b90471c..1a058c3 100644 --- a/test/ProjectDiff.Tests/Tool/OutputFormatters/JsonOutputFormatterTests.WriteAsync_OutputsJson_absolutePaths=True.verified.txt +++ b/test/ProjectDiff.Tests/Tool/OutputFormatters/JsonOutputFormatterTests.WriteAsync_OutputsJson_absolutePaths=True.verified.txt @@ -1,10 +1,12 @@ [ { path: {TempPath}ProjectA, + name: ProjectA, status: Added }, { path: {TempPath}ProjectB, + name: ProjectB, status: ReferenceChanged, referencedProjects: [ {TempPath}ProjectA diff --git a/test/ProjectDiff.Tests/Tool/OutputFormatters/JsonOutputFormatterTests.cs b/test/ProjectDiff.Tests/Tool/OutputFormatters/JsonOutputFormatterTests.cs index 82fcb51..33a4ec1 100644 --- a/test/ProjectDiff.Tests/Tool/OutputFormatters/JsonOutputFormatterTests.cs +++ b/test/ProjectDiff.Tests/Tool/OutputFormatters/JsonOutputFormatterTests.cs @@ -1,4 +1,4 @@ -using ProjectDiff.Core; +using ProjectDiff.Core; using ProjectDiff.Tests.Utils; using ProjectDiff.Tool; using ProjectDiff.Tool.OutputFormatters; @@ -41,4 +41,4 @@ public async Task WriteAsync_OutputsJson(bool absolutePaths) await VerifyJson(console.GetStandardOutput()) .UseParameters(absolutePaths); } -} \ No newline at end of file +} diff --git a/test/ProjectDiff.Tests/Tool/OutputFormatters/PlainOutputFormatterTests.cs b/test/ProjectDiff.Tests/Tool/OutputFormatters/PlainOutputFormatterTests.cs index fdb6044..3c70326 100644 --- a/test/ProjectDiff.Tests/Tool/OutputFormatters/PlainOutputFormatterTests.cs +++ b/test/ProjectDiff.Tests/Tool/OutputFormatters/PlainOutputFormatterTests.cs @@ -1,4 +1,4 @@ -using ProjectDiff.Core; +using ProjectDiff.Core; using ProjectDiff.Tests.Utils; using ProjectDiff.Tool; using ProjectDiff.Tool.OutputFormatters; @@ -40,4 +40,4 @@ public async Task WriteAsync_OutputsPlainText(bool absolutePaths) await Verify(console.GetStandardOutput()) .UseParameters(absolutePaths); } -} \ No newline at end of file +} diff --git a/test/ProjectDiff.Tests/Tool/OutputFormatters/SlnfOutputFormatterTests.cs b/test/ProjectDiff.Tests/Tool/OutputFormatters/SlnfOutputFormatterTests.cs index 37c6a84..4389a97 100644 --- a/test/ProjectDiff.Tests/Tool/OutputFormatters/SlnfOutputFormatterTests.cs +++ b/test/ProjectDiff.Tests/Tool/OutputFormatters/SlnfOutputFormatterTests.cs @@ -1,4 +1,4 @@ -using ProjectDiff.Core; +using ProjectDiff.Core; using ProjectDiff.Tests.Utils; using ProjectDiff.Tool; using ProjectDiff.Tool.OutputFormatters; @@ -39,7 +39,7 @@ public async Task WriteAsync_WritesSlnfFiles() sln, ProjectDiffCommand.JsonSerializerOptions ); - + await formatter.WriteAsync( projects, output, @@ -48,4 +48,4 @@ await formatter.WriteAsync( await VerifyJson(console.GetStandardOutput()); } -} \ No newline at end of file +} diff --git a/test/ProjectDiff.Tests/Tool/OutputFormatters/TraversalOutputFormatterTests.cs b/test/ProjectDiff.Tests/Tool/OutputFormatters/TraversalOutputFormatterTests.cs index 5c1f69a..df0577c 100644 --- a/test/ProjectDiff.Tests/Tool/OutputFormatters/TraversalOutputFormatterTests.cs +++ b/test/ProjectDiff.Tests/Tool/OutputFormatters/TraversalOutputFormatterTests.cs @@ -1,4 +1,4 @@ -using ProjectDiff.Core; +using ProjectDiff.Core; using ProjectDiff.Tests.Utils; using ProjectDiff.Tool; using ProjectDiff.Tool.OutputFormatters; @@ -48,4 +48,4 @@ public async Task WriteAsync_ShouldWriteTraversalOutput(string? traversalVersion await VerifyXml(console.GetStandardOutput()) .UseParameters(traversalVersion, absolutePaths); } -} \ No newline at end of file +} diff --git a/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsAddedFiles.verified.txt b/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsAddedFiles.verified.txt index 4362c65..619a1e6 100644 --- a/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsAddedFiles.verified.txt +++ b/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsAddedFiles.verified.txt @@ -1,6 +1,7 @@ [ { path: Sample/Sample.csproj, + name: Sample, status: Modified } ] \ No newline at end of file diff --git a/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsAddedProjects.verified.txt b/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsAddedProjects.verified.txt index ccc0ca6..dd6492a 100644 --- a/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsAddedProjects.verified.txt +++ b/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsAddedProjects.verified.txt @@ -1,6 +1,7 @@ [ { path: Added/Added.csproj, + name: Added, status: Added } ] \ No newline at end of file diff --git a/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsAddedProjectsWithDirectoryScan.verified.txt b/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsAddedProjectsWithDirectoryScan.verified.txt index ccc0ca6..dd6492a 100644 --- a/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsAddedProjectsWithDirectoryScan.verified.txt +++ b/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsAddedProjectsWithDirectoryScan.verified.txt @@ -1,6 +1,7 @@ [ { path: Added/Added.csproj, + name: Added, status: Added } ] \ No newline at end of file diff --git a/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsChangesInNestedReferencedProjects.verified.txt b/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsChangesInNestedReferencedProjects.verified.txt index ca07d4f..edf7b6a 100644 --- a/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsChangesInNestedReferencedProjects.verified.txt +++ b/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsChangesInNestedReferencedProjects.verified.txt @@ -1,10 +1,12 @@ [ { path: Sample/Sample.csproj, + name: Sample, status: Modified }, { path: Application/Application.csproj, + name: Application, status: ReferenceChanged, referencedProjects: [ Sample/Sample.csproj @@ -12,6 +14,7 @@ }, { path: Tests/Tests.csproj, + name: Tests, status: ReferenceChanged, referencedProjects: [ Application/Application.csproj, diff --git a/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsChangesInReferencedProjects.verified.txt b/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsChangesInReferencedProjects.verified.txt index d17975d..bb01156 100644 --- a/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsChangesInReferencedProjects.verified.txt +++ b/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsChangesInReferencedProjects.verified.txt @@ -1,10 +1,12 @@ [ { path: Sample/Sample.csproj, + name: Sample, status: Modified }, { path: Tests/Tests.csproj, + name: Tests, status: ReferenceChanged, referencedProjects: [ Sample/Sample.csproj diff --git a/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsDeletedFiles.verified.txt b/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsDeletedFiles.verified.txt index 4362c65..619a1e6 100644 --- a/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsDeletedFiles.verified.txt +++ b/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsDeletedFiles.verified.txt @@ -1,6 +1,7 @@ [ { path: Sample/Sample.csproj, + name: Sample, status: Modified } ] \ No newline at end of file diff --git a/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsDeletedProjectsWhenOptionIsSet.verified.txt b/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsDeletedProjectsWhenOptionIsSet.verified.txt index fe7bd9a..cdbabb4 100644 --- a/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsDeletedProjectsWhenOptionIsSet.verified.txt +++ b/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsDeletedProjectsWhenOptionIsSet.verified.txt @@ -1,6 +1,7 @@ [ { path: Tests/Tests.csproj, + name: Tests, status: Removed } ] \ No newline at end of file diff --git a/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsModifiedFiles.verified.txt b/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsModifiedFiles.verified.txt index 4362c65..619a1e6 100644 --- a/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsModifiedFiles.verified.txt +++ b/test/ProjectDiff.Tests/Tool/ProjectDiffTests.DetectsModifiedFiles.verified.txt @@ -1,6 +1,7 @@ [ { path: Sample/Sample.csproj, + name: Sample, status: Modified } ] \ No newline at end of file diff --git a/test/ProjectDiff.Tests/Tool/ProjectDiffTests.cs b/test/ProjectDiff.Tests/Tool/ProjectDiffTests.cs index 9775c3e..d35aaa8 100644 --- a/test/ProjectDiff.Tests/Tool/ProjectDiffTests.cs +++ b/test/ProjectDiff.Tests/Tool/ProjectDiffTests.cs @@ -1,4 +1,4 @@ -using ProjectDiff.Tests.Utils; +using ProjectDiff.Tests.Utils; using ProjectDiff.Tool; namespace ProjectDiff.Tests.Tool; @@ -306,7 +306,7 @@ params string[] args var console = new TestConsole(repository.WorkingDirectory); var cli = ProjectDiffTool.BuildCli(console); - var exitCode = await cli.InvokeAsync([..args, ..defaultArgs]); + var exitCode = await cli.InvokeAsync([.. args, .. defaultArgs]); if (exitCode != 0) { var stderr = console.GetStandardError(); @@ -315,4 +315,4 @@ params string[] args return console.GetStandardOutput(); } -} \ No newline at end of file +} diff --git a/test/ProjectDiff.Tests/Utils/SetupResult.cs b/test/ProjectDiff.Tests/Utils/SetupResult.cs index 87d6f92..1f4e112 100644 --- a/test/ProjectDiff.Tests/Utils/SetupResult.cs +++ b/test/ProjectDiff.Tests/Utils/SetupResult.cs @@ -1,4 +1,4 @@ -namespace ProjectDiff.Tests.Utils; +namespace ProjectDiff.Tests.Utils; public sealed class SetupResult : IDisposable { @@ -21,4 +21,4 @@ public void Dispose() { Repository.Dispose(); } -} \ No newline at end of file +} diff --git a/test/ProjectDiff.Tests/Utils/TestConsole.cs b/test/ProjectDiff.Tests/Utils/TestConsole.cs index 5d33d07..8acf04f 100644 --- a/test/ProjectDiff.Tests/Utils/TestConsole.cs +++ b/test/ProjectDiff.Tests/Utils/TestConsole.cs @@ -1,4 +1,4 @@ -using System.IO.Pipelines; +using System.IO.Pipelines; using ProjectDiff.Tool; namespace ProjectDiff.Tests.Utils; @@ -44,4 +44,4 @@ public Stream OpenStandardOutput() return writer.AsStream(leaveOpen: true); } -} \ No newline at end of file +} diff --git a/test/ProjectDiff.Tests/Utils/TestRepository.cs b/test/ProjectDiff.Tests/Utils/TestRepository.cs index b739ffc..cd411a5 100644 --- a/test/ProjectDiff.Tests/Utils/TestRepository.cs +++ b/test/ProjectDiff.Tests/Utils/TestRepository.cs @@ -1,4 +1,4 @@ -using LibGit2Sharp; +using LibGit2Sharp; using Microsoft.Build.Construction; using Microsoft.VisualStudio.SolutionPersistence.Model; using Microsoft.VisualStudio.SolutionPersistence.Serializer; @@ -65,7 +65,7 @@ public Task WriteAllTextAsync(string file, string content) public string GetPath(params string[] parts) { - return Path.Join([WorkingDirectory, ..parts]); + return Path.Join([WorkingDirectory, .. parts]); } public string GetPath(string relativePath) @@ -198,4 +198,4 @@ public void UpdateProject(string path, Action configure) configure(root); root.Save(p); } -} \ No newline at end of file +} diff --git a/test/ProjectDiff.Tests/VerifyTests.cs b/test/ProjectDiff.Tests/VerifyTests.cs index feed9a3..373be9a 100644 --- a/test/ProjectDiff.Tests/VerifyTests.cs +++ b/test/ProjectDiff.Tests/VerifyTests.cs @@ -1,4 +1,4 @@ -namespace ProjectDiff.Tests; +namespace ProjectDiff.Tests; public sealed class VerifyTests { @@ -7,5 +7,5 @@ public async Task VerifyIsSetupCorrectly() { await VerifyChecks.Run(); } - -} \ No newline at end of file + +}