From d56d1a38ea2c79f018fc9813e744af2d83bfc932 Mon Sep 17 00:00:00 2001 From: Stijn Moreels <9039753+stijnmoreels@users.noreply.github.com> Date: Wed, 27 Nov 2024 14:17:26 +0100 Subject: [PATCH] chore: deprecate serilog functionality (#231) --- .../Arcus.Testing.Logging.Core.csproj | 21 ++++----------- .../InMemoryLogSink.cs | 1 + .../Extensions/ILoggerBuilderExtensions.cs | 13 +++------- .../LoggerSinkConfigurationExtensions.cs | 1 + .../MSTestLogEventSink.cs | 1 + .../Extensions/ILoggerBuilderExtensions.cs | 26 +++++-------------- .../LoggerSinkConfigurationExtensions.cs | 2 ++ .../NUnitTestLogEventSink.cs | 1 + .../Extensions/ILoggerBuilderExtensions.cs | 13 +++------- .../LoggerSinkConfigurationExtensions.cs | 1 + .../XunitTestLogEventSink.cs | 1 + 11 files changed, 25 insertions(+), 56 deletions(-) diff --git a/src/Arcus.Testing.Logging.Core/Arcus.Testing.Logging.Core.csproj b/src/Arcus.Testing.Logging.Core/Arcus.Testing.Logging.Core.csproj index 71bea223..1d1017d0 100644 --- a/src/Arcus.Testing.Logging.Core/Arcus.Testing.Logging.Core.csproj +++ b/src/Arcus.Testing.Logging.Core/Arcus.Testing.Logging.Core.csproj @@ -7,28 +7,17 @@ Arcus Provides logging capabilities during Arcus testing Copyright (c) Arcus - https://github.com/arcus-azure/arcus.testing - https://github.com/arcus-azure/arcus.testing - LICENSE - icon.png - README.md - Git - Azure;Testing - Arcus.Testing.Logging.Core - true - true + false + false true - - - - - - + + + diff --git a/src/Arcus.Testing.Logging.Core/InMemoryLogSink.cs b/src/Arcus.Testing.Logging.Core/InMemoryLogSink.cs index a8d9c6af..ace94766 100644 --- a/src/Arcus.Testing.Logging.Core/InMemoryLogSink.cs +++ b/src/Arcus.Testing.Logging.Core/InMemoryLogSink.cs @@ -10,6 +10,7 @@ namespace Arcus.Testing /// /// Represents a logging sink that collects the emitted log events in-memory. /// + [Obsolete("Arcus.Testing.Logging.Core will stop supporting Serilog by default, please implement Serilog sinks yourself as this sink will be removed in v2.0")] public class InMemoryLogSink : ILogEventSink { private readonly ConcurrentQueue _logEmits = new ConcurrentQueue(); diff --git a/src/Arcus.Testing.Logging.MSTest/Extensions/ILoggerBuilderExtensions.cs b/src/Arcus.Testing.Logging.MSTest/Extensions/ILoggerBuilderExtensions.cs index 4cc62a86..ba3399c6 100644 --- a/src/Arcus.Testing.Logging.MSTest/Extensions/ILoggerBuilderExtensions.cs +++ b/src/Arcus.Testing.Logging.MSTest/Extensions/ILoggerBuilderExtensions.cs @@ -12,22 +12,15 @@ namespace Microsoft.Extensions.Logging public static class ILoggerBuilderExtensions { /// - /// Adds an the logging messages from the given xUnit as a provider to the . + /// Adds the logging messages from the given xUnit as a provider to the . /// /// The logging builder to add the NUnit logging test messages to. /// The MSTest writer to write custom test output. /// Thrown when the or the is null. public static ILoggingBuilder AddMSTestLogging(this ILoggingBuilder builder, TestContext testContext) { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - if (testContext is null) - { - throw new ArgumentNullException(nameof(testContext)); - } + ArgumentNullException.ThrowIfNull(builder); + ArgumentNullException.ThrowIfNull(testContext); var logger = new MSTestLogger(testContext); var provider = new CustomLoggerProvider(logger); diff --git a/src/Arcus.Testing.Logging.MSTest/Extensions/LoggerSinkConfigurationExtensions.cs b/src/Arcus.Testing.Logging.MSTest/Extensions/LoggerSinkConfigurationExtensions.cs index cf6fd440..41f99c71 100644 --- a/src/Arcus.Testing.Logging.MSTest/Extensions/LoggerSinkConfigurationExtensions.cs +++ b/src/Arcus.Testing.Logging.MSTest/Extensions/LoggerSinkConfigurationExtensions.cs @@ -16,6 +16,7 @@ public static class LoggerSinkConfigurationExtensions /// The Serilog sink configuration where the NUnit test logging will be added. /// The MSTest test writer to write custom test output. /// Thrown when the or is null. + [Obsolete("Arcus.Testing.Logging.MSTest will stop supporting Serilog by default, please implement Serilog sinks yourself as this extension will be removed in v2.0")] public static LoggerConfiguration MSTestLogging(this LoggerSinkConfiguration config, TestContext testContext) { if (config is null) diff --git a/src/Arcus.Testing.Logging.MSTest/MSTestLogEventSink.cs b/src/Arcus.Testing.Logging.MSTest/MSTestLogEventSink.cs index 734b9a87..237e981b 100644 --- a/src/Arcus.Testing.Logging.MSTest/MSTestLogEventSink.cs +++ b/src/Arcus.Testing.Logging.MSTest/MSTestLogEventSink.cs @@ -8,6 +8,7 @@ namespace Arcus.Testing /// /// representation of an instance. /// + [Obsolete("Arcus.Testing.Logging.MSTest will stop supporting Serilog by default, please implement Serilog sinks yourself as this sink will be removed in v2.0")] public class MSTestLogEventSink : ILogEventSink { private readonly TestContext _context; diff --git a/src/Arcus.Testing.Logging.NUnit/Extensions/ILoggerBuilderExtensions.cs b/src/Arcus.Testing.Logging.NUnit/Extensions/ILoggerBuilderExtensions.cs index 75eb8633..fad24066 100644 --- a/src/Arcus.Testing.Logging.NUnit/Extensions/ILoggerBuilderExtensions.cs +++ b/src/Arcus.Testing.Logging.NUnit/Extensions/ILoggerBuilderExtensions.cs @@ -12,22 +12,15 @@ namespace Microsoft.Extensions.Logging public static class ILoggerBuilderExtensions { /// - /// Adds an the logging messages from the given xUnit as a provider to the . + /// Adds the logging messages from the given xUnit as a provider to the . /// /// The logging builder to add the NUnit logging test messages to. /// The NUnit test writer to write custom test output. /// Thrown when the or the is null. public static ILoggingBuilder AddNUnitTestLogging(this ILoggingBuilder builder, TextWriter outputWriter) { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - if (outputWriter is null) - { - throw new ArgumentNullException(nameof(outputWriter)); - } + ArgumentNullException.ThrowIfNull(builder); + ArgumentNullException.ThrowIfNull(outputWriter); var logger = new NUnitTestLogger(outputWriter); var provider = new CustomLoggerProvider(logger); @@ -36,7 +29,7 @@ public static ILoggingBuilder AddNUnitTestLogging(this ILoggingBuilder builder, } /// - /// Adds an the logging messages from the given xUnit as a provider to the . + /// Adds the logging messages from the given xUnit as a provider to the . /// /// The logging builder to add the NUnit logging test messages to. /// The NUnit test writer to write custom test output. @@ -44,15 +37,8 @@ public static ILoggingBuilder AddNUnitTestLogging(this ILoggingBuilder builder, /// Thrown when the , or the is null. public static ILoggingBuilder AddNUnitTestLogging(this ILoggingBuilder builder, TextWriter outputWriter, TextWriter errorWriter) { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - if (outputWriter is null) - { - throw new ArgumentNullException(nameof(outputWriter)); - } + ArgumentNullException.ThrowIfNull(builder); + ArgumentNullException.ThrowIfNull(outputWriter); var logger = new NUnitTestLogger(outputWriter, errorWriter); var provider = new CustomLoggerProvider(logger); diff --git a/src/Arcus.Testing.Logging.NUnit/Extensions/LoggerSinkConfigurationExtensions.cs b/src/Arcus.Testing.Logging.NUnit/Extensions/LoggerSinkConfigurationExtensions.cs index af0dbc0d..4914b3b5 100644 --- a/src/Arcus.Testing.Logging.NUnit/Extensions/LoggerSinkConfigurationExtensions.cs +++ b/src/Arcus.Testing.Logging.NUnit/Extensions/LoggerSinkConfigurationExtensions.cs @@ -16,6 +16,7 @@ public static class LoggerSinkConfigurationExtensions /// The Serilog sink configuration where the NUnit test logging will be added. /// The NUnit test writer to write custom test output. /// Thrown when the or is null. + [Obsolete("Arcus.Testing.Logging.NUnit will stop supporting Serilog by default, please implement Serilog sinks yourself as this extension will be removed in v2.0")] public static LoggerConfiguration NUnitTestLogging(this LoggerSinkConfiguration config, TextWriter outputWriter) { if (config is null) @@ -38,6 +39,7 @@ public static LoggerConfiguration NUnitTestLogging(this LoggerSinkConfiguration /// The NUnit test writer to write custom test output. /// The NUnit test writer to write custom test errors. /// Thrown when the , or the is null. + [Obsolete("Arcus.Testing.Logging.NUnit will stop supporting Serilog by default, please implement Serilog sinks yourself as this extension will be removed in v2.0")] public static LoggerConfiguration NUnitTestLogging(this LoggerSinkConfiguration config, TextWriter outputWriter, TextWriter errorWriter) { if (config is null) diff --git a/src/Arcus.Testing.Logging.NUnit/NUnitTestLogEventSink.cs b/src/Arcus.Testing.Logging.NUnit/NUnitTestLogEventSink.cs index f1229d42..ed66e479 100644 --- a/src/Arcus.Testing.Logging.NUnit/NUnitTestLogEventSink.cs +++ b/src/Arcus.Testing.Logging.NUnit/NUnitTestLogEventSink.cs @@ -8,6 +8,7 @@ namespace Arcus.Testing /// /// representation of an instance. /// + [Obsolete("Arcus.Testing.Logging.NUnit will stop supporting Serilog by default, please implement Serilog sinks yourself as this sink will be removed in v2.0")] public class NUnitTestLogEventSink : ILogEventSink { private readonly TextWriter _outputWriter, _errorWriter; diff --git a/src/Arcus.Testing.Logging.Xunit/Extensions/ILoggerBuilderExtensions.cs b/src/Arcus.Testing.Logging.Xunit/Extensions/ILoggerBuilderExtensions.cs index 91618e91..d1af75dc 100644 --- a/src/Arcus.Testing.Logging.Xunit/Extensions/ILoggerBuilderExtensions.cs +++ b/src/Arcus.Testing.Logging.Xunit/Extensions/ILoggerBuilderExtensions.cs @@ -12,22 +12,15 @@ namespace Microsoft.Extensions.Logging public static class ILoggerBuilderExtensions { /// - /// Adds an the logging messages from the given xUnit as a provider to the . + /// Adds the logging messages from the given xUnit as a provider to the . /// /// The logging builder to add the xUnit logging test messages to. /// The xUnit test logger used across the test suite. /// Thrown when either the or the is null. public static ILoggingBuilder AddXunitTestLogging(this ILoggingBuilder builder, ITestOutputHelper outputWriter) { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - if (outputWriter is null) - { - throw new ArgumentNullException(nameof(outputWriter)); - } + ArgumentNullException.ThrowIfNull(builder); + ArgumentNullException.ThrowIfNull(outputWriter); var logger = new XunitTestLogger(outputWriter); var provider = new CustomLoggerProvider(logger); diff --git a/src/Arcus.Testing.Logging.Xunit/Extensions/LoggerSinkConfigurationExtensions.cs b/src/Arcus.Testing.Logging.Xunit/Extensions/LoggerSinkConfigurationExtensions.cs index 72201253..1f2b25f8 100644 --- a/src/Arcus.Testing.Logging.Xunit/Extensions/LoggerSinkConfigurationExtensions.cs +++ b/src/Arcus.Testing.Logging.Xunit/Extensions/LoggerSinkConfigurationExtensions.cs @@ -16,6 +16,7 @@ public static class LoggerSinkConfigurationExtensions /// The Serilog sink configuration where the xUnit test logging will be added. /// The xUnit test output writer to write custom test output. /// Thrown when the or is null. + [Obsolete("Arcus.Testing.Logging.Xunit will stop supporting Serilog by default, please implement Serilog sinks yourself as this extension will be removed in v2.0")] public static LoggerConfiguration XunitTestLogging( this LoggerSinkConfiguration config, ITestOutputHelper outputWriter) diff --git a/src/Arcus.Testing.Logging.Xunit/XunitTestLogEventSink.cs b/src/Arcus.Testing.Logging.Xunit/XunitTestLogEventSink.cs index a839a0de..f0d3243d 100644 --- a/src/Arcus.Testing.Logging.Xunit/XunitTestLogEventSink.cs +++ b/src/Arcus.Testing.Logging.Xunit/XunitTestLogEventSink.cs @@ -8,6 +8,7 @@ namespace Arcus.Testing /// /// representation of an instance. /// + [Obsolete("Arcus.Testing.Logging.Xunit will stop supporting Serilog by default, please implement Serilog sinks yourself as this sink will be removed in v2.0")] public class XunitLogEventSink : ILogEventSink { private readonly ITestOutputHelper _outputWriter;