From d37453adfec8bdbaecf645ea97368d56ac476976 Mon Sep 17 00:00:00 2001 From: David Pine Date: Fri, 20 Dec 2024 13:13:12 -0600 Subject: [PATCH] Upgrade to .NET 9 --- Directory.Build.props | 2 +- Directory.Packages.props | 9 +- dotnet-github-actions-sdk.sln | 4 + global.json | 5 +- .../Octokit.Sandbox/Octokit.Sandbox.csproj | 2 +- samples/Actions.Core.Sample/Dockerfile | 4 +- samples/Actions.Glob.Sample/Dockerfile | 4 +- samples/Directory.Build.props | 2 +- src/Actions.Core/Commands/CommandNames.cs | 6 +- .../Commands/DefaultCommandIssuer.cs | 4 +- src/Actions.Core/EnvironmentVariables/Keys.cs | 2 + .../EnvironmentVariables/Prefixes.cs | 2 + .../EnvironmentVariables/Suffixes.cs | 2 + .../Extensions/GenericExtensions.cs | 10 +- .../Extensions/ObjectExtensions.cs | 6 +- .../Extensions/ProcessExtensions.cs | 4 +- src/Actions.Core/GlobalUsings.cs | 1 - src/Actions.Core/Output/IConsole.cs | 20 +- .../Services/DefaultCoreService.cs | 43 +++- src/Actions.Core/Summaries/Summary.cs | 11 +- src/Actions.Core/Workflows/Command.cs | 14 +- .../DefaultGlobPatternResolver.cs | 18 +- .../DefaultGlobPatternResolverBuilder.cs | 4 +- .../Extensions/ServiceCollectionExtensions.cs | 2 + .../Extensions/StringExtensions.Files.cs | 6 +- src/Actions.Glob/Globber.cs | 23 +- .../Clients/DefaultHttpClient.cs | 25 ++- src/Actions.HttpClient/Clients/IHttpClient.cs | 2 + .../DefaultHttpKeyedClientFactory.cs | 2 + .../Factories/IHttpCredentialClientFactory.cs | 2 + src/Actions.IO/IOperations.cs | 4 +- src/Actions.IO/Operations.cs | 6 +- src/Actions.IO/Utilities.cs | 24 ++- tests/Actions.Core.Tests/GlobalUsings.cs | 6 + .../Actions.Core.Tests/Output/TestConsole.cs | 20 +- .../Services/CoreSummaryTestFixture.cs | 5 +- .../Services/CoreSummaryTests.cs | 200 ++++++++++++++---- .../Extensions/StringExtensionTests.cs | 2 +- .../GlobPatternBuilderTests.cs | 4 +- .../Actions.IO.Tests/TempFolderTestFixture.cs | 5 +- .../GitHubClientFactoryTests.cs | 16 +- .../GitHubClientTests.cs | 4 +- 42 files changed, 396 insertions(+), 141 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 215458f..17b1357 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -20,7 +20,7 @@ true David Pine - © 2022-2024 David Pine + © 2022-$([System.DateTime]::Now.ToString('yyyy')) David Pine MIT README.md dotnet;dotnetcore;csharp;github;actions;devops; diff --git a/Directory.Packages.props b/Directory.Packages.props index be0a882..bbdc507 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,7 +1,7 @@ true - net8.0 + net9.0 @@ -15,7 +15,8 @@ - - + + + - \ No newline at end of file + diff --git a/dotnet-github-actions-sdk.sln b/dotnet-github-actions-sdk.sln index 196f8f6..fa2cb86 100644 --- a/dotnet-github-actions-sdk.sln +++ b/dotnet-github-actions-sdk.sln @@ -25,6 +25,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution .github\workflows\build-and-test.yml = .github\workflows\build-and-test.yml .github\workflows\codeql-analysis.yml = .github\workflows\codeql-analysis.yml Directory.Build.props = Directory.Build.props + Directory.Build.targets = Directory.Build.targets Directory.Packages.props = Directory.Packages.props global.json = global.json LICENSE = LICENSE @@ -34,6 +35,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{C5358CA3-CAA9-43F6-9696-4AEFA18AD581}" + ProjectSection(SolutionItems) = preProject + samples\Directory.Build.props = samples\Directory.Build.props + EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Actions.Core.Sample", "samples\Actions.Core.Sample\Actions.Core.Sample.csproj", "{2C5BDF3F-726C-4D1B-91D9-AB4209B9DD3C}" EndProject diff --git a/global.json b/global.json index 415f184..52a6e36 100644 --- a/global.json +++ b/global.json @@ -1,9 +1,6 @@ { "sdk": { - "version": "8.0.200", + "version": "9.0.100", "rollForward": "major" - }, - "tools": { - "dotnet": "8.0.200" } } diff --git a/playground/Octokit.Sandbox/Octokit.Sandbox.csproj b/playground/Octokit.Sandbox/Octokit.Sandbox.csproj index 3ab9243..3a6bcb1 100644 --- a/playground/Octokit.Sandbox/Octokit.Sandbox.csproj +++ b/playground/Octokit.Sandbox/Octokit.Sandbox.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net9.0 enable enable diff --git a/samples/Actions.Core.Sample/Dockerfile b/samples/Actions.Core.Sample/Dockerfile index 55eb8fb..7433fd9 100644 --- a/samples/Actions.Core.Sample/Dockerfile +++ b/samples/Actions.Core.Sample/Dockerfile @@ -1,4 +1,4 @@ -FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-jammy AS build +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0-noble AS build ARG TARGETARCH WORKDIR /source @@ -13,7 +13,7 @@ RUN dotnet restore "samples/Actions.Core.Sample/Actions.Core.Sample.csproj" -a $ COPY . . RUN dotnet publish "samples/Actions.Core.Sample/Actions.Core.Sample.csproj" -a $TARGETARCH --no-restore -o /app -FROM mcr.microsoft.com/dotnet/runtime:8.0-jammy-chiseled +FROM mcr.microsoft.com/dotnet/runtime:9.0-noble-chiseled WORKDIR /app COPY --from=build /app . USER root diff --git a/samples/Actions.Glob.Sample/Dockerfile b/samples/Actions.Glob.Sample/Dockerfile index 8179efd..0d7facd 100644 --- a/samples/Actions.Glob.Sample/Dockerfile +++ b/samples/Actions.Glob.Sample/Dockerfile @@ -1,4 +1,4 @@ -FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-jammy AS build +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0-noble AS build ARG TARGETARCH WORKDIR /source @@ -14,7 +14,7 @@ RUN dotnet restore "samples/Actions.Glob.Sample/Actions.Glob.Sample.csproj" -a $ COPY . . RUN dotnet publish "samples/Actions.Glob.Sample/Actions.Glob.Sample.csproj" -a $TARGETARCH --no-restore -o /app -FROM mcr.microsoft.com/dotnet/runtime:8.0-jammy-chiseled +FROM mcr.microsoft.com/dotnet/runtime:9.0-noble-chiseled WORKDIR /app COPY --from=build /app . USER root diff --git a/samples/Directory.Build.props b/samples/Directory.Build.props index 12d73af..3c3c5a0 100644 --- a/samples/Directory.Build.props +++ b/samples/Directory.Build.props @@ -2,7 +2,7 @@ - net8.0 + net9.0 Exe false diff --git a/src/Actions.Core/Commands/CommandNames.cs b/src/Actions.Core/Commands/CommandNames.cs index 7847d37..fcaf947 100644 --- a/src/Actions.Core/Commands/CommandNames.cs +++ b/src/Actions.Core/Commands/CommandNames.cs @@ -47,6 +47,8 @@ internal static class CommandNames SetOutput ]); - internal static bool IsConventional(string? command) => - s_all.Value.Contains(command); + internal static bool IsConventional(string? command) + { + return s_all.Value.Contains(command); + } } diff --git a/src/Actions.Core/Commands/DefaultCommandIssuer.cs b/src/Actions.Core/Commands/DefaultCommandIssuer.cs index 7f9a837..cd65cbf 100644 --- a/src/Actions.Core/Commands/DefaultCommandIssuer.cs +++ b/src/Actions.Core/Commands/DefaultCommandIssuer.cs @@ -7,8 +7,10 @@ namespace Actions.Core.Commands; internal sealed class DefaultCommandIssuer(IConsole console) : ICommandIssuer { /// - public void Issue(string commandName, string? message = default) => + public void Issue(string commandName, string? message = default) + { IssueCommand(commandName, null, message); + } /// public void IssueCommand( diff --git a/src/Actions.Core/EnvironmentVariables/Keys.cs b/src/Actions.Core/EnvironmentVariables/Keys.cs index 475bc25..be192c7 100644 --- a/src/Actions.Core/EnvironmentVariables/Keys.cs +++ b/src/Actions.Core/EnvironmentVariables/Keys.cs @@ -13,6 +13,8 @@ namespace Actions.Core.EnvironmentVariables; Justification = "These values correspond to environment variables and I want them to match exactly.")] #if ACTIONS_CORE_ENVIRONMENTVARIABLES_PUBLIC public +#else +internal #endif static class Keys { diff --git a/src/Actions.Core/EnvironmentVariables/Prefixes.cs b/src/Actions.Core/EnvironmentVariables/Prefixes.cs index e8f0891..e7c9c39 100644 --- a/src/Actions.Core/EnvironmentVariables/Prefixes.cs +++ b/src/Actions.Core/EnvironmentVariables/Prefixes.cs @@ -12,6 +12,8 @@ namespace Actions.Core.EnvironmentVariables; Justification = "These values correspond to environment variables and I want them to match exactly.")] #if ACTIONS_CORE_ENVIRONMENTVARIABLES_PUBLIC public +#else +internal #endif static class Prefixes { diff --git a/src/Actions.Core/EnvironmentVariables/Suffixes.cs b/src/Actions.Core/EnvironmentVariables/Suffixes.cs index a138279..7c8f18e 100644 --- a/src/Actions.Core/EnvironmentVariables/Suffixes.cs +++ b/src/Actions.Core/EnvironmentVariables/Suffixes.cs @@ -8,6 +8,8 @@ namespace Actions.Core.EnvironmentVariables; /// #if ACTIONS_CORE_ENVIRONMENTVARIABLES_PUBLIC public +#else +internal #endif static class Suffixes { diff --git a/src/Actions.Core/Extensions/GenericExtensions.cs b/src/Actions.Core/Extensions/GenericExtensions.cs index 994f9e4..56c0938 100644 --- a/src/Actions.Core/Extensions/GenericExtensions.cs +++ b/src/Actions.Core/Extensions/GenericExtensions.cs @@ -3,7 +3,7 @@ namespace Actions.Core.Extensions; -static class GenericExtensions +internal static class GenericExtensions { /// /// Converts the specified object as: @@ -17,8 +17,9 @@ static class GenericExtensions /// The in context. /// The JSON type info, used to serialize the type. /// The string representation of the . - internal static string ToCommandValue(this T? value, JsonTypeInfo? typeInfo = null) => - IsAnonymousType(typeof(T)) + internal static string ToCommandValue(this T? value, JsonTypeInfo? typeInfo = null) + { + return IsAnonymousType(typeof(T)) ? throw new ArgumentException("Generic type T, cannot be anonymous type!") : value switch { @@ -28,6 +29,7 @@ internal static string ToCommandValue(this T? value, JsonTypeInfo? typeInf _ when typeInfo is null => value?.ToString() ?? string.Empty, _ => JsonSerializer.Serialize(value, typeInfo) }; + } // From: https://stackoverflow.com/a/1650965/2410379 internal static bool IsAnonymousType(this Type type) @@ -42,4 +44,4 @@ internal static bool IsAnonymousType(this Type type) && typeName.IndexOf("AnonymousType", StringComparison.Ordinal) > 0 }; } -} \ No newline at end of file +} diff --git a/src/Actions.Core/Extensions/ObjectExtensions.cs b/src/Actions.Core/Extensions/ObjectExtensions.cs index bab313a..76ad229 100644 --- a/src/Actions.Core/Extensions/ObjectExtensions.cs +++ b/src/Actions.Core/Extensions/ObjectExtensions.cs @@ -16,9 +16,11 @@ internal static class ObjectExtensions /// A new dictionary, with a single key-value pair. internal static Dictionary ToCommandProperties( this T value, - [CallerArgumentExpression(nameof(value))] string? paramName = null) => - new() + [CallerArgumentExpression(nameof(value))] string? paramName = null) + { + return new() { [paramName!] = value?.ToString() ?? string.Empty }; + } } diff --git a/src/Actions.Core/Extensions/ProcessExtensions.cs b/src/Actions.Core/Extensions/ProcessExtensions.cs index a607df1..17804cf 100644 --- a/src/Actions.Core/Extensions/ProcessExtensions.cs +++ b/src/Actions.Core/Extensions/ProcessExtensions.cs @@ -5,9 +5,11 @@ namespace Actions.Core.Extensions; internal static class ProcessExtensions { - internal static void GracefulOrForcedShutdown(this int pid) => + internal static void GracefulOrForcedShutdown(this int pid) + { Process.GetProcessById(pid) ?.GracefulOrForcedShutdown(); + } internal static void GracefulOrForcedShutdown(this Process process) { diff --git a/src/Actions.Core/GlobalUsings.cs b/src/Actions.Core/GlobalUsings.cs index b3e797b..f65731f 100644 --- a/src/Actions.Core/GlobalUsings.cs +++ b/src/Actions.Core/GlobalUsings.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. global using System.Diagnostics; -global using System.Diagnostics.CodeAnalysis; global using System.Globalization; global using System.Runtime.CompilerServices; global using System.Text; diff --git a/src/Actions.Core/Output/IConsole.cs b/src/Actions.Core/Output/IConsole.cs index f3635b7..38ba79e 100644 --- a/src/Actions.Core/Output/IConsole.cs +++ b/src/Actions.Core/Output/IConsole.cs @@ -9,22 +9,32 @@ namespace Actions.Core.Output; public interface IConsole { /// - void ExitWithCode(int exitCode = 0) => + void ExitWithCode(int exitCode = 0) + { Exit(Environment.ExitCode = exitCode); + } /// - void Write(string? message = null) => + void Write(string? message = null) + { Console.Write(message); + } /// - void WriteLine(string? message = null) => + void WriteLine(string? message = null) + { Console.WriteLine(message); + } /// - void WriteError(string message) => + void WriteError(string message) + { Console.Error.Write(message); + } /// - void WriteErrorLine(string message) => + void WriteErrorLine(string message) + { Console.Error.WriteLine(message); + } } diff --git a/src/Actions.Core/Services/DefaultCoreService.cs b/src/Actions.Core/Services/DefaultCoreService.cs index 34a620b..52dd8ad 100644 --- a/src/Actions.Core/Services/DefaultCoreService.cs +++ b/src/Actions.Core/Services/DefaultCoreService.cs @@ -34,19 +34,25 @@ public async ValueTask AddPathAsync(string path) } /// - public void WriteDebug(string message) => + public void WriteDebug(string message) + { commandIssuer.IssueCommand( CommandNames.Debug, message: message); + } /// - public void EndGroup() => + public void EndGroup() + { commandIssuer.Issue( CommandNames.EndGroup, ""); + } /// - public void WriteError(string message, AnnotationProperties? properties = default) => + public void WriteError(string message, AnnotationProperties? properties = default) + { commandIssuer.IssueCommand( CommandNames.Error, properties?.ToCommandProperties(), message); + } /// public async ValueTask ExportVariableAsync(string name, string value) @@ -109,8 +115,10 @@ public string[] GetMultilineInput(string name, InputOptions? options = default) } /// - public string GetState(string name) => - GetEnvironmentVariable($"{STATE_}{name}") ?? ""; + public string GetState(string name) + { + return GetEnvironmentVariable($"{STATE_}{name}") ?? ""; + } /// public async ValueTask GroupAsync(string name, Func> task) @@ -131,12 +139,17 @@ public async ValueTask GroupAsync(string name, Func> task) } /// - public void WriteInfo(string message) => console.WriteLine(message); + public void WriteInfo(string message) + { + console.WriteLine(message); + } /// - public void WriteNotice(string message, AnnotationProperties? properties = default) => + public void WriteNotice(string message, AnnotationProperties? properties = default) + { commandIssuer.IssueCommand( CommandNames.Notice, properties?.ToCommandProperties(), message); + } /// public async ValueTask SaveStateAsync(string name, T value, JsonTypeInfo? typeInfo) @@ -158,9 +171,11 @@ await fileCommandIssuer.IssueFileCommandAsync( } /// - public void SetCommandEcho(bool enabled) => + public void SetCommandEcho(bool enabled) + { commandIssuer.Issue( CommandNames.Echo, enabled ? "on" : "off"); + } /// public void SetFailed(string message) @@ -191,17 +206,23 @@ await fileCommandIssuer.IssueFileCommandAsync( } /// - public void SetSecret(string secret) => + public void SetSecret(string secret) + { commandIssuer.IssueCommand( CommandNames.AddMask, null, secret); + } /// - public void StartGroup(string name) => + public void StartGroup(string name) + { commandIssuer.Issue( CommandNames.Group, name); + } /// - public void WriteWarning(string message, AnnotationProperties? properties = default) => + public void WriteWarning(string message, AnnotationProperties? properties = default) + { commandIssuer.IssueCommand( CommandNames.Warning, properties?.ToCommandProperties(), message); + } } diff --git a/src/Actions.Core/Summaries/Summary.cs b/src/Actions.Core/Summaries/Summary.cs index 6284e8a..895aeee 100644 --- a/src/Actions.Core/Summaries/Summary.cs +++ b/src/Actions.Core/Summaries/Summary.cs @@ -109,12 +109,17 @@ public async Task WriteAsync(SummaryWriteOptions? options = default) /// Clears the summary buffer and wipes the summary file /// The Summary instance - public Task ClearAsync() => - EmptyBuffer().WriteAsync(new(true)); + public Task ClearAsync() + { + return EmptyBuffer().WriteAsync(new(true)); + } /// Returns the current summary buffer as a string /// A string representation of the summary buffer - public string Stringify() => _buffer.ToString(); + public string Stringify() + { + return _buffer.ToString(); + } /// Resets the summary buffer without writing to summary file /// The Summary instance diff --git a/src/Actions.Core/Workflows/Command.cs b/src/Actions.Core/Workflows/Command.cs index f197526..0a3a748 100644 --- a/src/Actions.Core/Workflows/Command.cs +++ b/src/Actions.Core/Workflows/Command.cs @@ -18,7 +18,7 @@ internal readonly record struct Command( string? Message = default, IReadOnlyDictionary? CommandProperties = default) { - const string CMD_STRING = "::"; + private const string CMD_STRING = "::"; internal bool Conventional => CommandNames.IsConventional(CommandName); @@ -51,17 +51,21 @@ in CommandProperties.Select( return builder.ToString(); } - static string EscapeProperty(string? value) => - value.ToCommandValue() + private static string EscapeProperty(string? value) + { + return value.ToCommandValue() .Replace("%", "%25") .Replace("\r", "%0D") .Replace("\n", "%0A") .Replace(":", "%3A") .Replace(",", "%2C"); + } - static string EscapeData(string? value) => - value.ToCommandValue() + private static string EscapeData(string? value) + { + return value.ToCommandValue() .Replace("%", "%25") .Replace("\r", "%0D") .Replace("\n", "%0A"); + } } diff --git a/src/Actions.Glob/DefaultGlobPatternResolver.cs b/src/Actions.Glob/DefaultGlobPatternResolver.cs index bfaa485..6668fb3 100644 --- a/src/Actions.Glob/DefaultGlobPatternResolver.cs +++ b/src/Actions.Glob/DefaultGlobPatternResolver.cs @@ -17,20 +17,26 @@ private DefaultGlobPatternResolver( /// internal static IGlobPatternResolver Factory( IEnumerable includePatterns, - IEnumerable excludePatterns) => - new DefaultGlobPatternResolver(includePatterns, excludePatterns); + IEnumerable excludePatterns) + { + return new DefaultGlobPatternResolver(includePatterns, excludePatterns); + } /// IEnumerable IGlobPatternResolver.GetGlobFiles( - string? directory) => - directory.GetGlobFiles( + string? directory) + { + return directory.GetGlobFiles( _includePatterns, _excludePatterns); + } /// GlobResult IGlobPatternResolver.GetGlobResult( - string? directory) => - directory.GetGlobResult( + string? directory) + { + return directory.GetGlobResult( _includePatterns, _excludePatterns); + } } diff --git a/src/Actions.Glob/DefaultGlobPatternResolverBuilder.cs b/src/Actions.Glob/DefaultGlobPatternResolverBuilder.cs index 6680516..648bd4f 100644 --- a/src/Actions.Glob/DefaultGlobPatternResolverBuilder.cs +++ b/src/Actions.Glob/DefaultGlobPatternResolverBuilder.cs @@ -6,8 +6,8 @@ namespace Actions.Glob; /// internal sealed class DefaultGlobPatternResolverBuilder : IGlobPatternResolverBuilder { - private readonly Lazy> _includePatterns = new(() => new()); - private readonly Lazy> _excludePatterns = new(() => new()); + private readonly Lazy> _includePatterns = new(() => []); + private readonly Lazy> _excludePatterns = new(() => []); /// public IGlobPatternResolver Build() diff --git a/src/Actions.Glob/Extensions/ServiceCollectionExtensions.cs b/src/Actions.Glob/Extensions/ServiceCollectionExtensions.cs index a7c11b6..c4dfa87 100644 --- a/src/Actions.Glob/Extensions/ServiceCollectionExtensions.cs +++ b/src/Actions.Glob/Extensions/ServiceCollectionExtensions.cs @@ -1,7 +1,9 @@ // Copyright (c) David Pine. All rights reserved. // Licensed under the MIT License. +#pragma warning disable IDE0130 // Namespace does not match folder structure namespace Actions.Glob; +#pragma warning restore IDE0130 // Namespace does not match folder structure /// /// Extensions for registering services with the . diff --git a/src/Actions.Glob/Extensions/StringExtensions.Files.cs b/src/Actions.Glob/Extensions/StringExtensions.Files.cs index 36606d7..c577bea 100644 --- a/src/Actions.Glob/Extensions/StringExtensions.Files.cs +++ b/src/Actions.Glob/Extensions/StringExtensions.Files.cs @@ -20,9 +20,11 @@ public static partial class StringExtensions public static IEnumerable GetGlobFiles( this string? directory, IEnumerable includePatterns, - IEnumerable? excludePatterns = null) => - directory.GetGlobResult( + IEnumerable? excludePatterns = null) + { + return directory.GetGlobResult( includePatterns, excludePatterns) is { HasMatches: true } result ? result.Files.Select(file => file.FullName) : []; + } } diff --git a/src/Actions.Glob/Globber.cs b/src/Actions.Glob/Globber.cs index 2014d57..4dabe34 100644 --- a/src/Actions.Glob/Globber.cs +++ b/src/Actions.Glob/Globber.cs @@ -23,8 +23,10 @@ private Globber( /// /// Required inclusion patterns. /// A new instance. - public static Globber Create(params string[] inclusions) => - new(inclusions); + public static Globber Create(params string[] inclusions) + { + return new(inclusions); + } /// /// Creates a new instance. @@ -34,13 +36,20 @@ public static Globber Create(params string[] inclusions) => /// A new instance. public static Globber Create( IEnumerable inclusions, - IEnumerable? exclusions = null) => new(inclusions, exclusions); + IEnumerable? exclusions = null) + { + return new(inclusions, exclusions); + } /// - public GlobResult Glob(string? directory = null) => - _glob.GetGlobResult(directory); + public GlobResult Glob(string? directory = null) + { + return _glob.GetGlobResult(directory); + } /// - public IEnumerable GlobFiles(string? directory = null) => - _glob.GetGlobFiles(directory); + public IEnumerable GlobFiles(string? directory = null) + { + return _glob.GetGlobFiles(directory); + } } diff --git a/src/Actions.HttpClient/Clients/DefaultHttpClient.cs b/src/Actions.HttpClient/Clients/DefaultHttpClient.cs index b8bf2b5..d31342d 100644 --- a/src/Actions.HttpClient/Clients/DefaultHttpClient.cs +++ b/src/Actions.HttpClient/Clients/DefaultHttpClient.cs @@ -1,7 +1,9 @@ // Copyright (c) David Pine. All rights reserved. // Licensed under the MIT License. +#pragma warning disable IDE0130 // Namespace does not match folder structure namespace Actions.HttpClient; +#pragma warning restore IDE0130 // Namespace does not match folder structure internal sealed class DefaultHttpClient(NetClient client, IRequestHandler? requestHandler = null) : IHttpClient { @@ -67,8 +69,10 @@ ValueTask> IHttpClient.PatchAsync( JsonTypeInfo dataJsonTypeInfo, JsonTypeInfo resultJsonTypeInfo, Dictionary>? additionalHeaders, - CancellationToken cancellationToken) => - RequestAsync(requestUri, HttpMethod.Patch, data, dataJsonTypeInfo, resultJsonTypeInfo, additionalHeaders, cancellationToken); + CancellationToken cancellationToken) + { + return RequestAsync(requestUri, HttpMethod.Patch, data, dataJsonTypeInfo, resultJsonTypeInfo, additionalHeaders, cancellationToken); + } ValueTask> IHttpClient.PostAsync( string requestUri, @@ -76,8 +80,10 @@ ValueTask> IHttpClient.PostAsync( JsonTypeInfo dataJsonTypeInfo, JsonTypeInfo resultJsonTypeInfo, Dictionary>? additionalHeaders, - CancellationToken cancellationToken) => - RequestAsync(requestUri, HttpMethod.Post, data, dataJsonTypeInfo, resultJsonTypeInfo, additionalHeaders, cancellationToken); + CancellationToken cancellationToken) + { + return RequestAsync(requestUri, HttpMethod.Post, data, dataJsonTypeInfo, resultJsonTypeInfo, additionalHeaders, cancellationToken); + } ValueTask> IHttpClient.PutAsync( string requestUri, @@ -85,8 +91,10 @@ ValueTask> IHttpClient.PutAsync( JsonTypeInfo dataJsonTypeInfo, JsonTypeInfo resultJsonTypeInfo, Dictionary>? additionalHeaders, - CancellationToken cancellationToken) => - RequestAsync(requestUri, HttpMethod.Put, data, dataJsonTypeInfo, resultJsonTypeInfo, additionalHeaders, cancellationToken); + CancellationToken cancellationToken) + { + return RequestAsync(requestUri, HttpMethod.Put, data, dataJsonTypeInfo, resultJsonTypeInfo, additionalHeaders, cancellationToken); + } async ValueTask IHttpClient.HeadAsync( string requestUri, @@ -150,5 +158,8 @@ private static StringContent GetRequestJsonContent( mediaType: "application/json"); } - void IDisposable.Dispose() => client?.Dispose(); + void IDisposable.Dispose() + { + client?.Dispose(); + } } diff --git a/src/Actions.HttpClient/Clients/IHttpClient.cs b/src/Actions.HttpClient/Clients/IHttpClient.cs index 7f18843..bbd3756 100644 --- a/src/Actions.HttpClient/Clients/IHttpClient.cs +++ b/src/Actions.HttpClient/Clients/IHttpClient.cs @@ -1,7 +1,9 @@ // Copyright (c) David Pine. All rights reserved. // Licensed under the MIT License. +#pragma warning disable IDE0130 // Namespace does not match folder structure namespace Actions.HttpClient; +#pragma warning restore IDE0130 // Namespace does not match folder structure /// /// Represents an HTTP client abstraction, exposing Native AOT compatible APIs. diff --git a/src/Actions.HttpClient/Factories/DefaultHttpKeyedClientFactory.cs b/src/Actions.HttpClient/Factories/DefaultHttpKeyedClientFactory.cs index 2b00e70..8549a51 100644 --- a/src/Actions.HttpClient/Factories/DefaultHttpKeyedClientFactory.cs +++ b/src/Actions.HttpClient/Factories/DefaultHttpKeyedClientFactory.cs @@ -1,7 +1,9 @@ // Copyright (c) David Pine. All rights reserved. // Licensed under the MIT License. +#pragma warning disable IDE0130 // Namespace does not match folder structure namespace Actions.HttpClient; +#pragma warning restore IDE0130 // Namespace does not match folder structure internal sealed class DefaultHttpKeyedClientFactory( IHttpClientFactory clientFactory) : IHttpCredentialClientFactory diff --git a/src/Actions.HttpClient/Factories/IHttpCredentialClientFactory.cs b/src/Actions.HttpClient/Factories/IHttpCredentialClientFactory.cs index ccd3788..cea68ca 100644 --- a/src/Actions.HttpClient/Factories/IHttpCredentialClientFactory.cs +++ b/src/Actions.HttpClient/Factories/IHttpCredentialClientFactory.cs @@ -1,7 +1,9 @@ // Copyright (c) David Pine. All rights reserved. // Licensed under the MIT License. +#pragma warning disable IDE0130 // Namespace does not match folder structure namespace Actions.HttpClient; +#pragma warning restore IDE0130 // Namespace does not match folder structure /// /// Represents a factory for creating instances, given a set of credentials. diff --git a/src/Actions.IO/IOperations.cs b/src/Actions.IO/IOperations.cs index adaa0ef..e4f8284 100644 --- a/src/Actions.IO/IOperations.cs +++ b/src/Actions.IO/IOperations.cs @@ -56,8 +56,10 @@ void Remove(string path) /// Make a directory. Creates the full path with folders in between. /// /// Path to create. - void MakeDirectory(string path) => + void MakeDirectory(string path) + { Directory.CreateDirectory(path); + } /// /// Returns path of a tool had the tool actually been invoked. Resolves via PATH. diff --git a/src/Actions.IO/Operations.cs b/src/Actions.IO/Operations.cs index ca2601d..a0c06b0 100644 --- a/src/Actions.IO/Operations.cs +++ b/src/Actions.IO/Operations.cs @@ -7,10 +7,12 @@ namespace Actions.IO; internal sealed class Operations : IOperations { /// - public void Copy(string sourcePath, string destinationPath, CopyOptions? options = default) => + public void Copy(string sourcePath, string destinationPath, CopyOptions? options = default) + { CopyAll(sourcePath, destinationPath, options); + } - static void CopyAll(string sourcePath, string destinationPath, CopyOptions? options = default) + private static void CopyAll(string sourcePath, string destinationPath, CopyOptions? options = default) { var (recursive, force, copySourceDirectory) = (options ??= new(false)); diff --git a/src/Actions.IO/Utilities.cs b/src/Actions.IO/Utilities.cs index c0bae4e..170e030 100644 --- a/src/Actions.IO/Utilities.cs +++ b/src/Actions.IO/Utilities.cs @@ -35,12 +35,16 @@ public static class Utilities }); /// - public static bool Exists(string? path) => - File.Exists(path); + public static bool Exists(string? path) + { + return File.Exists(path); + } /// - public static bool IsRooted(string? path) => - Path.IsPathRooted(path); + public static bool IsRooted(string? path) + { + return Path.IsPathRooted(path); + } /// /// Indicates whether the given resolves as a directory. @@ -49,8 +53,10 @@ public static bool IsRooted(string? path) => /// when refers to a /// directory, else . public static bool IsDirectory( - [NotNullWhen(true)] string? path) => - Directory.Exists(path) && (File.GetAttributes(path!) & FileAttributes.Directory) is FileAttributes.Directory; + [NotNullWhen(true)] string? path) + { + return Directory.Exists(path) && (File.GetAttributes(path!) & FileAttributes.Directory) is FileAttributes.Directory; + } /// /// Best effort attempt to determine whether a file exists and is executable. @@ -82,6 +88,8 @@ public static string TryGetExecutablePath(string filePath, string[] extensions) return string.Empty; } - private static bool IsUnixExecutable(FileInfo file) => - file.Exists && (file.Attributes & FileAttributes.Archive) is FileAttributes.Archive; + private static bool IsUnixExecutable(FileInfo file) + { + return file.Exists && (file.Attributes & FileAttributes.Archive) is FileAttributes.Archive; + } } diff --git a/tests/Actions.Core.Tests/GlobalUsings.cs b/tests/Actions.Core.Tests/GlobalUsings.cs index 99bbd93..d7e336d 100644 --- a/tests/Actions.Core.Tests/GlobalUsings.cs +++ b/tests/Actions.Core.Tests/GlobalUsings.cs @@ -21,3 +21,9 @@ global using Xunit; global using static Actions.Core.EnvironmentVariables.Keys; + +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage( + "Performance", + "CA1859:Use concrete types when possible for improved performance", + Justification = "") +] diff --git a/tests/Actions.Core.Tests/Output/TestConsole.cs b/tests/Actions.Core.Tests/Output/TestConsole.cs index 74ae5b6..79368d8 100644 --- a/tests/Actions.Core.Tests/Output/TestConsole.cs +++ b/tests/Actions.Core.Tests/Output/TestConsole.cs @@ -11,18 +11,28 @@ internal sealed class TestConsole : IConsole public int ExitCode { get; internal set; } public bool Exited { get; internal set; } - public void ExitWithCode(int exitCode = 0) => + public void ExitWithCode(int exitCode = 0) + { (ExitCode, Exited) = (exitCode, true); + } - public void Write(string? message = null) => + public void Write(string? message = null) + { Output.Append(message); + } - public void WriteLine(string? message = null) => + public void WriteLine(string? message = null) + { Output.AppendLine(message); + } - public void WriteError(string message) => + public void WriteError(string message) + { ErrorOutput.Append(message); + } - public void WriteErrorLine(string message) => + public void WriteErrorLine(string message) + { ErrorOutput.AppendLine(message); + } } diff --git a/tests/Actions.Core.Tests/Services/CoreSummaryTestFixture.cs b/tests/Actions.Core.Tests/Services/CoreSummaryTestFixture.cs index 4cbdc7f..2c2a988 100644 --- a/tests/Actions.Core.Tests/Services/CoreSummaryTestFixture.cs +++ b/tests/Actions.Core.Tests/Services/CoreSummaryTestFixture.cs @@ -127,5 +127,8 @@ private void BeforeEach() File.WriteAllText(TestFilePath, ""); } - private void AfterEach() => File.Delete(TestFilePath); + private void AfterEach() + { + File.Delete(TestFilePath); + } } diff --git a/tests/Actions.Core.Tests/Services/CoreSummaryTests.cs b/tests/Actions.Core.Tests/Services/CoreSummaryTests.cs index e06d871..f4da53f 100644 --- a/tests/Actions.Core.Tests/Services/CoreSummaryTests.cs +++ b/tests/Actions.Core.Tests/Services/CoreSummaryTests.cs @@ -13,7 +13,9 @@ private async Task AssertSummary(string expected) } [Fact] - public Task ThrowsIfSummaryEnvVarIsUndefined() => fixture.TestAsync(async () => + public Task ThrowsIfSummaryEnvVarIsUndefined() + { + return fixture.TestAsync(async () => { Environment.SetEnvironmentVariable(GITHUB_STEP_SUMMARY, null); @@ -26,9 +28,12 @@ Task WriteAsync() await Assert.ThrowsAsync(WriteAsync); }); + } [Fact] - public Task ThrowsIfSummaryFileDoesNotExist() => fixture.TestAsync(async () => + public Task ThrowsIfSummaryFileDoesNotExist() + { + return fixture.TestAsync(async () => { File.Delete(fixture.TestFilePath); @@ -41,9 +46,12 @@ Task WriteAsync() await Assert.ThrowsAsync(WriteAsync); }); + } [Fact] - public Task AppendsTextToSummaryFile() => fixture.TestAsync(async () => + public Task AppendsTextToSummaryFile() + { + return fixture.TestAsync(async () => { await File.WriteAllTextAsync(fixture.TestFilePath, "# "); @@ -53,9 +61,12 @@ public Task AppendsTextToSummaryFile() => fixture.TestAsync(async () => await AssertSummary($"# {Environment.NewLine}{Environment.NewLine}{fixture.TestCase.Text}"); }); + } [Fact] - public Task OverwritesTextToSummaryFile() => fixture.TestAsync(async () => + public Task OverwritesTextToSummaryFile() + { + return fixture.TestAsync(async () => { await File.WriteAllTextAsync(fixture.TestFilePath, "overwrite"); @@ -65,9 +76,12 @@ public Task OverwritesTextToSummaryFile() => fixture.TestAsync(async () => await AssertSummary(fixture.TestCase.Text); }); + } [Fact] - public Task AppendsTextWithEOLToSummaryFile() => fixture.TestAsync(async () => + public Task AppendsTextWithEOLToSummaryFile() + { + return fixture.TestAsync(async () => { await File.WriteAllTextAsync(fixture.TestFilePath, "# "); @@ -77,9 +91,12 @@ public Task AppendsTextWithEOLToSummaryFile() => fixture.TestAsync(async () => await AssertSummary($"# {Environment.NewLine}{Environment.NewLine}{fixture.TestCase.Text}{Environment.NewLine}"); }); + } [Fact] - public Task ChainsAppendsTextToSummaryFile() => fixture.TestAsync(async () => + public Task ChainsAppendsTextToSummaryFile() + { + return fixture.TestAsync(async () => { await File.WriteAllTextAsync(fixture.TestFilePath, ""); @@ -93,9 +110,12 @@ await sut await AssertSummary(string.Join("", fixture.TestCase.Text, fixture.TestCase.Text, fixture.TestCase.Text)); }); + } [Fact] - public Task EmptiesBufferAfterWriteAsync() => fixture.TestAsync(async () => + public Task EmptiesBufferAfterWriteAsync() + { + return fixture.TestAsync(async () => { await File.WriteAllTextAsync(fixture.TestFilePath, ""); @@ -107,9 +127,12 @@ public Task EmptiesBufferAfterWriteAsync() => fixture.TestAsync(async () => Assert.True(sut.IsBufferEmpty); }); + } [Fact] - public void ReturnsSummaryBufferAsString() => fixture.Test(() => + public void ReturnsSummaryBufferAsString() + { + fixture.Test(() => { var sut = new Summary(); @@ -117,9 +140,12 @@ public void ReturnsSummaryBufferAsString() => fixture.Test(() => Assert.Equal(fixture.TestCase.Text, sut.Stringify()); }); + } [Fact] - public void ReturnsCorrectValuesForIsBufferEmpty() => fixture.Test(() => + public void ReturnsCorrectValuesForIsBufferEmpty() + { + fixture.Test(() => { var sut = new Summary(); @@ -131,9 +157,12 @@ public void ReturnsCorrectValuesForIsBufferEmpty() => fixture.Test(() => Assert.True(sut.IsBufferEmpty); }); + } [Fact] - public Task ClearsABufferAndSummaryFile() => fixture.TestAsync(async () => + public Task ClearsABufferAndSummaryFile() + { + return fixture.TestAsync(async () => { await File.WriteAllTextAsync(fixture.TestFilePath, "content", Encoding.UTF8); @@ -145,9 +174,12 @@ public Task ClearsABufferAndSummaryFile() => fixture.TestAsync(async () => Assert.True(sut.IsBufferEmpty); }); + } [Fact] - public Task AddsEOL() => fixture.TestAsync(async () => + public Task AddsEOL() + { + return fixture.TestAsync(async () => { var sut = new Summary(); @@ -155,9 +187,12 @@ public Task AddsEOL() => fixture.TestAsync(async () => await AssertSummary($"{fixture.TestCase.Text}{Environment.NewLine}"); }); + } [Fact] - public Task AddsACodeBlockWithoutLanguage() => fixture.TestAsync(async () => + public Task AddsACodeBlockWithoutLanguage() + { + return fixture.TestAsync(async () => { var sut = new Summary(); @@ -173,9 +208,12 @@ go fork() await AssertSummary(expected); }); + } [Fact] - public Task AddsMarkdownCodeBlockWithoutLanguage() => fixture.TestAsync(async () => + public Task AddsMarkdownCodeBlockWithoutLanguage() + { + return fixture.TestAsync(async () => { var sut = new Summary(); @@ -193,9 +231,12 @@ go fork() await AssertSummary(expected); }); + } [Fact] - public Task AddsACodeBlockWithALanguage() => fixture.TestAsync(async () => + public Task AddsACodeBlockWithALanguage() + { + return fixture.TestAsync(async () => { var sut = new Summary(); @@ -211,9 +252,12 @@ go fork() await AssertSummary(expected); }); + } [Fact] - public Task AddsMarkdownCodeBlockWithALanguage() => fixture.TestAsync(async () => + public Task AddsMarkdownCodeBlockWithALanguage() + { + return fixture.TestAsync(async () => { var sut = new Summary(); @@ -231,9 +275,12 @@ go fork() await AssertSummary(expected); }); + } [Fact] - public Task AddsAnUnorderedList() => fixture.TestAsync(async () => + public Task AddsAnUnorderedList() + { + return fixture.TestAsync(async () => { var sut = new Summary(); @@ -243,9 +290,12 @@ public Task AddsAnUnorderedList() => fixture.TestAsync(async () => await AssertSummary(expected); }); + } [Fact] - public Task AddsMarkdownUnorderedList() => fixture.TestAsync(async () => + public Task AddsMarkdownUnorderedList() + { + return fixture.TestAsync(async () => { var sut = new Summary(); @@ -255,9 +305,12 @@ public Task AddsMarkdownUnorderedList() => fixture.TestAsync(async () => await AssertSummary(expected); }); + } [Fact] - public Task AddsAnOrderedList() => fixture.TestAsync(async () => + public Task AddsAnOrderedList() + { + return fixture.TestAsync(async () => { var sut = new Summary(); @@ -267,9 +320,12 @@ public Task AddsAnOrderedList() => fixture.TestAsync(async () => await AssertSummary(expected); }); + } [Fact] - public Task AddsMarkdownOrderedList() => fixture.TestAsync(async () => + public Task AddsMarkdownOrderedList() + { + return fixture.TestAsync(async () => { var sut = new Summary(); @@ -279,9 +335,12 @@ public Task AddsMarkdownOrderedList() => fixture.TestAsync(async () => await AssertSummary(expected); }); + } [Fact] - public Task AddsMarkdownTaskList() => fixture.TestAsync(async () => + public Task AddsMarkdownTaskList() + { + return fixture.TestAsync(async () => { var sut = new Summary(); @@ -291,9 +350,12 @@ public Task AddsMarkdownTaskList() => fixture.TestAsync(async () => await AssertSummary(expected); }); + } [Fact] - public Task AddsATable() => fixture.TestAsync(async () => + public Task AddsATable() + { + return fixture.TestAsync(async () => { var sut = new Summary(); @@ -303,9 +365,12 @@ public Task AddsATable() => fixture.TestAsync(async () => await AssertSummary(expected); }); + } [Fact] - public Task AddsMarkdownTable() => fixture.TestAsync(async () => + public Task AddsMarkdownTable() + { + return fixture.TestAsync(async () => { var sut = new Summary(); @@ -315,9 +380,12 @@ public Task AddsMarkdownTable() => fixture.TestAsync(async () => await AssertSummary(expected); }); + } [Fact] - public Task AddsADetailsElement() => fixture.TestAsync(async () => + public Task AddsADetailsElement() + { + return fixture.TestAsync(async () => { var sut = new Summary(); @@ -329,9 +397,12 @@ await sut await AssertSummary(expected); }); + } [Fact] - public Task AddsAnImageWithAltText() => fixture.TestAsync(async () => + public Task AddsAnImageWithAltText() + { + return fixture.TestAsync(async () => { var sut = new Summary(); @@ -341,9 +412,12 @@ public Task AddsAnImageWithAltText() => fixture.TestAsync(async () => await AssertSummary(expected); }); + } [Fact] - public Task AddsAnImageWithCustomDimensions() => fixture.TestAsync(async () => + public Task AddsAnImageWithCustomDimensions() + { + return fixture.TestAsync(async () => { var sut = new Summary(); @@ -355,9 +429,12 @@ await sut await AssertSummary(expected); }); + } [Fact] - public Task AddsHeadingsH1ToH6() => fixture.TestAsync(async () => + public Task AddsHeadingsH1ToH6() + { + return fixture.TestAsync(async () => { var sut = new Summary(); for (var i = 1; i <= 6; i++) @@ -371,9 +448,12 @@ public Task AddsHeadingsH1ToH6() => fixture.TestAsync(async () => await AssertSummary(expected); }); + } [Fact] - public Task AddsMarkdownHeadingsH1ToH6() => fixture.TestAsync(async () => + public Task AddsMarkdownHeadingsH1ToH6() + { + return fixture.TestAsync(async () => { var sut = new Summary(); for (var i = 1; i <= 6; i++) @@ -387,9 +467,12 @@ public Task AddsMarkdownHeadingsH1ToH6() => fixture.TestAsync(async () => await AssertSummary(expected); }); + } [Fact] - public Task AddsCorrectSpacingBetweenHtmlAndMarkdown() => fixture.TestAsync(async () => + public Task AddsCorrectSpacingBetweenHtmlAndMarkdown() + { + return fixture.TestAsync(async () => { var sut = new Summary(); @@ -405,9 +488,12 @@ public Task AddsCorrectSpacingBetweenHtmlAndMarkdown() => fixture.TestAsync(asyn await AssertSummary(expected); }); + } [Fact] - public Task AddsH1IfHeadingLevelNotSpecified() => fixture.TestAsync(async () => + public Task AddsH1IfHeadingLevelNotSpecified() + { + return fixture.TestAsync(async () => { var sut = new Summary(); @@ -417,9 +503,12 @@ public Task AddsH1IfHeadingLevelNotSpecified() => fixture.TestAsync(async () => await AssertSummary(expected); }); + } [Fact] - public Task AddsMarkdownH1IfHeadingLevelNotSpecified() => fixture.TestAsync(async () => + public Task AddsMarkdownH1IfHeadingLevelNotSpecified() + { + return fixture.TestAsync(async () => { var sut = new Summary(); @@ -429,9 +518,12 @@ public Task AddsMarkdownH1IfHeadingLevelNotSpecified() => fixture.TestAsync(asyn await AssertSummary(expected); }); + } [Fact] - public Task UsesH1IfHeadingLevelIsGarbageOrOutOfRange() => fixture.TestAsync(async () => + public Task UsesH1IfHeadingLevelIsGarbageOrOutOfRange() + { + return fixture.TestAsync(async () => { var sut = new Summary(); @@ -443,9 +535,12 @@ await sut.AddHeading("heading", 1337) await AssertSummary(expected); }); + } [Fact] - public Task UsesMarkdownH1IfHeadingLevelIsGarbageOrOutOfRange() => fixture.TestAsync(async () => + public Task UsesMarkdownH1IfHeadingLevelIsGarbageOrOutOfRange() + { + return fixture.TestAsync(async () => { var sut = new Summary(); @@ -457,9 +552,12 @@ await sut.AddMarkdownHeading("heading", 1337) await AssertSummary(expected); }); + } [Fact] - public Task AddsASeparator() => fixture.TestAsync(async () => + public Task AddsASeparator() + { + return fixture.TestAsync(async () => { var sut = new Summary(); @@ -469,9 +567,12 @@ public Task AddsASeparator() => fixture.TestAsync(async () => await AssertSummary(expected); }); + } [Fact] - public Task AddsMarkdownSeparator() => fixture.TestAsync(async () => + public Task AddsMarkdownSeparator() + { + return fixture.TestAsync(async () => { var sut = new Summary(); @@ -481,9 +582,12 @@ public Task AddsMarkdownSeparator() => fixture.TestAsync(async () => await AssertSummary(expected); }); + } [Fact] - public Task AddsABreak() => fixture.TestAsync(async () => + public Task AddsABreak() + { + return fixture.TestAsync(async () => { var sut = new Summary(); @@ -493,9 +597,12 @@ public Task AddsABreak() => fixture.TestAsync(async () => await AssertSummary(expected); }); + } [Fact] - public Task AddsAQuote() => fixture.TestAsync(async () => + public Task AddsAQuote() + { + return fixture.TestAsync(async () => { var sut = new Summary(); @@ -505,9 +612,12 @@ public Task AddsAQuote() => fixture.TestAsync(async () => await AssertSummary(expected); }); + } [Fact] - public Task AddsMarkdownQuote() => fixture.TestAsync(async () => + public Task AddsMarkdownQuote() + { + return fixture.TestAsync(async () => { var sut = new Summary(); @@ -517,9 +627,12 @@ public Task AddsMarkdownQuote() => fixture.TestAsync(async () => await AssertSummary(expected); }); + } [Fact] - public Task AddsAQuoteWithCitation() => fixture.TestAsync(async () => + public Task AddsAQuoteWithCitation() + { + return fixture.TestAsync(async () => { var sut = new Summary(); @@ -529,9 +642,12 @@ public Task AddsAQuoteWithCitation() => fixture.TestAsync(async () => await AssertSummary(expected); }); + } [Fact] - public Task AddsALinkWithHref() => fixture.TestAsync(async () => + public Task AddsALinkWithHref() + { + return fixture.TestAsync(async () => { var sut = new Summary(); @@ -541,9 +657,12 @@ public Task AddsALinkWithHref() => fixture.TestAsync(async () => await AssertSummary(expected); }); + } [Fact] - public Task AddsMarkdownLinkWithHref() => fixture.TestAsync(async () => + public Task AddsMarkdownLinkWithHref() + { + return fixture.TestAsync(async () => { var sut = new Summary(); @@ -553,4 +672,5 @@ public Task AddsMarkdownLinkWithHref() => fixture.TestAsync(async () => await AssertSummary(expected); }); + } } diff --git a/tests/Actions.Glob.Tests/Extensions/StringExtensionTests.cs b/tests/Actions.Glob.Tests/Extensions/StringExtensionTests.cs index a5d850e..24a3aee 100644 --- a/tests/Actions.Glob.Tests/Extensions/StringExtensionTests.cs +++ b/tests/Actions.Glob.Tests/Extensions/StringExtensionTests.cs @@ -5,7 +5,7 @@ namespace Actions.Glob.Tests; public sealed class StringExtensionsTests { - public readonly static TheoryData GetGlobResultTestInput = + public static readonly TheoryData GetGlobResultTestInput = new() { { diff --git a/tests/Actions.Glob.Tests/GlobPatternBuilderTests.cs b/tests/Actions.Glob.Tests/GlobPatternBuilderTests.cs index 7b11ab2..fe9b43b 100644 --- a/tests/Actions.Glob.Tests/GlobPatternBuilderTests.cs +++ b/tests/Actions.Glob.Tests/GlobPatternBuilderTests.cs @@ -6,9 +6,11 @@ namespace Actions.Glob.Tests; public sealed class GlobPatternBuilderTests { [Fact] - public void GlobPatternBuilderThrowsWithoutIncludeOrExcludePatternsTest() => + public void GlobPatternBuilderThrowsWithoutIncludeOrExcludePatternsTest() + { Assert.Throws( () => new DefaultGlobPatternResolverBuilder().Build()); + } [Fact] public void GlobPatternBuilderYieldsWorkingResolver() diff --git a/tests/Actions.IO.Tests/TempFolderTestFixture.cs b/tests/Actions.IO.Tests/TempFolderTestFixture.cs index 786216d..bf362f9 100644 --- a/tests/Actions.IO.Tests/TempFolderTestFixture.cs +++ b/tests/Actions.IO.Tests/TempFolderTestFixture.cs @@ -10,5 +10,8 @@ public sealed class TempFolderTestFixture : IDisposable ) .FullName; - void IDisposable.Dispose() => Directory.Delete(TempFolder, true); + void IDisposable.Dispose() + { + Directory.Delete(TempFolder, true); + } } \ No newline at end of file diff --git a/tests/Actions.Octokit.Tests/GitHubClientFactoryTests.cs b/tests/Actions.Octokit.Tests/GitHubClientFactoryTests.cs index 5588b23..0562a47 100644 --- a/tests/Actions.Octokit.Tests/GitHubClientFactoryTests.cs +++ b/tests/Actions.Octokit.Tests/GitHubClientFactoryTests.cs @@ -6,18 +6,26 @@ namespace Actions.Octokit.Tests; public class GitHubClientFactoryTests { [Fact] - public void CreateThrowsOnNullToken() => + public void CreateThrowsOnNullToken() + { Assert.Throws(() => GitHubClientFactory.Create(null!)); + } [Fact] - public void CreateThrowsOnEmptyToken() => + public void CreateThrowsOnEmptyToken() + { Assert.Throws(() => GitHubClientFactory.Create(string.Empty)); + } [Fact] - public void CreateThrowsOnWhitespaceToken() => + public void CreateThrowsOnWhitespaceToken() + { Assert.Throws(() => GitHubClientFactory.Create(" ")); + } [Fact] - public void CreateReturnsClientOnFakeToken() => + public void CreateReturnsClientOnFakeToken() + { Assert.NotNull(GitHubClientFactory.Create("token")); + } } diff --git a/tests/Actions.Octokit.Tests/GitHubClientTests.cs b/tests/Actions.Octokit.Tests/GitHubClientTests.cs index d1bc5a0..943285b 100644 --- a/tests/Actions.Octokit.Tests/GitHubClientTests.cs +++ b/tests/Actions.Octokit.Tests/GitHubClientTests.cs @@ -1,8 +1,6 @@ // Copyright (c) David Pine. All rights reserved. // Licensed under the MIT License. -using System.Diagnostics; - namespace Actions.Octokit.Tests; public class GitHubClientTests @@ -90,6 +88,6 @@ public async Task GitHubClientGetsIssueCommentTest() catch (Exception ex) { Assert.Fail(ex.Message); - } + } } }