From 3e9fc271c5ad7bcf468617b8f71cf8be74f429dd Mon Sep 17 00:00:00 2001 From: Nikolay Pianikov Date: Tue, 2 Jul 2024 20:19:57 +0300 Subject: [PATCH] Fix build --- .../Cmd/IPathResolver.cs | 5 ++- CSharpInteractive.HostApi/CommandLine.cs | 1 - CSharpInteractive.HostApi/CommandLines.cs | 1 + CSharpInteractive.HostApi/IBuildRunner.cs | 10 ++++-- .../ICommandLineRunner.cs | 10 ++++-- CSharpInteractive.HostApi/IProperties.cs | 3 -- CSharpInteractive.HostApi/Output.cs | 6 +++- .../Integration/ScriptRunTests.cs | 4 +-- .../Integration/TeamCityScriptRunTests.cs | 2 +- CSharpInteractive/StatisticsPresenter.cs | 31 ++++++++++--------- Directory.Build.props | 1 - 11 files changed, 46 insertions(+), 28 deletions(-) diff --git a/CSharpInteractive.HostApi/Cmd/IPathResolver.cs b/CSharpInteractive.HostApi/Cmd/IPathResolver.cs index 2b04232a..da9ef8a5 100644 --- a/CSharpInteractive.HostApi/Cmd/IPathResolver.cs +++ b/CSharpInteractive.HostApi/Cmd/IPathResolver.cs @@ -3,5 +3,8 @@ namespace HostApi.Cmd; internal interface IPathResolver { - string Resolve(IHost host, string path, IPathResolver nextResolver); + string Resolve( + IHost host, + string path, + IPathResolver nextResolver); } \ No newline at end of file diff --git a/CSharpInteractive.HostApi/CommandLine.cs b/CSharpInteractive.HostApi/CommandLine.cs index 4639afbd..325b0113 100644 --- a/CSharpInteractive.HostApi/CommandLine.cs +++ b/CSharpInteractive.HostApi/CommandLine.cs @@ -9,7 +9,6 @@ namespace HostApi; /// /// Runs an arbitrary executable with arguments and environment variables from the working directory. /// -[ExcludeFromCodeCoverage] [Target] [DebuggerTypeProxy(typeof(CommandLineDebugView))] public partial record CommandLine( diff --git a/CSharpInteractive.HostApi/CommandLines.cs b/CSharpInteractive.HostApi/CommandLines.cs index 4ad42c51..9d6d65f1 100644 --- a/CSharpInteractive.HostApi/CommandLines.cs +++ b/CSharpInteractive.HostApi/CommandLines.cs @@ -1,6 +1,7 @@ // ReSharper disable InconsistentNaming namespace HostApi; +[ExcludeFromCodeCoverage] public partial record CommandLine: ICommandLine { public static CommandLine operator +(CommandLine command, string arg) => command.AddArgs(arg); diff --git a/CSharpInteractive.HostApi/IBuildRunner.cs b/CSharpInteractive.HostApi/IBuildRunner.cs index 436bd1d9..659a5c3c 100644 --- a/CSharpInteractive.HostApi/IBuildRunner.cs +++ b/CSharpInteractive.HostApi/IBuildRunner.cs @@ -6,7 +6,13 @@ namespace HostApi; public interface IBuildRunner { - IBuildResult Run(ICommandLine commandLine, Action? handler = default, TimeSpan timeout = default); + IBuildResult Run( + ICommandLine commandLine, + Action? handler = default, + TimeSpan timeout = default); - Task RunAsync(ICommandLine commandLine, Action? handler = default, CancellationToken cancellationToken = default); + Task RunAsync( + ICommandLine commandLine, + Action? handler = default, + CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/CSharpInteractive.HostApi/ICommandLineRunner.cs b/CSharpInteractive.HostApi/ICommandLineRunner.cs index 04ae720e..5cd08acc 100644 --- a/CSharpInteractive.HostApi/ICommandLineRunner.cs +++ b/CSharpInteractive.HostApi/ICommandLineRunner.cs @@ -3,7 +3,13 @@ namespace HostApi; public interface ICommandLineRunner { - int? Run(ICommandLine commandLine, Action? handler = default, TimeSpan timeout = default); + int? Run( + ICommandLine commandLine, + Action? handler = default, + TimeSpan timeout = default); - Task RunAsync(ICommandLine commandLine, Action? handler = default, CancellationToken cancellationToken = default); + Task RunAsync( + ICommandLine commandLine, + Action? handler = default, + CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/CSharpInteractive.HostApi/IProperties.cs b/CSharpInteractive.HostApi/IProperties.cs index 80426424..d593a254 100644 --- a/CSharpInteractive.HostApi/IProperties.cs +++ b/CSharpInteractive.HostApi/IProperties.cs @@ -1,10 +1,7 @@ namespace HostApi; -using System.Diagnostics.Contracts; - public interface IProperties : IEnumerable> { - [Pure] int Count { get; } string this[string key] { get; set; } diff --git a/CSharpInteractive.HostApi/Output.cs b/CSharpInteractive.HostApi/Output.cs index 6d26e1ef..8712f71e 100644 --- a/CSharpInteractive.HostApi/Output.cs +++ b/CSharpInteractive.HostApi/Output.cs @@ -1,7 +1,11 @@ namespace HostApi; [Target] -public readonly record struct Output(IStartInfo StartInfo, bool IsError, string Line, int ProcessId) +public readonly record struct Output( + IStartInfo StartInfo, + bool IsError, + string Line, + int ProcessId) { public override string ToString() => IsError ? $"ERR {Line}" : Line; } \ No newline at end of file diff --git a/CSharpInteractive.Tests/Integration/ScriptRunTests.cs b/CSharpInteractive.Tests/Integration/ScriptRunTests.cs index 237b40bd..cb147f40 100644 --- a/CSharpInteractive.Tests/Integration/ScriptRunTests.cs +++ b/CSharpInteractive.Tests/Integration/ScriptRunTests.cs @@ -11,7 +11,7 @@ namespace CSharpInteractive.Tests.Integration; [SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")] public class ScriptRunTests { - private const int InitialLinesCount = 3; + private const int InitialLinesCount = 4; [Fact] public void ShouldRunEmptyScript() @@ -166,7 +166,7 @@ public void ShouldSupportWarning() // Then result.ExitCode.ShouldBe(0, result.ToString()); result.StdErr.ShouldBeEmpty(result.ToString()); - result.StdOut.Count.ShouldBe(InitialLinesCount + 3, result.ToString()); + result.StdOut.Count.ShouldBe(InitialLinesCount + 4, result.ToString()); result.StdOut.Contains("My warning").ShouldBeTrue(result.ToString()); } diff --git a/CSharpInteractive.Tests/Integration/TeamCityScriptRunTests.cs b/CSharpInteractive.Tests/Integration/TeamCityScriptRunTests.cs index a1d2c519..7f368ab8 100644 --- a/CSharpInteractive.Tests/Integration/TeamCityScriptRunTests.cs +++ b/CSharpInteractive.Tests/Integration/TeamCityScriptRunTests.cs @@ -4,7 +4,7 @@ namespace CSharpInteractive.Tests.Integration; [Trait("Integration", "true")] public class ScriptRunTeamCityScriptRunTests { - private const int InitialMessagesCount = 3; + private const int InitialMessagesCount = 4; [Fact] public void ShouldAddSystemNamespace() diff --git a/CSharpInteractive/StatisticsPresenter.cs b/CSharpInteractive/StatisticsPresenter.cs index 564848bc..4a35cc4f 100644 --- a/CSharpInteractive/StatisticsPresenter.cs +++ b/CSharpInteractive/StatisticsPresenter.cs @@ -9,21 +9,24 @@ internal class StatisticsPresenter(ILog log) : IPresenter 0 || statistics.Warnings.Count > 0 || statistics.Errors.Count > 0) { - log.Info(Text.Tab, new Text(error, Color.Error)); + log.Info(new Text("Summary:", Color.Header)); + + foreach (var processResult in statistics.ProcessResults) + { + log.Info(Text.Tab + processResult.Description); + } + + foreach (var warning in statistics.Warnings) + { + log.Info(Text.Tab, new Text(warning, Color.Warning)); + } + + foreach (var error in statistics.Errors) + { + log.Info(Text.Tab, new Text(error, Color.Error)); + } } if (statistics.Warnings.Count > 0) diff --git a/Directory.Build.props b/Directory.Build.props index 1bb6c8d0..a1632c38 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -18,7 +18,6 @@ -