diff --git a/src/LeanCode.ContractsGenerator/AnalyzeFailedException.cs b/src/LeanCode.ContractsGenerator/AnalyzeFailedException.cs index cf05834..6e11b55 100644 --- a/src/LeanCode.ContractsGenerator/AnalyzeFailedException.cs +++ b/src/LeanCode.ContractsGenerator/AnalyzeFailedException.cs @@ -5,7 +5,7 @@ public class AnalyzeFailedException : Exception public IReadOnlyList Errors { get; } public AnalyzeFailedException(IReadOnlyList errors) - : base("Analyze phase failed.") + : base(string.Join('\n', errors.Select(e => e.ToString()).Prepend("Analyze phase failed."))) { Errors = errors; } diff --git a/src/LeanCode.ContractsGenerator/Analyzers/AllAnalyzers.cs b/src/LeanCode.ContractsGenerator/Analyzers/AllAnalyzers.cs index 406a9d5..ea0e0ac 100644 --- a/src/LeanCode.ContractsGenerator/Analyzers/AllAnalyzers.cs +++ b/src/LeanCode.ContractsGenerator/Analyzers/AllAnalyzers.cs @@ -2,7 +2,7 @@ namespace LeanCode.ContractsGenerator.Analyzers; public class AllAnalyzers : IAnalyzer { - private static readonly IReadOnlyList Analyzers = new IAnalyzer[] + private readonly IReadOnlyList analyzers = new IAnalyzer[] { new InternalStructureCheck(), new KnownTypeCheck(), @@ -13,6 +13,6 @@ public class AllAnalyzers : IAnalyzer public IEnumerable Analyze(Export export) { - return Analyzers.SelectMany(a => a.Analyze(export)); + return analyzers.SelectMany(a => a.Analyze(export)); } } diff --git a/src/LeanCode.ContractsGenerator/Compilation/ProjectLoader.cs b/src/LeanCode.ContractsGenerator/Compilation/ProjectLoader.cs index 129890c..4e3b15c 100644 --- a/src/LeanCode.ContractsGenerator/Compilation/ProjectLoader.cs +++ b/src/LeanCode.ContractsGenerator/Compilation/ProjectLoader.cs @@ -30,8 +30,10 @@ await Console.Error.WriteLineAsync( foreach (var projectPath in projectPathsList) { if (msbuildWorkspace.CurrentSolution.Projects - .Where(p => p.FilePath is not null) - .Any(p => ResolveCanonicalPath(p.FilePath) == projectPath)) + .Select(p => p.FilePath) + .OfType() + .Select(ResolveCanonicalPath) + .Contains(projectPath)) { continue; } diff --git a/src/LeanCode.ContractsGenerator/IAnalyzer.cs b/src/LeanCode.ContractsGenerator/IAnalyzer.cs index c086b7a..6de2a9c 100644 --- a/src/LeanCode.ContractsGenerator/IAnalyzer.cs +++ b/src/LeanCode.ContractsGenerator/IAnalyzer.cs @@ -5,4 +5,7 @@ public interface IAnalyzer IEnumerable Analyze(Export export); } -public record AnalyzeError(string Code, string Message, AnalyzerContext Context); +public record AnalyzeError(string Code, string Message, AnalyzerContext Context) +{ + public override string ToString() => $"{Code}: {Message}\n at {Context.Path}"; +}