diff --git a/Turkey/BashTest.cs b/Turkey/BashTest.cs index 3dd09ba..e6d490f 100644 --- a/Turkey/BashTest.cs +++ b/Turkey/BashTest.cs @@ -38,7 +38,7 @@ protected override async Task InternalRunAsync(Action logger startInfo.EnvironmentVariables.Add(key, value); } - int exitCode = await ProcessRunner.RunAsync(startInfo, logger, cancellationToken); + int exitCode = await ProcessRunner.RunAsync(startInfo, logger, cancellationToken).ConfigureAwait(false); return exitCode == 0 ? TestResult.Passed : TestResult.Failed; } diff --git a/Turkey/Cleaner.cs b/Turkey/Cleaner.cs index 7747152..d442ed4 100644 --- a/Turkey/Cleaner.cs +++ b/Turkey/Cleaner.cs @@ -36,7 +36,9 @@ public static IEnumerable LocalProjectCruft() yield return "project.lock.json"; } - public async Task CleanProjectLocalDotNetCruftAsync() +#pragma warning disable CA1822 // Mark members as static + public Task CleanProjectLocalDotNetCruftAsync() +#pragma warning restore CA1822 // Mark members as static { foreach(var name in LocalProjectCruft()) @@ -51,9 +53,12 @@ public async Task CleanProjectLocalDotNetCruftAsync() File.Delete(name); } } + return Task.CompletedTask; } - public async Task CleanLocalDotNetCacheAsync() +#pragma warning disable CA1822 // Mark members as static + public Task CleanLocalDotNetCacheAsync() +#pragma warning restore CA1822 // Mark members as static { foreach (var path in CruftDirectoryGlobs()) { @@ -77,12 +82,14 @@ public async Task CleanLocalDotNetCacheAsync() Console.WriteLine($"WARNING: unable to expand {path}"); } } - return; + return Task.CompletedTask; } +#pragma warning disable CA1822 // Mark members as static public IEnumerable ExpandPath(string pathWithGlob) +#pragma warning restore CA1822 // Mark members as static { - if (pathWithGlob.StartsWith("~")) + if (pathWithGlob.StartsWith("~", StringComparison.Ordinal)) { pathWithGlob = Environment.GetEnvironmentVariable("HOME") + pathWithGlob.Substring(1); } diff --git a/Turkey/DotNet.cs b/Turkey/DotNet.cs index 9cf4760..7a0bf10 100644 --- a/Turkey/DotNet.cs +++ b/Turkey/DotNet.cs @@ -43,7 +43,7 @@ public List RuntimeVersions string output = p.StandardOutput.ReadToEnd(); var list = output .Split("\n", StringSplitOptions.RemoveEmptyEntries) - .Where(line => line.StartsWith("Microsoft.NETCore.App")) + .Where(line => line.StartsWith("Microsoft.NETCore.App", StringComparison.Ordinal)) .Select(line => line.Split(" ")[1]) .Select(versionString => Version.Parse(versionString)) .OrderBy(x => x) @@ -137,7 +137,7 @@ private async Task RunDotNetCommandAsync(DirectoryInfo workingDirectory, st startInfo.EnvironmentVariables.Add(key, value); } - return await ProcessRunner.RunAsync(startInfo, logger, token); + return await ProcessRunner.RunAsync(startInfo, logger, token).ConfigureAwait(false); } private static bool IsCoreClrRuntime(string dotnetRoot, Version version) @@ -159,7 +159,9 @@ private static bool IsCoreClrRuntime(string dotnetRoot, Version version) return File.Exists(Path.Combine(runtimeDir, "libcoreclrtraceptprovider.so")); } + #nullable enable private static string? FindProgramInPath(string program) + #nullable disable { string[] paths = Environment.GetEnvironmentVariable("PATH")?.Split(':', StringSplitOptions.RemoveEmptyEntries) ?? Array.Empty(); foreach (string p in paths) diff --git a/Turkey/IEnumerableExtensions.cs b/Turkey/IEnumerableExtensions.cs index 023805e..7cea08b 100644 --- a/Turkey/IEnumerableExtensions.cs +++ b/Turkey/IEnumerableExtensions.cs @@ -10,7 +10,7 @@ public static async Task ForEachAsync(this IEnumerable items, Func IsPackageLiveAsync(string name, Version version) { var url = $"https://api-v2v3search-0.nuget.org/autocomplete?id={name}&prerelease=true"; - var result = await _client.GetStringAsync(url); - return await IsPackageLiveAsync(name, version, result); + Uri uri = new(url); + var result = await _client.GetStringAsync(uri).ConfigureAwait(false); + return await IsPackageLiveAsync(name, version, result).ConfigureAwait(false); } - public async Task IsPackageLiveAsync(string name, Version version, string json) +#pragma warning disable CA1801 // Remove unused parameter +#pragma warning disable CA1822 // Mark members as static + public Task IsPackageLiveAsync(string name, Version version, string json) +#pragma warning restore CA1822 // Mark members as static +#pragma warning restore CA1801 // Remove unused parameter { JObject deserialized = (JObject) JsonConvert.DeserializeObject(json); - JArray versions = (JArray) deserialized.GetValue("data"); + JArray versions = (JArray) deserialized.GetValue("data", StringComparison.Ordinal); var found = versions.Children() - .Where(v => v.Value().Equals(version.ToString())) + .Where(v => v.Value().Equals(version.ToString(), StringComparison.Ordinal)) .Any(); - return found; + return Task.FromResult(found); } - public async Task GenerateNuGetConfig(List urls, string nugetConfig = null) +#pragma warning disable CA1822 // Mark members as static + public Task GenerateNuGetConfig(List urls, string nugetConfig = null) +#pragma warning restore CA1822 // Mark members as static { - if( !urls.Any() && nugetConfig == null ) - throw new ArgumentNullException(); + if(!urls.Any()) + ArgumentNullException.ThrowIfNull(nugetConfig); string sources = null; if( urls.Any() ) @@ -54,6 +61,7 @@ public async Task GenerateNuGetConfig(List urls, string nugetCon { sources = $" {sources}\n"; } + } if( string.IsNullOrWhiteSpace(nugetConfig) ) @@ -66,9 +74,9 @@ public async Task GenerateNuGetConfig(List urls, string nugetCon } if( !string.IsNullOrWhiteSpace(sources) ) - nugetConfig = nugetConfig.Replace("", sources + ""); + nugetConfig = nugetConfig.Replace("", sources + "", StringComparison.Ordinal); - return nugetConfig; + return Task.FromResult(nugetConfig); } } diff --git a/Turkey/PlatformId.cs b/Turkey/PlatformId.cs index cae1728..45a750c 100644 --- a/Turkey/PlatformId.cs +++ b/Turkey/PlatformId.cs @@ -18,7 +18,9 @@ public List CurrentIds public List ComputePlatformIds(string[] osReleaseLines, string lddVersionOutput) { - string arch = Enum.GetName(typeof(Architecture), RuntimeInformation.OSArchitecture).ToLowerInvariant(); + #pragma warning disable CA1308 // Normalize strings to uppercase + string arch = RuntimeInformation.OSArchitecture.ToString().ToLowerInvariant(); + #pragma warning restore CA1308 // Normalize strings to uppercase return ComputePlatformIds(osReleaseLines, arch, lddVersionOutput); } @@ -63,17 +65,17 @@ public List ComputePlatformIds(string[] osReleaseLines, string architect return platforms.ToList(); } - private string GetValue(string key, string[] lines) + private static string GetValue(string key, string[] lines) { return lines.Where(line => line.StartsWith(key + "=", StringComparison.Ordinal)).Last().Substring((key + "=").Length); } - private string Unquote(string text) + private static string Unquote(string text) { // TODO implement proper un-escaping // This is a limited shell-style syntax described at // https://www.freedesktop.org/software/systemd/man/os-release.html - if (text.StartsWith("\"") && text.EndsWith("\"")) + if (text.StartsWith("\"", StringComparison.Ordinal) && text.EndsWith("\"", StringComparison.Ordinal)) { return text.Substring(1, text.Length - 2); } @@ -81,7 +83,9 @@ private string Unquote(string text) return text; } +#pragma warning disable CA1822 // Mark members as static internal string GetLddVersion() +#pragma warning restore CA1822 // Mark members as static { using (Process p = new Process()) { diff --git a/Turkey/ProcessExtensions.cs b/Turkey/ProcessExtensions.cs index d02bb2a..dd8ee3a 100644 --- a/Turkey/ProcessExtensions.cs +++ b/Turkey/ProcessExtensions.cs @@ -12,7 +12,7 @@ public static async Task RunAsync(ProcessStartInfo psi, Action logg { logger($"Executing {psi.FileName} with arguments {psi.Arguments} in working directory {psi.WorkingDirectory}"); using var process = Process.Start(psi); - await process.WaitForExitAsync(logger, token); + await process.WaitForExitAsync(logger, token).ConfigureAwait(false); return process.ExitCode; } } @@ -43,11 +43,11 @@ public static async Task WaitForExitAsync(this Process process, Action l try { - await process.WaitForExitAsync(token); + await process.WaitForExitAsync(token).ConfigureAwait(false); logger($"Process Exit Code: {process.ExitCode}"); } - catch (OperationCanceledException ex) + catch (OperationCanceledException) { lock (logger) { diff --git a/Turkey/Program.cs b/Turkey/Program.cs index fba1d31..3618640 100644 --- a/Turkey/Program.cs +++ b/Turkey/Program.cs @@ -11,8 +11,8 @@ using System.Runtime.InteropServices; namespace Turkey -{ - public class Program +{ public static class Program + { public static readonly Option verboseOption = new Option( new string[] { "--verbose", "-v" }, @@ -118,7 +118,7 @@ public static async Task Run(string testRoot, Version packageVersion = runtimeVersion; string nuGetConfig = await GenerateNuGetConfigIfNeededAsync(additionalFeed, packageVersion, - useSourceBuildNuGetConfig: false); + useSourceBuildNuGetConfig: false).ConfigureAwait(false); if (verbose && nuGetConfig != null) { Console.WriteLine("Using nuget.config: "); @@ -132,7 +132,7 @@ public static async Task Run(string testRoot, verboseOutput: verbose, nuGetConfig: nuGetConfig); - var results = await runner.ScanAndRunAsync(testOutputs, logDir.FullName, defaultTimeout); + var results = await runner.ScanAndRunAsync(testOutputs, logDir.FullName, defaultTimeout).ConfigureAwait(false); int exitCode = (results.Failed == 0) ? 0 : 1; return exitCode; @@ -157,7 +157,7 @@ public static async Task GenerateNuGetConfigIfNeededAsync(string additio { try { - nugetConfig = await sourceBuild.GetNuGetConfigAsync(netCoreAppVersion); + nugetConfig = await sourceBuild.GetNuGetConfigAsync(netCoreAppVersion).ConfigureAwait(false); } catch( HttpRequestException exception ) { @@ -173,14 +173,16 @@ public static async Task GenerateNuGetConfigIfNeededAsync(string additio // if the nugetConfig has a element that removes // it. urls.Add("https://api.nuget.org/v3/index.json"); - return await nuget.GenerateNuGetConfig(urls, nugetConfig); + return await nuget.GenerateNuGetConfig(urls, nugetConfig).ConfigureAwait(false); } } return null; } +#pragma warning disable CA1801 // Remove unused parameter public static IReadOnlySet CreateTraits(Version runtimeVersion, Version sdkVersion, List rids, bool isMonoRuntime, IEnumerable additionalTraits) +#pragma warning restore CA1801 // Remove unused parameter { var traits = new HashSet(StringComparer.OrdinalIgnoreCase); @@ -199,7 +201,9 @@ public static IReadOnlySet CreateTraits(Version runtimeVersion, Version } // Add 'arch=' trait. +#pragma warning disable CA1308 // Normalize strings to uppercase string arch = RuntimeInformation.OSArchitecture.ToString().ToLowerInvariant(); +#pragma warning restore CA1308 // Normalize strings to uppercase traits.Add($"arch={arch}"); // Add 'runtime=' trait. @@ -231,7 +235,7 @@ static async Task Main(string[] args) rootCommand.AddOption(traitOption); rootCommand.AddOption(timeoutOption); - return await rootCommand.InvokeAsync(args); + return await rootCommand.InvokeAsync(args).ConfigureAwait(false); } } -} +} \ No newline at end of file diff --git a/Turkey/SourceBuild.cs b/Turkey/SourceBuild.cs index ce847d9..daed9ab 100644 --- a/Turkey/SourceBuild.cs +++ b/Turkey/SourceBuild.cs @@ -16,11 +16,12 @@ public SourceBuild(HttpClient client) this._client = client; } - public string GetBranchContentUrl(Version version) + public static System.Uri GetBranchContentUrl(Version version) { var branchName = "release/" + version.MajorMinor + ".1xx"; var url = $"https://raw.githubusercontent.com/dotnet/installer/{branchName}/"; - return url; + Uri uri = new(url); + return uri; } public async Task GetProdConFeedAsync(Version version) @@ -31,9 +32,10 @@ public async Task GetProdConFeedAsync(Version version) } var url = GetBranchContentUrl(version) + "ProdConFeed.txt"; - var feedUrl = await _client.GetStringAsync(url); - - using(var response = await _client.GetAsync(feedUrl)) + Uri uri = new(url); + var feedUrl = await _client.GetStringAsync(uri).ConfigureAwait(false); + Uri feedUri = new(feedUrl); + using(var response = await _client.GetAsync(feedUri).ConfigureAwait(false)) { if (!response.IsSuccessStatusCode) { @@ -46,11 +48,12 @@ public async Task GetProdConFeedAsync(Version version) public async Task GetNuGetConfigAsync(Version version) { string url = GetBranchContentUrl(version) + "NuGet.config"; + Uri uri = new(url); string nugetConfig = null; try { - nugetConfig = await _client.GetStringAsync(url); + nugetConfig = await _client.GetStringAsync(uri).ConfigureAwait(false); } catch( HttpRequestException e ) { diff --git a/Turkey/Test.cs b/Turkey/Test.cs index dc4b8a7..f916a51 100644 --- a/Turkey/Test.cs +++ b/Turkey/Test.cs @@ -18,8 +18,8 @@ public class TestDescriptor public string Type { get; set; } public bool Cleanup { get; set; } public double TimeoutMultiplier { get; set; } = 1.0; - public List IgnoredRIDs { get; set; } = new(); - public List SkipWhen { get; set; } = new(); + internal List IgnoredRIDs = new(); + internal List SkipWhen = new(); } // TODO is this a strongly-typed enum in C#? @@ -58,10 +58,10 @@ public async Task RunAsync(Action logger, CancellationToken { Console.WriteLine($"WARNING: overwriting {path}"); } - await File.WriteAllTextAsync(path, NuGetConfig); + await File.WriteAllTextAsync(path, NuGetConfig).ConfigureAwait(false); } - var testResult = await InternalRunAsync(logger, cancelltionToken); + var testResult = await InternalRunAsync(logger, cancelltionToken).ConfigureAwait(false); if (!string.IsNullOrEmpty(NuGetConfig)) { diff --git a/Turkey/TestOutputFormat.cs b/Turkey/TestOutputFormat.cs index 4f85e64..b88743c 100644 --- a/Turkey/TestOutputFormat.cs +++ b/Turkey/TestOutputFormat.cs @@ -11,9 +11,9 @@ namespace Turkey { - public class TestOutputFormats + public static class TestOutputFormats { - public class NewOutput : TestOutput + internal class NewOutput : TestOutput { public class FailedTest { @@ -23,16 +23,23 @@ public class FailedTest private List failedTests = new List(); - public async override Task AtStartupAsync(){ +#pragma warning disable CA1822 // Mark members as static + public void AtStartup() +#pragma warning restore CA1822 // Mark members as static + { Console.WriteLine("Running tests:"); + return; } - public async override Task AfterParsingTestAsync(string name, bool enabled) + public override Task AfterParsingTestAsync(string name, bool enabled) { + #pragma warning disable CA1305 var nameText = string.Format("{0,-60}", name); + #pragma warning restore CA1305 Console.Write(nameText); + return Task.CompletedTask; } - public async override Task AfterRunningTestAsync(string name, TestResult result, StringBuilder testLog, TimeSpan testTime) + public override Task AfterRunningTestAsync(string name, TestResult result, StringBuilder testLog, TimeSpan testTime) { int minutes = (int)testTime.TotalMinutes; int seconds = (int)Math.Ceiling(testTime.TotalSeconds - 60 * minutes); @@ -59,26 +66,31 @@ public async override Task AfterRunningTestAsync(string name, TestResult result, } Console.WriteLine($"[{resultOutput}]\t({elapsedTime})"); } + return Task.CompletedTask; } - public async override Task PrintFailedTests() + public override Task PrintFailedTests() { Console.WriteLine(); Console.WriteLine("The following tests failed: "); foreach(var test in failedTests) { + #pragma warning disable CA1305 Console.WriteLine($"{string.Format("{0,-30}", test.Name)}({test.Duration})"); + #pragma warning restore CA1305 } + return Task.CompletedTask; } - public async override Task AfterRunningAllTestsAsync(TestResults results) + public override Task AfterRunningAllTestsAsync(TestResults results) { Console.WriteLine(); Console.WriteLine($"Total: {results.Total} Passed: {results.Passed} Failed: {results.Failed}"); + return Task.CompletedTask; } } - public class JUnitOutput : TestOutput + internal class JUnitOutput : TestOutput { private struct TestCase { public string Name; @@ -102,7 +114,7 @@ public JUnitOutput(FileInfo resultsFile) _resultsFile = resultsFile; } - public async override Task AfterRunningTestAsync(string name, TestResult result, StringBuilder testLog, TimeSpan testTime) + public override Task AfterRunningTestAsync(string name, TestResult result, StringBuilder testLog, TimeSpan testTime) { var testCase = new TestCase(); testCase.Name = name; @@ -113,9 +125,11 @@ public async override Task AfterRunningTestAsync(string name, TestResult result, testCase.Log = testLog; _testCases.Add(testCase); + + return Task.CompletedTask; } - public async override Task AfterRunningAllTestsAsync(TestResults results) + public override Task AfterRunningAllTestsAsync(TestResults results) { var settings = new XmlWriterSettings(); settings.Indent = true; @@ -126,8 +140,10 @@ public async override Task AfterRunningAllTestsAsync(TestResults results) writer.WriteStartElement("testsuite"); writer.WriteAttributeString("name", "dotnet"); +#pragma warning disable CA1305 // Specify IFormatProvider writer.WriteAttributeString("tests", _testCases.Count.ToString()); writer.WriteAttributeString("failures", _testCases.Where(t => t.Failed).Count().ToString()); +#pragma warning restore CA1305 // Specify IFormatProvider writer.WriteAttributeString("errors", "0"); foreach (var testCase in _testCases) @@ -168,9 +184,10 @@ public async override Task AfterRunningAllTestsAsync(TestResults results) writer.WriteEndDocument(); writer.Close(); } + return Task.CompletedTask; } - private string RemoveInvalidXmlCharacters(string input) + private static string RemoveInvalidXmlCharacters(string input) { return Regex.Replace(input, @"[\u0000-\u0008,\u000B,\u000C,\u000E-\u001F]", ""); } diff --git a/Turkey/TestParser.cs b/Turkey/TestParser.cs index af59eda..0a63b92 100644 --- a/Turkey/TestParser.cs +++ b/Turkey/TestParser.cs @@ -1,6 +1,7 @@ using System; using System.IO; using System.Linq; +using System.Reflection.Metadata.Ecma335; using System.Threading.Tasks; using Newtonsoft.Json; @@ -15,7 +16,9 @@ public class TestParser return TryParseAsync(system, nuGetConfig, dir, File.ReadAllText(testConfiguration.FullName)); } - public async Task<(bool Success, Test Test)> TryParseAsync(SystemUnderTest system, string nuGetConfig, DirectoryInfo directory, string testConfiguration) +#pragma warning disable CA1801 // Remove unused parameter + public Task<(bool Success, Test Test)> TryParseAsync(SystemUnderTest system, string nuGetConfig, DirectoryInfo directory, string testConfiguration) +#pragma warning restore CA1801 // Remove unused parameter { // TODO: async var fileName = Path.Combine(directory.FullName, "test.json"); @@ -32,12 +35,12 @@ public class TestParser { case "xunit": test = new XUnitTest(directory, system, nuGetConfig, descriptor, enabled); - return (true, test); + return Task.FromResult((true, test)); case "bash": test = new BashTest(directory, system, nuGetConfig, descriptor, enabled); - return (true, test); + return Task.FromResult((true, test)); default: - return (false, null); + return Task.FromResult((false, test)); } } @@ -98,7 +101,9 @@ public bool ShouldRunTest(SystemUnderTest system, TestDescriptor test) } +#pragma warning disable CA1822 // Mark members as static private bool VersionMatches(TestDescriptor test, Version runtimeVersion) +#pragma warning restore CA1822 // Mark members as static { if (test.VersionSpecific) { diff --git a/Turkey/TestRunner.cs b/Turkey/TestRunner.cs index 13ce46b..929e13f 100644 --- a/Turkey/TestRunner.cs +++ b/Turkey/TestRunner.cs @@ -22,7 +22,7 @@ public class SystemUnderTest public Version RuntimeVersion { get; } public Version SdkVersion { get; } public List CurrentPlatformIds { get; } - public IReadOnlyDictionary EnvironmentVariables; + internal IReadOnlyDictionary EnvironmentVariables; public IReadOnlySet Traits { get; } public DotNet Dotnet { get; } @@ -44,12 +44,12 @@ public SystemUnderTest(DotNet dotnet, public class TestOutput { - public async virtual Task AtStartupAsync() {} - public async virtual Task BeforeTestAsync() {} - public async virtual Task AfterParsingTestAsync(string name, bool enabled) {} - public async virtual Task AfterRunningTestAsync(string name, TestResult result, StringBuilder testLog, TimeSpan testTime) {} - public async virtual Task PrintFailedTests() {} - public async virtual Task AfterRunningAllTestsAsync(TestResults results) {} + public virtual Task AtStartupAsync() { return Task.CompletedTask; } + public virtual Task BeforeTestAsync() { return Task.CompletedTask; } + public virtual Task AfterParsingTestAsync(string name, bool enabled) { return Task.CompletedTask; } + public virtual Task AfterRunningTestAsync(string name, TestResult result, StringBuilder testLog, TimeSpan testTime) { return Task.CompletedTask; } + public virtual Task PrintFailedTests() { return Task.CompletedTask; } + public virtual Task AfterRunningAllTestsAsync(TestResults results) { return Task.CompletedTask; } } public class TestRunner @@ -72,7 +72,7 @@ public TestRunner(SystemUnderTest system, DirectoryInfo root, bool verboseOutput public async Task ScanAndRunAsync(List outputs, string logDir, TimeSpan defaultTimeout) { - await outputs.ForEachAsync(output => output.AtStartupAsync()); + await outputs.ForEachAsync(output => output.AtStartupAsync()).ConfigureAwait(false); TestResults results = new TestResults(); @@ -93,10 +93,10 @@ public async Task ScanAndRunAsync(List outputs, string foreach (var file in sortedFiles) { testTimeWatch.Reset(); - await cleaner.CleanLocalDotNetCacheAsync(); + await cleaner.CleanLocalDotNetCacheAsync().ConfigureAwait(false); testTimeWatch.Start(); - var parsedTest = await parser.TryParseAsync(system, nuGetConfig, file); + var parsedTest = await parser.TryParseAsync(system, nuGetConfig, file).ConfigureAwait(false); if (!parsedTest.Success) { Console.WriteLine($"WARNING: Unable to parse {file}"); @@ -105,7 +105,7 @@ public async Task ScanAndRunAsync(List outputs, string var test = parsedTest.Test; string testName = test.Descriptor.Name; - await outputs.ForEachAsync(output => output.AfterParsingTestAsync(testName, !test.Skip)); + await outputs.ForEachAsync(output => output.AfterParsingTestAsync(testName, !test.Skip)).ConfigureAwait(false); TimeSpan testTimeout = test.Descriptor.TimeoutMultiplier * defaultTimeout; using var cts = testTimeout == TimeSpan.Zero ? null : new CancellationTokenSource(testTimeout); @@ -125,13 +125,13 @@ public async Task ScanAndRunAsync(List outputs, string if (test.Descriptor.Cleanup) { - await cleaner.CleanProjectLocalDotNetCruftAsync(); + await cleaner.CleanProjectLocalDotNetCruftAsync().ConfigureAwait(false); } TestResult testResult; try { - testResult = await test.RunAsync(testLogger, cancellationToken); + testResult = await test.RunAsync(testLogger, cancellationToken).ConfigureAwait(false); } catch (OperationCanceledException) { @@ -149,15 +149,15 @@ public async Task ScanAndRunAsync(List outputs, string case TestResult.Skipped: results.Skipped++; break; } - await outputs.ForEachAsync(output => output.AfterRunningTestAsync(testName, testResult, testLog, testTimeWatch.Elapsed)); + await outputs.ForEachAsync(output => output.AfterRunningTestAsync(testName, testResult, testLog, testTimeWatch.Elapsed)).ConfigureAwait(false); } if (results.Failed != 0 ) { - await outputs.ForEachAsync(outputs => outputs.PrintFailedTests()); + await outputs.ForEachAsync(outputs => outputs.PrintFailedTests()).ConfigureAwait(false); } - await outputs.ForEachAsync(output => output.AfterRunningAllTestsAsync(results)); + await outputs.ForEachAsync(output => output.AfterRunningAllTestsAsync(results)).ConfigureAwait(false); return results; } diff --git a/Turkey/Version.cs b/Turkey/Version.cs index 7b95170..0bcbd18 100644 --- a/Turkey/Version.cs +++ b/Turkey/Version.cs @@ -134,7 +134,9 @@ private static int CompareTo(Version v1, Version v2) public override int GetHashCode() { +#pragma warning disable CA1065 // Do not raise exceptions in unexpected locations throw new NotImplementedException(); +#pragma warning restore CA1065 // Do not raise exceptions in unexpected locations } } diff --git a/Turkey/XUnitTest.cs b/Turkey/XUnitTest.cs index 1834f82..2232407 100644 --- a/Turkey/XUnitTest.cs +++ b/Turkey/XUnitTest.cs @@ -16,8 +16,8 @@ public XUnitTest(DirectoryInfo directory, SystemUnderTest system, string nuGetCo protected override async Task InternalRunAsync(Action logger, CancellationToken cancellationToken) { - bool success = await BuildProjectAsync(logger, cancellationToken) == 0 - && await RunTestProjectAsync(logger, cancellationToken) == 0; + bool success = await BuildProjectAsync(logger, cancellationToken).ConfigureAwait(false) == 0 + && await RunTestProjectAsync(logger, cancellationToken).ConfigureAwait(false) == 0; return success ? TestResult.Passed : TestResult.Failed; }