diff --git a/.editorconfig b/.editorconfig index 15950d2..8738748 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,6 +11,7 @@ indent_style = space trim_trailing_whitespace = true charset = utf-8 end_of_line = lf +max_line_length = 120 # Verify settings # https://github.com/VerifyTests/Verify?tab=readme-ov-file#text-file-settings diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 4dc77e2..b187e7c 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -22,7 +22,7 @@ jobs: all: if: github.run_id != 1 name: Build & Tests - uses: dailydevops/pipelines/.github/workflows/cicd-dotnet.yml@0.14.68 + uses: dailydevops/pipelines/.github/workflows/cicd-dotnet.yml@0.14.82 with: enableSonarQube: true dotnet-logging: ${{ inputs.dotnet-logging }} diff --git a/Directory.Build.props b/Directory.Build.props index bf585df..f7d68f8 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,4 @@ - $(MSBuildProjectName) Extensions for `ILogger` implementations to log messages to xUnit test output. @@ -8,20 +7,15 @@ $(RepositoryUrl)/releases/tag/$(Version) logging;provider;xunit 2024 - true - net6.0;net7.0;net8.0;net9.0 net6.0;net7.0;net8.0;net9.0 - true - net8.0 - diff --git a/Directory.Packages.props b/Directory.Packages.props index 34f8d0b..81938a7 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -4,14 +4,18 @@ true - + - - + + diff --git a/nuget.config b/nuget.config index 5290396..51b2271 100644 --- a/nuget.config +++ b/nuget.config @@ -5,7 +5,6 @@ - @@ -13,7 +12,6 @@ - diff --git a/src/NetEvolve.Logging.XUnit/NetEvolve.Logging.XUnit.csproj b/src/NetEvolve.Logging.XUnit/NetEvolve.Logging.XUnit.csproj index 494946a..a08c77d 100644 --- a/src/NetEvolve.Logging.XUnit/NetEvolve.Logging.XUnit.csproj +++ b/src/NetEvolve.Logging.XUnit/NetEvolve.Logging.XUnit.csproj @@ -1,13 +1,14 @@ - $(ProjectTargetFrameworks) enable enable - - + @@ -15,5 +16,4 @@ - diff --git a/src/NetEvolve.Logging.XUnit/XUnitLogger.cs b/src/NetEvolve.Logging.XUnit/XUnitLogger.cs index 2df8046..dca1c1c 100644 --- a/src/NetEvolve.Logging.XUnit/XUnitLogger.cs +++ b/src/NetEvolve.Logging.XUnit/XUnitLogger.cs @@ -86,8 +86,7 @@ public static XUnitLogger CreateLogger( IExternalScopeProvider? scopeProvider = null, IXUnitLoggerOptions? options = null ) - where T : notnull => - CreateLogger(messageSink, TimeProvider.System, scopeProvider, options); + where T : notnull => CreateLogger(messageSink, TimeProvider.System, scopeProvider, options); /// /// Creates a new instance of . @@ -159,8 +158,7 @@ public static XUnitLogger CreateLogger( IExternalScopeProvider? scopeProvider = null, IXUnitLoggerOptions? options = null ) - where T : notnull => - CreateLogger(testOutputHelper, TimeProvider.System, scopeProvider, options); + where T : notnull => CreateLogger(testOutputHelper, TimeProvider.System, scopeProvider, options); /// /// Creates a new instance of . @@ -233,9 +231,7 @@ public void Log( var now = _timeProvider.GetLocalNow(); var (fullMessage, scopes) = CreateMessage(logLevel, state, exception, message, now); - _loggedMessages.Add( - new LoggedMessage(now, logLevel, eventId, message, exception, scopes) - ); + _loggedMessages.Add(new LoggedMessage(now, logLevel, eventId, message, exception, scopes)); _writeToLog.Invoke(fullMessage); } @@ -263,9 +259,7 @@ DateTimeOffset now { if (!_options.DisableTimestamp) { - _ = builder - .Append(now.ToString(_options.TimestampFormat, CultureInfo.InvariantCulture)) - .Append(' '); + _ = builder.Append(now.ToString(_options.TimestampFormat, CultureInfo.InvariantCulture)).Append(' '); } if (!_options.DisableLogLevel) @@ -341,10 +335,8 @@ private static void PrintScope(object? scope, StringBuilder state) : state.Append(scope); } - private static void AddAdditionalInformation( - StringBuilder builder, - KeyValuePair info - ) => _ = builder.Append('\n').Append(' ', 4).Append(info.Key).Append(": ").Append(info.Value); + private static void AddAdditionalInformation(StringBuilder builder, KeyValuePair info) => + _ = builder.Append('\n').Append(' ', 4).Append(info.Key).Append(": ").Append(info.Value); #pragma warning disable IDE0072 // Add missing cases internal static string LogLevelToString(LogLevel logLevel) => @@ -382,12 +374,7 @@ public override string ToString() if (!_options.DisableTimestamp) { _ = builder - .Append( - lmsg.Timestamp.ToString( - _options.TimestampFormat, - CultureInfo.InvariantCulture - ) - ) + .Append(lmsg.Timestamp.ToString(_options.TimestampFormat, CultureInfo.InvariantCulture)) .Append(' '); } diff --git a/src/NetEvolve.Logging.XUnit/XUnitLoggerExtensions.cs b/src/NetEvolve.Logging.XUnit/XUnitLoggerExtensions.cs index f3f2153..4946ee8 100644 --- a/src/NetEvolve.Logging.XUnit/XUnitLoggerExtensions.cs +++ b/src/NetEvolve.Logging.XUnit/XUnitLoggerExtensions.cs @@ -27,14 +27,12 @@ public static ILoggingBuilder AddXUnit( services.TryAddSingleton(_ => TimeProvider.System); services.TryAddScoped(); services.TryAddEnumerable( - ServiceDescriptor.Singleton( - sp => new XUnitLoggerProvider( - sp.GetRequiredService(), - sp.GetRequiredService(), - sp.GetRequiredService(), - options ?? XUnitLoggerOptions.Default - ) - ) + ServiceDescriptor.Singleton(sp => new XUnitLoggerProvider( + sp.GetRequiredService(), + sp.GetRequiredService(), + sp.GetRequiredService(), + options ?? XUnitLoggerOptions.Default + )) ); return builder; @@ -56,14 +54,12 @@ public static ILoggingBuilder AddXUnit( services.TryAddSingleton(_ => TimeProvider.System); services.TryAddScoped(); services.TryAddEnumerable( - ServiceDescriptor.Singleton( - sp => new XUnitLoggerProvider( - sp.GetRequiredService(), - sp.GetRequiredService(), - sp.GetRequiredService(), - options ?? XUnitLoggerOptions.Default - ) - ) + ServiceDescriptor.Singleton(sp => new XUnitLoggerProvider( + sp.GetRequiredService(), + sp.GetRequiredService(), + sp.GetRequiredService(), + options ?? XUnitLoggerOptions.Default + )) ); return builder; diff --git a/src/NetEvolve.Logging.XUnit/XUnitLoggerOptions.cs b/src/NetEvolve.Logging.XUnit/XUnitLoggerOptions.cs index a89d72a..cca279f 100644 --- a/src/NetEvolve.Logging.XUnit/XUnitLoggerOptions.cs +++ b/src/NetEvolve.Logging.XUnit/XUnitLoggerOptions.cs @@ -62,9 +62,7 @@ public class XUnitLoggerOptions : IXUnitLoggerOptions /// #if NET7_0_OR_GREATER - [System.Diagnostics.CodeAnalysis.StringSyntax( - System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.DateTimeFormat - )] + [System.Diagnostics.CodeAnalysis.StringSyntax(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.DateTimeFormat)] #endif public string TimestampFormat { diff --git a/src/NetEvolve.Logging.XUnit/XUnitLoggerProvider.cs b/src/NetEvolve.Logging.XUnit/XUnitLoggerProvider.cs index 3999b46..5d268cc 100644 --- a/src/NetEvolve.Logging.XUnit/XUnitLoggerProvider.cs +++ b/src/NetEvolve.Logging.XUnit/XUnitLoggerProvider.cs @@ -10,10 +10,7 @@ using Xunit.Sdk; [ProviderAlias("XUnit")] -internal sealed class XUnitLoggerProvider - : ILoggerProvider, - ISupportExternalScope, - IXUnitLoggerOptions +internal sealed class XUnitLoggerProvider : ILoggerProvider, ISupportExternalScope, IXUnitLoggerOptions { private readonly Action _writeToAction; diff --git a/tests/NetEvolve.Logging.XUnit.Tests.Integration/NetEvolve.Logging.XUnit.Tests.Integration.csproj b/tests/NetEvolve.Logging.XUnit.Tests.Integration/NetEvolve.Logging.XUnit.Tests.Integration.csproj index 08b60ce..55b6fb9 100644 --- a/tests/NetEvolve.Logging.XUnit.Tests.Integration/NetEvolve.Logging.XUnit.Tests.Integration.csproj +++ b/tests/NetEvolve.Logging.XUnit.Tests.Integration/NetEvolve.Logging.XUnit.Tests.Integration.csproj @@ -1,9 +1,7 @@ - $(TestTargetFrameworks) - all @@ -22,9 +20,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - - diff --git a/tests/NetEvolve.Logging.XUnit.Tests.Integration/XUnitLoggerExtensionsTests.cs b/tests/NetEvolve.Logging.XUnit.Tests.Integration/XUnitLoggerExtensionsTests.cs index f98e716..04eff6a 100644 --- a/tests/NetEvolve.Logging.XUnit.Tests.Integration/XUnitLoggerExtensionsTests.cs +++ b/tests/NetEvolve.Logging.XUnit.Tests.Integration/XUnitLoggerExtensionsTests.cs @@ -8,8 +8,7 @@ public partial class XUnitLoggerExtensionsTests { private readonly ITestOutputHelper _testOutputHelper; - public XUnitLoggerExtensionsTests(ITestOutputHelper testOutputHelper) => - _testOutputHelper = testOutputHelper; + public XUnitLoggerExtensionsTests(ITestOutputHelper testOutputHelper) => _testOutputHelper = testOutputHelper; [Theory] [MemberData(nameof(AddXUnitData))] diff --git a/tests/NetEvolve.Logging.XUnit.Tests.Integration/XUnitLoggerTests.cs b/tests/NetEvolve.Logging.XUnit.Tests.Integration/XUnitLoggerTests.cs index 9d4b489..06bad2d 100644 --- a/tests/NetEvolve.Logging.XUnit.Tests.Integration/XUnitLoggerTests.cs +++ b/tests/NetEvolve.Logging.XUnit.Tests.Integration/XUnitLoggerTests.cs @@ -15,8 +15,7 @@ public partial class XUnitLoggerTests ); private readonly ITestOutputHelper _testOutputHelper; - public XUnitLoggerTests(ITestOutputHelper testOutputHelper) => - _testOutputHelper = testOutputHelper; + public XUnitLoggerTests(ITestOutputHelper testOutputHelper) => _testOutputHelper = testOutputHelper; [Fact] public void LoggedMessages_Empty_Expected() diff --git a/tests/NetEvolve.Logging.XUnit.Tests.Integration/XUnitLoggerWithFixtureTests.cs b/tests/NetEvolve.Logging.XUnit.Tests.Integration/XUnitLoggerWithFixtureTests.cs index 0f4d0e5..d1c5fb7 100644 --- a/tests/NetEvolve.Logging.XUnit.Tests.Integration/XUnitLoggerWithFixtureTests.cs +++ b/tests/NetEvolve.Logging.XUnit.Tests.Integration/XUnitLoggerWithFixtureTests.cs @@ -56,12 +56,7 @@ bool disableTimestamp _ = await Verifier .Verify(logger.LoggedMessages) .HashParameters() - .UseParameters( - disableAdditionalInformation, - disableLogLevel, - disableScopes, - disableTimestamp - ); + .UseParameters(disableAdditionalInformation, disableLogLevel, disableScopes, disableTimestamp); } [Theory] @@ -96,12 +91,7 @@ bool disableTimestamp _ = await Verifier .Verify(logger.ToString()) .HashParameters() - .UseParameters( - disableAdditionalInformation, - disableLogLevel, - disableScopes, - disableTimestamp - ); + .UseParameters(disableAdditionalInformation, disableLogLevel, disableScopes, disableTimestamp); } [Theory] @@ -139,12 +129,7 @@ bool disableTimestamp _ = await Verifier .Verify(logger.LoggedMessages) .HashParameters() - .UseParameters( - disableAdditionalInformation, - disableLogLevel, - disableScopes, - disableTimestamp - ); + .UseParameters(disableAdditionalInformation, disableLogLevel, disableScopes, disableTimestamp); } [Theory] @@ -182,12 +167,7 @@ bool disableTimestamp _ = await Verifier .Verify(logger.ToString()) .HashParameters() - .UseParameters( - disableAdditionalInformation, - disableLogLevel, - disableScopes, - disableTimestamp - ); + .UseParameters(disableAdditionalInformation, disableLogLevel, disableScopes, disableTimestamp); } [Theory] @@ -225,12 +205,7 @@ bool disableTimestamp _ = await Verifier .Verify(logger.LoggedMessages) .HashParameters() - .UseParameters( - disableAdditionalInformation, - disableLogLevel, - disableScopes, - disableTimestamp - ); + .UseParameters(disableAdditionalInformation, disableLogLevel, disableScopes, disableTimestamp); } [Theory] @@ -268,12 +243,7 @@ bool disableTimestamp _ = await Verifier .Verify(logger.ToString()) .HashParameters() - .UseParameters( - disableAdditionalInformation, - disableLogLevel, - disableScopes, - disableTimestamp - ); + .UseParameters(disableAdditionalInformation, disableLogLevel, disableScopes, disableTimestamp); } public static TheoryData LoggedMessageOrToStringData => diff --git a/tests/NetEvolve.Logging.XUnit.Tests.Unit/NetEvolve.Logging.XUnit.Tests.Unit.csproj b/tests/NetEvolve.Logging.XUnit.Tests.Unit/NetEvolve.Logging.XUnit.Tests.Unit.csproj index 4d394ed..4454239 100644 --- a/tests/NetEvolve.Logging.XUnit.Tests.Unit/NetEvolve.Logging.XUnit.Tests.Unit.csproj +++ b/tests/NetEvolve.Logging.XUnit.Tests.Unit/NetEvolve.Logging.XUnit.Tests.Unit.csproj @@ -1,9 +1,7 @@ - $(TestTargetFrameworks) - all @@ -21,9 +19,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - - diff --git a/tests/NetEvolve.Logging.XUnit.Tests.Unit/XUnitLoggerExtensionsTests.cs b/tests/NetEvolve.Logging.XUnit.Tests.Unit/XUnitLoggerExtensionsTests.cs index 8d86261..5f4feb9 100644 --- a/tests/NetEvolve.Logging.XUnit.Tests.Unit/XUnitLoggerExtensionsTests.cs +++ b/tests/NetEvolve.Logging.XUnit.Tests.Unit/XUnitLoggerExtensionsTests.cs @@ -10,8 +10,7 @@ public class XUnitLoggerExtensionsTests { private readonly ITestOutputHelper _testOutputHelper; - public XUnitLoggerExtensionsTests(ITestOutputHelper testOutputHelper) => - _testOutputHelper = testOutputHelper; + public XUnitLoggerExtensionsTests(ITestOutputHelper testOutputHelper) => _testOutputHelper = testOutputHelper; [Fact] public void AddXUnit_WithNullBuilder_ThrowArgumentNullException() diff --git a/tests/NetEvolve.Logging.XUnit.Tests.Unit/XUnitLoggerProviderTests.cs b/tests/NetEvolve.Logging.XUnit.Tests.Unit/XUnitLoggerProviderTests.cs index ceee635..4636066 100644 --- a/tests/NetEvolve.Logging.XUnit.Tests.Unit/XUnitLoggerProviderTests.cs +++ b/tests/NetEvolve.Logging.XUnit.Tests.Unit/XUnitLoggerProviderTests.cs @@ -10,8 +10,7 @@ public class XUnitLoggerProviderTests { private readonly ITestOutputHelper _testOutputHelper; - public XUnitLoggerProviderTests(ITestOutputHelper testOutputHelper) => - _testOutputHelper = testOutputHelper; + public XUnitLoggerProviderTests(ITestOutputHelper testOutputHelper) => _testOutputHelper = testOutputHelper; [Fact] public void CreateLogger_WithTestOutputHelper() @@ -64,9 +63,7 @@ public void SetScopeProvider_WithNullScopeProvider_NoExceptionThrown() _ = provider.CreateLogger(); // Act - var ex = Record.Exception( - () => provider.SetScopeProvider(NullExternalScopeProvider.Instance) - ); + var ex = Record.Exception(() => provider.SetScopeProvider(NullExternalScopeProvider.Instance)); // Assert Assert.Null(ex); diff --git a/tests/NetEvolve.Logging.XUnit.Tests.Unit/XUnitLoggerTests.cs b/tests/NetEvolve.Logging.XUnit.Tests.Unit/XUnitLoggerTests.cs index 01a3b44..71b9c62 100644 --- a/tests/NetEvolve.Logging.XUnit.Tests.Unit/XUnitLoggerTests.cs +++ b/tests/NetEvolve.Logging.XUnit.Tests.Unit/XUnitLoggerTests.cs @@ -37,10 +37,7 @@ public void CreateLogger_WithMessageSinkNull_ThrowsArgumentNullException() { IMessageSink messageSink = null!; - _ = Assert.Throws( - "messageSink", - () => XUnitLogger.CreateLogger(messageSink) - ); + _ = Assert.Throws("messageSink", () => XUnitLogger.CreateLogger(messageSink)); } [Fact] @@ -107,10 +104,7 @@ public void CreateLogger_WithTestOutputHelperNull_ThrowsArgumentNullException() { ITestOutputHelper testOutputHelper = null!; - _ = Assert.Throws( - "testOutputHelper", - () => XUnitLogger.CreateLogger(testOutputHelper) - ); + _ = Assert.Throws("testOutputHelper", () => XUnitLogger.CreateLogger(testOutputHelper)); } [Fact]