From 0a14ecc9025b28a7b081b0452001ce9c99aeec88 Mon Sep 17 00:00:00 2001 From: skwasjer <11424653+skwasjer@users.noreply.github.com> Date: Tue, 17 Dec 2024 18:21:12 +0100 Subject: [PATCH] test: verify public API so we can detect (breaking) changes --- .github/workflows/main.yml | 3 + .github/workflows/sonarcloud.yml | 2 +- Correlate.sln | 7 ++ .../Correlate.Abstractions.Tests.csproj | 15 ++++ .../PublicApi/.NET_8.0.verified.txt | 54 +++++++++++++ .../PublicApi/.NET_9.0.verified.txt | 54 +++++++++++++ ...NET_Standard_2.0_via_.NET_6.0.verified.txt | 54 +++++++++++++ .../PublicApiTests.cs | 11 +++ .../PublicApi/.NET_8.0.verified.txt | 30 +++++++ .../PublicApi/.NET_9.0.verified.txt | 30 +++++++ .../PublicApiTests.cs | 12 +++ .../PublicApi/.NET_8.0.verified.txt | 75 +++++++++++++++++ .../PublicApi/.NET_9.0.verified.txt | 75 +++++++++++++++++ ...NET_Standard_2.0_via_.NET_6.0.verified.txt | 75 +++++++++++++++++ test/Correlate.Core.Tests/PublicApiTests.cs | 11 +++ .../PublicApi/.NET_8.0.verified.txt | 15 ++++ .../PublicApi/.NET_9.0.verified.txt | 15 ++++ ...NET_Standard_2.0_via_.NET_6.0.verified.txt | 15 ++++ .../PublicApiTests.cs | 11 +++ .../Correlate.Testing.csproj | 12 +++ test/Correlate.Testing/Specs/PublicApiSpec.cs | 81 +++++++++++++++++++ 21 files changed, 656 insertions(+), 1 deletion(-) create mode 100644 test/Correlate.Abstractions.Tests/Correlate.Abstractions.Tests.csproj create mode 100644 test/Correlate.Abstractions.Tests/PublicApi/.NET_8.0.verified.txt create mode 100644 test/Correlate.Abstractions.Tests/PublicApi/.NET_9.0.verified.txt create mode 100644 test/Correlate.Abstractions.Tests/PublicApi/.NET_Standard_2.0_via_.NET_6.0.verified.txt create mode 100644 test/Correlate.Abstractions.Tests/PublicApiTests.cs create mode 100644 test/Correlate.AspNetCore.Tests/PublicApi/.NET_8.0.verified.txt create mode 100644 test/Correlate.AspNetCore.Tests/PublicApi/.NET_9.0.verified.txt create mode 100644 test/Correlate.AspNetCore.Tests/PublicApiTests.cs create mode 100644 test/Correlate.Core.Tests/PublicApi/.NET_8.0.verified.txt create mode 100644 test/Correlate.Core.Tests/PublicApi/.NET_9.0.verified.txt create mode 100644 test/Correlate.Core.Tests/PublicApi/.NET_Standard_2.0_via_.NET_6.0.verified.txt create mode 100644 test/Correlate.Core.Tests/PublicApiTests.cs create mode 100644 test/Correlate.DependencyInjection.Tests/PublicApi/.NET_8.0.verified.txt create mode 100644 test/Correlate.DependencyInjection.Tests/PublicApi/.NET_9.0.verified.txt create mode 100644 test/Correlate.DependencyInjection.Tests/PublicApi/.NET_Standard_2.0_via_.NET_6.0.verified.txt create mode 100644 test/Correlate.DependencyInjection.Tests/PublicApiTests.cs create mode 100644 test/Correlate.Testing/Specs/PublicApiSpec.cs diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fd11351..6c7ab51 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -122,6 +122,9 @@ jobs: # Run all tests - run: dotnet test --no-restore --no-build -c Release + if: matrix.os == 'ubuntu-22.04' + - run: dotnet test --no-restore --no-build -c Release --filter Category!=PublicApi + if: matrix.os != 'ubuntu-22.04' pack: needs: diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index ebf63d0..24ebbe0 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -82,6 +82,6 @@ jobs: run: | dotnet sonarscanner begin /k:"$SONAR_PROJECT_KEY" /o:"$SONAR_ORG_KEY" /d:sonar.host.url=https://sonarcloud.io /d:sonar.token="$SONAR_TOKEN" /d:sonar.cs.opencover.reportsPaths="**/*opencover.xml" $SONAR_PR_ARGS - dotnet test -c Release /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:ExcludeByFile="test/**/*.cs" + dotnet test -c Release /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:ExcludeByFile="test/**/*.cs" /p:VerifyPublicApi=false dotnet sonarscanner end /d:sonar.token="$SONAR_TOKEN" diff --git a/Correlate.sln b/Correlate.sln index 63f0a3a..82b55a7 100644 --- a/Correlate.sln +++ b/Correlate.sln @@ -41,6 +41,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Correlate.Testing", "test\C EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Correlate.Benchmarks", "test\Correlate.Benchmarks\Correlate.Benchmarks.csproj", "{3CDE7B0E-5527-4106-A208-1FA6BC06F2B9}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Correlate.Abstractions.Tests", "test\Correlate.Abstractions.Tests\Correlate.Abstractions.Tests.csproj", "{BE4DCDBB-F8F7-42E1-899E-DE1F51471D1F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -83,6 +85,10 @@ Global {3CDE7B0E-5527-4106-A208-1FA6BC06F2B9}.Debug|Any CPU.Build.0 = Debug|Any CPU {3CDE7B0E-5527-4106-A208-1FA6BC06F2B9}.Release|Any CPU.ActiveCfg = Release|Any CPU {3CDE7B0E-5527-4106-A208-1FA6BC06F2B9}.Release|Any CPU.Build.0 = Release|Any CPU + {BE4DCDBB-F8F7-42E1-899E-DE1F51471D1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BE4DCDBB-F8F7-42E1-899E-DE1F51471D1F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BE4DCDBB-F8F7-42E1-899E-DE1F51471D1F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BE4DCDBB-F8F7-42E1-899E-DE1F51471D1F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -97,6 +103,7 @@ Global {6506DA5B-F341-4B6A-92A9-A2583A43C625} = {45C7B4DF-E612-4301-B2D3-164650B05FC6} {27F547F7-01DE-4B18-9035-0223A80970E4} = {45C7B4DF-E612-4301-B2D3-164650B05FC6} {3CDE7B0E-5527-4106-A208-1FA6BC06F2B9} = {45C7B4DF-E612-4301-B2D3-164650B05FC6} + {BE4DCDBB-F8F7-42E1-899E-DE1F51471D1F} = {45C7B4DF-E612-4301-B2D3-164650B05FC6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BE2CCEF9-2685-4DF3-B085-B6FB083E8E56} diff --git a/test/Correlate.Abstractions.Tests/Correlate.Abstractions.Tests.csproj b/test/Correlate.Abstractions.Tests/Correlate.Abstractions.Tests.csproj new file mode 100644 index 0000000..b07de47 --- /dev/null +++ b/test/Correlate.Abstractions.Tests/Correlate.Abstractions.Tests.csproj @@ -0,0 +1,15 @@ + + + + net9.0;net8.0;net6.0 + $(TargetFrameworks);netx.0 + true + Correlate + + + + + + + + diff --git a/test/Correlate.Abstractions.Tests/PublicApi/.NET_8.0.verified.txt b/test/Correlate.Abstractions.Tests/PublicApi/.NET_8.0.verified.txt new file mode 100644 index 0000000..25c3e79 --- /dev/null +++ b/test/Correlate.Abstractions.Tests/PublicApi/.NET_8.0.verified.txt @@ -0,0 +1,54 @@ +[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/skwasjer/Correlate")] +[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName=".NET 8.0")] +namespace Correlate +{ + public class CorrelationContext + { + public CorrelationContext() { } + public string? CorrelationId { get; set; } + } + public class ErrorContext + { + public Correlate.CorrelationContext CorrelationContext { get; } + public System.Exception Exception { get; } + public bool IsErrorHandled { get; set; } + } + public class ErrorContext : Correlate.ErrorContext + { + public T Result { get; set; } + } + public interface IActivity + { + Correlate.CorrelationContext Start(string correlationId); + void Stop(); + } + public interface IActivityFactory + { + Correlate.IActivity CreateActivity(); + } + public interface IAsyncCorrelationManager + { + System.Threading.Tasks.Task CorrelateAsync(string? correlationId, System.Func correlatedTask, Correlate.OnError? onError); + System.Threading.Tasks.Task CorrelateAsync(string? correlationId, System.Func> correlatedTask, Correlate.OnError? onError); + } + public interface ICorrelationContextAccessor + { + Correlate.CorrelationContext? CorrelationContext { get; set; } + } + public interface ICorrelationContextFactory + { + Correlate.CorrelationContext Create(string correlationId); + void Dispose(); + } + public interface ICorrelationIdFactory + { + string Create(); + } + public interface ICorrelationManager + { + void Correlate(string? correlationId, System.Action correlatedAction, Correlate.OnError? onError); + T Correlate(string? correlationId, System.Func correlatedFunc, Correlate.OnError? onError); + } + public delegate void OnError(Correlate.ErrorContext errorContext); + public delegate void OnError(Correlate.ErrorContext errorContext); +} \ No newline at end of file diff --git a/test/Correlate.Abstractions.Tests/PublicApi/.NET_9.0.verified.txt b/test/Correlate.Abstractions.Tests/PublicApi/.NET_9.0.verified.txt new file mode 100644 index 0000000..21fa54a --- /dev/null +++ b/test/Correlate.Abstractions.Tests/PublicApi/.NET_9.0.verified.txt @@ -0,0 +1,54 @@ +[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/skwasjer/Correlate")] +[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v9.0", FrameworkDisplayName=".NET 9.0")] +namespace Correlate +{ + public class CorrelationContext + { + public CorrelationContext() { } + public string? CorrelationId { get; set; } + } + public class ErrorContext + { + public Correlate.CorrelationContext CorrelationContext { get; } + public System.Exception Exception { get; } + public bool IsErrorHandled { get; set; } + } + public class ErrorContext : Correlate.ErrorContext + { + public T Result { get; set; } + } + public interface IActivity + { + Correlate.CorrelationContext Start(string correlationId); + void Stop(); + } + public interface IActivityFactory + { + Correlate.IActivity CreateActivity(); + } + public interface IAsyncCorrelationManager + { + System.Threading.Tasks.Task CorrelateAsync(string? correlationId, System.Func correlatedTask, Correlate.OnError? onError); + System.Threading.Tasks.Task CorrelateAsync(string? correlationId, System.Func> correlatedTask, Correlate.OnError? onError); + } + public interface ICorrelationContextAccessor + { + Correlate.CorrelationContext? CorrelationContext { get; set; } + } + public interface ICorrelationContextFactory + { + Correlate.CorrelationContext Create(string correlationId); + void Dispose(); + } + public interface ICorrelationIdFactory + { + string Create(); + } + public interface ICorrelationManager + { + void Correlate(string? correlationId, System.Action correlatedAction, Correlate.OnError? onError); + T Correlate(string? correlationId, System.Func correlatedFunc, Correlate.OnError? onError); + } + public delegate void OnError(Correlate.ErrorContext errorContext); + public delegate void OnError(Correlate.ErrorContext errorContext); +} \ No newline at end of file diff --git a/test/Correlate.Abstractions.Tests/PublicApi/.NET_Standard_2.0_via_.NET_6.0.verified.txt b/test/Correlate.Abstractions.Tests/PublicApi/.NET_Standard_2.0_via_.NET_6.0.verified.txt new file mode 100644 index 0000000..1fa4010 --- /dev/null +++ b/test/Correlate.Abstractions.Tests/PublicApi/.NET_Standard_2.0_via_.NET_6.0.verified.txt @@ -0,0 +1,54 @@ +[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/skwasjer/Correlate")] +[assembly: System.Runtime.Versioning.TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName=".NET Standard 2.0")] +namespace Correlate +{ + public class CorrelationContext + { + public CorrelationContext() { } + public string? CorrelationId { get; set; } + } + public class ErrorContext + { + public Correlate.CorrelationContext CorrelationContext { get; } + public System.Exception Exception { get; } + public bool IsErrorHandled { get; set; } + } + public class ErrorContext : Correlate.ErrorContext + { + public T Result { get; set; } + } + public interface IActivity + { + Correlate.CorrelationContext Start(string correlationId); + void Stop(); + } + public interface IActivityFactory + { + Correlate.IActivity CreateActivity(); + } + public interface IAsyncCorrelationManager + { + System.Threading.Tasks.Task CorrelateAsync(string? correlationId, System.Func correlatedTask, Correlate.OnError? onError); + System.Threading.Tasks.Task CorrelateAsync(string? correlationId, System.Func> correlatedTask, Correlate.OnError? onError); + } + public interface ICorrelationContextAccessor + { + Correlate.CorrelationContext? CorrelationContext { get; set; } + } + public interface ICorrelationContextFactory + { + Correlate.CorrelationContext Create(string correlationId); + void Dispose(); + } + public interface ICorrelationIdFactory + { + string Create(); + } + public interface ICorrelationManager + { + void Correlate(string? correlationId, System.Action correlatedAction, Correlate.OnError? onError); + T Correlate(string? correlationId, System.Func correlatedFunc, Correlate.OnError? onError); + } + public delegate void OnError(Correlate.ErrorContext errorContext); + public delegate void OnError(Correlate.ErrorContext errorContext); +} diff --git a/test/Correlate.Abstractions.Tests/PublicApiTests.cs b/test/Correlate.Abstractions.Tests/PublicApiTests.cs new file mode 100644 index 0000000..a146827 --- /dev/null +++ b/test/Correlate.Abstractions.Tests/PublicApiTests.cs @@ -0,0 +1,11 @@ +using Correlate.Testing.Specs; + +namespace Correlate; + +public sealed class PublicApiTests : PublicApiSpec +{ + public PublicApiTests() + : base(typeof(IActivity)) + { + } +} diff --git a/test/Correlate.AspNetCore.Tests/PublicApi/.NET_8.0.verified.txt b/test/Correlate.AspNetCore.Tests/PublicApi/.NET_8.0.verified.txt new file mode 100644 index 0000000..60e4565 --- /dev/null +++ b/test/Correlate.AspNetCore.Tests/PublicApi/.NET_8.0.verified.txt @@ -0,0 +1,30 @@ +[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/skwasjer/Correlate")] +[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName=".NET 8.0")] +namespace Correlate.AspNetCore +{ + public static class AppBuilderExtensions + { + public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseCorrelate(this Microsoft.AspNetCore.Builder.IApplicationBuilder appBuilder) { } + } + public sealed class CorrelateOptions : Correlate.CorrelationManagerOptions + { + public CorrelateOptions() { } + public bool IncludeInResponse { get; set; } + public System.Collections.Generic.IReadOnlyList? RequestHeaders { get; set; } + } +} +namespace Correlate.DependencyInjection +{ + public static class ServiceCollectionExtensions + { + public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddCorrelate(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action configureOptions) { } + } +} +namespace Correlate +{ + public class RequestIdentifierCorrelationIdFactory : Correlate.ICorrelationIdFactory + { + public RequestIdentifierCorrelationIdFactory() { } + public string Create() { } + } +} \ No newline at end of file diff --git a/test/Correlate.AspNetCore.Tests/PublicApi/.NET_9.0.verified.txt b/test/Correlate.AspNetCore.Tests/PublicApi/.NET_9.0.verified.txt new file mode 100644 index 0000000..b4e63c5 --- /dev/null +++ b/test/Correlate.AspNetCore.Tests/PublicApi/.NET_9.0.verified.txt @@ -0,0 +1,30 @@ +[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/skwasjer/Correlate")] +[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v9.0", FrameworkDisplayName=".NET 9.0")] +namespace Correlate.AspNetCore +{ + public static class AppBuilderExtensions + { + public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseCorrelate(this Microsoft.AspNetCore.Builder.IApplicationBuilder appBuilder) { } + } + public sealed class CorrelateOptions : Correlate.CorrelationManagerOptions + { + public CorrelateOptions() { } + public bool IncludeInResponse { get; set; } + public System.Collections.Generic.IReadOnlyList? RequestHeaders { get; set; } + } +} +namespace Correlate.DependencyInjection +{ + public static class ServiceCollectionExtensions + { + public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddCorrelate(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action configureOptions) { } + } +} +namespace Correlate +{ + public class RequestIdentifierCorrelationIdFactory : Correlate.ICorrelationIdFactory + { + public RequestIdentifierCorrelationIdFactory() { } + public string Create() { } + } +} \ No newline at end of file diff --git a/test/Correlate.AspNetCore.Tests/PublicApiTests.cs b/test/Correlate.AspNetCore.Tests/PublicApiTests.cs new file mode 100644 index 0000000..9d53ac5 --- /dev/null +++ b/test/Correlate.AspNetCore.Tests/PublicApiTests.cs @@ -0,0 +1,12 @@ +using Correlate.AspNetCore; +using Correlate.Testing.Specs; + +namespace Correlate; + +public sealed class PublicApiTests : PublicApiSpec +{ + public PublicApiTests() + : base(typeof(ICorrelateFeature)) + { + } +} diff --git a/test/Correlate.Core.Tests/PublicApi/.NET_8.0.verified.txt b/test/Correlate.Core.Tests/PublicApi/.NET_8.0.verified.txt new file mode 100644 index 0000000..7c964d0 --- /dev/null +++ b/test/Correlate.Core.Tests/PublicApi/.NET_8.0.verified.txt @@ -0,0 +1,75 @@ +[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/skwasjer/Correlate")] +[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName=".NET 8.0")] +namespace Correlate +{ + public static class AsyncCorrelationManagerExtensions + { + public static System.Threading.Tasks.Task CorrelateAsync(this Correlate.IAsyncCorrelationManager asyncCorrelationManager, System.Func correlatedTask) { } + public static System.Threading.Tasks.Task CorrelateAsync(this Correlate.IAsyncCorrelationManager asyncCorrelationManager, System.Func correlatedTask, Correlate.OnError? onError) { } + public static System.Threading.Tasks.Task CorrelateAsync(this Correlate.IAsyncCorrelationManager asyncCorrelationManager, string? correlationId, System.Func correlatedTask) { } + public static System.Threading.Tasks.Task CorrelateAsync(this Correlate.IAsyncCorrelationManager asyncCorrelationManager, System.Func> correlatedTask) { } + public static System.Threading.Tasks.Task CorrelateAsync(this Correlate.IAsyncCorrelationManager asyncCorrelationManager, System.Func> correlatedTask, Correlate.OnError? onError) { } + public static System.Threading.Tasks.Task CorrelateAsync(this Correlate.IAsyncCorrelationManager asyncCorrelationManager, string? correlationId, System.Func> correlatedTask) { } + } + public class CorrelationContextAccessor : Correlate.ICorrelationContextAccessor + { + public CorrelationContextAccessor() { } + public Correlate.CorrelationContext? CorrelationContext { get; set; } + } + public class CorrelationContextFactory : Correlate.ICorrelationContextFactory + { + public CorrelationContextFactory() { } + public CorrelationContextFactory(Correlate.ICorrelationContextAccessor correlationContextAccessor) { } + public virtual Correlate.CorrelationContext Create(string correlationId) { } + public void Dispose() { } + } + public class CorrelationManager : Correlate.IActivityFactory, Correlate.IAsyncCorrelationManager, Correlate.ICorrelationManager + { + public CorrelationManager(Correlate.ICorrelationContextFactory correlationContextFactory, Correlate.ICorrelationIdFactory correlationIdFactory, Correlate.ICorrelationContextAccessor correlationContextAccessor, Microsoft.Extensions.Logging.ILogger logger) { } + public CorrelationManager(Correlate.ICorrelationContextFactory correlationContextFactory, Correlate.ICorrelationIdFactory correlationIdFactory, Correlate.ICorrelationContextAccessor correlationContextAccessor, Microsoft.Extensions.Logging.ILogger logger, System.Diagnostics.DiagnosticListener diagnosticListener) { } + public CorrelationManager(Correlate.ICorrelationContextFactory correlationContextFactory, Correlate.ICorrelationIdFactory correlationIdFactory, Correlate.ICorrelationContextAccessor correlationContextAccessor, Microsoft.Extensions.Logging.ILogger logger, System.Diagnostics.DiagnosticListener diagnosticListener, Microsoft.Extensions.Options.IOptions options) { } + public void Correlate(string? correlationId, System.Action correlatedAction, Correlate.OnError? onError) { } + public T Correlate(string? correlationId, System.Func correlatedFunc, Correlate.OnError? onError) { } + public System.Threading.Tasks.Task CorrelateAsync(string? correlationId, System.Func correlatedTask, Correlate.OnError? onError) { } + public System.Threading.Tasks.Task CorrelateAsync(string? correlationId, System.Func> correlatedTask, Correlate.OnError? onError) { } + public Correlate.IActivity CreateActivity() { } + } + public static class CorrelationManagerExtensions + { + public static void Correlate(this Correlate.ICorrelationManager correlationManager, System.Action correlatedAction) { } + public static void Correlate(this Correlate.ICorrelationManager correlationManager, System.Action correlatedAction, Correlate.OnError? onError) { } + public static void Correlate(this Correlate.ICorrelationManager correlationManager, string? correlationId, System.Action correlatedAction) { } + public static T Correlate(this Correlate.ICorrelationManager correlationManager, System.Func correlatedFunc) { } + public static T Correlate(this Correlate.ICorrelationManager correlationManager, System.Func correlatedFunc, Correlate.OnError? onError) { } + public static T Correlate(this Correlate.ICorrelationManager correlationManager, string? correlationId, System.Func correlatedFunc) { } + } + public class CorrelationManagerOptions + { + public CorrelationManagerOptions() { } + public string LoggingScopeKey { get; set; } + } + public class GuidCorrelationIdFactory : Correlate.ICorrelationIdFactory + { + public GuidCorrelationIdFactory() { } + public string Create() { } + } +} +namespace Correlate.Http +{ + public class CorrelateClientOptions + { + public CorrelateClientOptions() { } + public string RequestHeader { get; set; } + } + public class CorrelatingHttpMessageHandler : System.Net.Http.DelegatingHandler + { + public CorrelatingHttpMessageHandler(Correlate.ICorrelationContextAccessor correlationContextAccessor, Microsoft.Extensions.Options.IOptions options) { } + public CorrelatingHttpMessageHandler(Correlate.ICorrelationContextAccessor correlationContextAccessor, Microsoft.Extensions.Options.IOptions options, System.Net.Http.HttpMessageHandler innerHandler) { } + protected override System.Threading.Tasks.Task SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) { } + } + public static class CorrelationHttpHeaders + { + public const string CorrelationId = "X-Correlation-ID"; + public const string RequestId = "X-Request-ID"; + } +} \ No newline at end of file diff --git a/test/Correlate.Core.Tests/PublicApi/.NET_9.0.verified.txt b/test/Correlate.Core.Tests/PublicApi/.NET_9.0.verified.txt new file mode 100644 index 0000000..07b5965 --- /dev/null +++ b/test/Correlate.Core.Tests/PublicApi/.NET_9.0.verified.txt @@ -0,0 +1,75 @@ +[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/skwasjer/Correlate")] +[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v9.0", FrameworkDisplayName=".NET 9.0")] +namespace Correlate +{ + public static class AsyncCorrelationManagerExtensions + { + public static System.Threading.Tasks.Task CorrelateAsync(this Correlate.IAsyncCorrelationManager asyncCorrelationManager, System.Func correlatedTask) { } + public static System.Threading.Tasks.Task CorrelateAsync(this Correlate.IAsyncCorrelationManager asyncCorrelationManager, System.Func correlatedTask, Correlate.OnError? onError) { } + public static System.Threading.Tasks.Task CorrelateAsync(this Correlate.IAsyncCorrelationManager asyncCorrelationManager, string? correlationId, System.Func correlatedTask) { } + public static System.Threading.Tasks.Task CorrelateAsync(this Correlate.IAsyncCorrelationManager asyncCorrelationManager, System.Func> correlatedTask) { } + public static System.Threading.Tasks.Task CorrelateAsync(this Correlate.IAsyncCorrelationManager asyncCorrelationManager, System.Func> correlatedTask, Correlate.OnError? onError) { } + public static System.Threading.Tasks.Task CorrelateAsync(this Correlate.IAsyncCorrelationManager asyncCorrelationManager, string? correlationId, System.Func> correlatedTask) { } + } + public class CorrelationContextAccessor : Correlate.ICorrelationContextAccessor + { + public CorrelationContextAccessor() { } + public Correlate.CorrelationContext? CorrelationContext { get; set; } + } + public class CorrelationContextFactory : Correlate.ICorrelationContextFactory + { + public CorrelationContextFactory() { } + public CorrelationContextFactory(Correlate.ICorrelationContextAccessor correlationContextAccessor) { } + public virtual Correlate.CorrelationContext Create(string correlationId) { } + public void Dispose() { } + } + public class CorrelationManager : Correlate.IActivityFactory, Correlate.IAsyncCorrelationManager, Correlate.ICorrelationManager + { + public CorrelationManager(Correlate.ICorrelationContextFactory correlationContextFactory, Correlate.ICorrelationIdFactory correlationIdFactory, Correlate.ICorrelationContextAccessor correlationContextAccessor, Microsoft.Extensions.Logging.ILogger logger) { } + public CorrelationManager(Correlate.ICorrelationContextFactory correlationContextFactory, Correlate.ICorrelationIdFactory correlationIdFactory, Correlate.ICorrelationContextAccessor correlationContextAccessor, Microsoft.Extensions.Logging.ILogger logger, System.Diagnostics.DiagnosticListener diagnosticListener) { } + public CorrelationManager(Correlate.ICorrelationContextFactory correlationContextFactory, Correlate.ICorrelationIdFactory correlationIdFactory, Correlate.ICorrelationContextAccessor correlationContextAccessor, Microsoft.Extensions.Logging.ILogger logger, System.Diagnostics.DiagnosticListener diagnosticListener, Microsoft.Extensions.Options.IOptions options) { } + public void Correlate(string? correlationId, System.Action correlatedAction, Correlate.OnError? onError) { } + public T Correlate(string? correlationId, System.Func correlatedFunc, Correlate.OnError? onError) { } + public System.Threading.Tasks.Task CorrelateAsync(string? correlationId, System.Func correlatedTask, Correlate.OnError? onError) { } + public System.Threading.Tasks.Task CorrelateAsync(string? correlationId, System.Func> correlatedTask, Correlate.OnError? onError) { } + public Correlate.IActivity CreateActivity() { } + } + public static class CorrelationManagerExtensions + { + public static void Correlate(this Correlate.ICorrelationManager correlationManager, System.Action correlatedAction) { } + public static void Correlate(this Correlate.ICorrelationManager correlationManager, System.Action correlatedAction, Correlate.OnError? onError) { } + public static void Correlate(this Correlate.ICorrelationManager correlationManager, string? correlationId, System.Action correlatedAction) { } + public static T Correlate(this Correlate.ICorrelationManager correlationManager, System.Func correlatedFunc) { } + public static T Correlate(this Correlate.ICorrelationManager correlationManager, System.Func correlatedFunc, Correlate.OnError? onError) { } + public static T Correlate(this Correlate.ICorrelationManager correlationManager, string? correlationId, System.Func correlatedFunc) { } + } + public class CorrelationManagerOptions + { + public CorrelationManagerOptions() { } + public string LoggingScopeKey { get; set; } + } + public class GuidCorrelationIdFactory : Correlate.ICorrelationIdFactory + { + public GuidCorrelationIdFactory() { } + public string Create() { } + } +} +namespace Correlate.Http +{ + public class CorrelateClientOptions + { + public CorrelateClientOptions() { } + public string RequestHeader { get; set; } + } + public class CorrelatingHttpMessageHandler : System.Net.Http.DelegatingHandler + { + public CorrelatingHttpMessageHandler(Correlate.ICorrelationContextAccessor correlationContextAccessor, Microsoft.Extensions.Options.IOptions options) { } + public CorrelatingHttpMessageHandler(Correlate.ICorrelationContextAccessor correlationContextAccessor, Microsoft.Extensions.Options.IOptions options, System.Net.Http.HttpMessageHandler innerHandler) { } + protected override System.Threading.Tasks.Task SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) { } + } + public static class CorrelationHttpHeaders + { + public const string CorrelationId = "X-Correlation-ID"; + public const string RequestId = "X-Request-ID"; + } +} \ No newline at end of file diff --git a/test/Correlate.Core.Tests/PublicApi/.NET_Standard_2.0_via_.NET_6.0.verified.txt b/test/Correlate.Core.Tests/PublicApi/.NET_Standard_2.0_via_.NET_6.0.verified.txt new file mode 100644 index 0000000..9506f33 --- /dev/null +++ b/test/Correlate.Core.Tests/PublicApi/.NET_Standard_2.0_via_.NET_6.0.verified.txt @@ -0,0 +1,75 @@ +[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/skwasjer/Correlate")] +[assembly: System.Runtime.Versioning.TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName=".NET Standard 2.0")] +namespace Correlate +{ + public static class AsyncCorrelationManagerExtensions + { + public static System.Threading.Tasks.Task CorrelateAsync(this Correlate.IAsyncCorrelationManager asyncCorrelationManager, System.Func correlatedTask) { } + public static System.Threading.Tasks.Task CorrelateAsync(this Correlate.IAsyncCorrelationManager asyncCorrelationManager, System.Func correlatedTask, Correlate.OnError? onError) { } + public static System.Threading.Tasks.Task CorrelateAsync(this Correlate.IAsyncCorrelationManager asyncCorrelationManager, string? correlationId, System.Func correlatedTask) { } + public static System.Threading.Tasks.Task CorrelateAsync(this Correlate.IAsyncCorrelationManager asyncCorrelationManager, System.Func> correlatedTask) { } + public static System.Threading.Tasks.Task CorrelateAsync(this Correlate.IAsyncCorrelationManager asyncCorrelationManager, System.Func> correlatedTask, Correlate.OnError? onError) { } + public static System.Threading.Tasks.Task CorrelateAsync(this Correlate.IAsyncCorrelationManager asyncCorrelationManager, string? correlationId, System.Func> correlatedTask) { } + } + public class CorrelationContextAccessor : Correlate.ICorrelationContextAccessor + { + public CorrelationContextAccessor() { } + public Correlate.CorrelationContext? CorrelationContext { get; set; } + } + public class CorrelationContextFactory : Correlate.ICorrelationContextFactory + { + public CorrelationContextFactory() { } + public CorrelationContextFactory(Correlate.ICorrelationContextAccessor correlationContextAccessor) { } + public virtual Correlate.CorrelationContext Create(string correlationId) { } + public void Dispose() { } + } + public class CorrelationManager : Correlate.IActivityFactory, Correlate.IAsyncCorrelationManager, Correlate.ICorrelationManager + { + public CorrelationManager(Correlate.ICorrelationContextFactory correlationContextFactory, Correlate.ICorrelationIdFactory correlationIdFactory, Correlate.ICorrelationContextAccessor correlationContextAccessor, Microsoft.Extensions.Logging.ILogger logger) { } + public CorrelationManager(Correlate.ICorrelationContextFactory correlationContextFactory, Correlate.ICorrelationIdFactory correlationIdFactory, Correlate.ICorrelationContextAccessor correlationContextAccessor, Microsoft.Extensions.Logging.ILogger logger, System.Diagnostics.DiagnosticListener diagnosticListener) { } + public CorrelationManager(Correlate.ICorrelationContextFactory correlationContextFactory, Correlate.ICorrelationIdFactory correlationIdFactory, Correlate.ICorrelationContextAccessor correlationContextAccessor, Microsoft.Extensions.Logging.ILogger logger, System.Diagnostics.DiagnosticListener diagnosticListener, Microsoft.Extensions.Options.IOptions options) { } + public void Correlate(string? correlationId, System.Action correlatedAction, Correlate.OnError? onError) { } + public T Correlate(string? correlationId, System.Func correlatedFunc, Correlate.OnError? onError) { } + public System.Threading.Tasks.Task CorrelateAsync(string? correlationId, System.Func correlatedTask, Correlate.OnError? onError) { } + public System.Threading.Tasks.Task CorrelateAsync(string? correlationId, System.Func> correlatedTask, Correlate.OnError? onError) { } + public Correlate.IActivity CreateActivity() { } + } + public static class CorrelationManagerExtensions + { + public static void Correlate(this Correlate.ICorrelationManager correlationManager, System.Action correlatedAction) { } + public static void Correlate(this Correlate.ICorrelationManager correlationManager, System.Action correlatedAction, Correlate.OnError? onError) { } + public static void Correlate(this Correlate.ICorrelationManager correlationManager, string? correlationId, System.Action correlatedAction) { } + public static T Correlate(this Correlate.ICorrelationManager correlationManager, System.Func correlatedFunc) { } + public static T Correlate(this Correlate.ICorrelationManager correlationManager, System.Func correlatedFunc, Correlate.OnError? onError) { } + public static T Correlate(this Correlate.ICorrelationManager correlationManager, string? correlationId, System.Func correlatedFunc) { } + } + public class CorrelationManagerOptions + { + public CorrelationManagerOptions() { } + public string LoggingScopeKey { get; set; } + } + public class GuidCorrelationIdFactory : Correlate.ICorrelationIdFactory + { + public GuidCorrelationIdFactory() { } + public string Create() { } + } +} +namespace Correlate.Http +{ + public class CorrelateClientOptions + { + public CorrelateClientOptions() { } + public string RequestHeader { get; set; } + } + public class CorrelatingHttpMessageHandler : System.Net.Http.DelegatingHandler + { + public CorrelatingHttpMessageHandler(Correlate.ICorrelationContextAccessor correlationContextAccessor, Microsoft.Extensions.Options.IOptions options) { } + public CorrelatingHttpMessageHandler(Correlate.ICorrelationContextAccessor correlationContextAccessor, Microsoft.Extensions.Options.IOptions options, System.Net.Http.HttpMessageHandler innerHandler) { } + protected override System.Threading.Tasks.Task SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) { } + } + public static class CorrelationHttpHeaders + { + public const string CorrelationId = "X-Correlation-ID"; + public const string RequestId = "X-Request-ID"; + } +} \ No newline at end of file diff --git a/test/Correlate.Core.Tests/PublicApiTests.cs b/test/Correlate.Core.Tests/PublicApiTests.cs new file mode 100644 index 0000000..6439b0b --- /dev/null +++ b/test/Correlate.Core.Tests/PublicApiTests.cs @@ -0,0 +1,11 @@ +using Correlate.Testing.Specs; + +namespace Correlate; + +public sealed class PublicApiTests : PublicApiSpec +{ + public PublicApiTests() + : base(typeof(RootActivity)) + { + } +} diff --git a/test/Correlate.DependencyInjection.Tests/PublicApi/.NET_8.0.verified.txt b/test/Correlate.DependencyInjection.Tests/PublicApi/.NET_8.0.verified.txt new file mode 100644 index 0000000..1f1fcea --- /dev/null +++ b/test/Correlate.DependencyInjection.Tests/PublicApi/.NET_8.0.verified.txt @@ -0,0 +1,15 @@ +[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/skwasjer/Correlate")] +[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName=".NET 8.0")] +namespace Correlate.DependencyInjection +{ + public static class IHttpClientBuilderExtensions + { + public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder CorrelateRequests(this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, System.Action configureOptions) { } + public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder CorrelateRequests(this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, string requestHeader = "X-Correlation-ID") { } + } + public static class IServiceCollectionExtensions + { + public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddCorrelate(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) { } + public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddCorrelate(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action configure) { } + } +} \ No newline at end of file diff --git a/test/Correlate.DependencyInjection.Tests/PublicApi/.NET_9.0.verified.txt b/test/Correlate.DependencyInjection.Tests/PublicApi/.NET_9.0.verified.txt new file mode 100644 index 0000000..cacdf3c --- /dev/null +++ b/test/Correlate.DependencyInjection.Tests/PublicApi/.NET_9.0.verified.txt @@ -0,0 +1,15 @@ +[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/skwasjer/Correlate")] +[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v9.0", FrameworkDisplayName=".NET 9.0")] +namespace Correlate.DependencyInjection +{ + public static class IHttpClientBuilderExtensions + { + public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder CorrelateRequests(this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, System.Action configureOptions) { } + public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder CorrelateRequests(this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, string requestHeader = "X-Correlation-ID") { } + } + public static class IServiceCollectionExtensions + { + public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddCorrelate(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) { } + public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddCorrelate(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action configure) { } + } +} \ No newline at end of file diff --git a/test/Correlate.DependencyInjection.Tests/PublicApi/.NET_Standard_2.0_via_.NET_6.0.verified.txt b/test/Correlate.DependencyInjection.Tests/PublicApi/.NET_Standard_2.0_via_.NET_6.0.verified.txt new file mode 100644 index 0000000..d00fd33 --- /dev/null +++ b/test/Correlate.DependencyInjection.Tests/PublicApi/.NET_Standard_2.0_via_.NET_6.0.verified.txt @@ -0,0 +1,15 @@ +[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/skwasjer/Correlate")] +[assembly: System.Runtime.Versioning.TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName=".NET Standard 2.0")] +namespace Correlate.DependencyInjection +{ + public static class IHttpClientBuilderExtensions + { + public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder CorrelateRequests(this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, System.Action configureOptions) { } + public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder CorrelateRequests(this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, string requestHeader = "X-Correlation-ID") { } + } + public static class IServiceCollectionExtensions + { + public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddCorrelate(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) { } + public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddCorrelate(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action configure) { } + } +} \ No newline at end of file diff --git a/test/Correlate.DependencyInjection.Tests/PublicApiTests.cs b/test/Correlate.DependencyInjection.Tests/PublicApiTests.cs new file mode 100644 index 0000000..9706b72 --- /dev/null +++ b/test/Correlate.DependencyInjection.Tests/PublicApiTests.cs @@ -0,0 +1,11 @@ +using Correlate.Testing.Specs; + +namespace Correlate.DependencyInjection; + +public sealed class PublicApiTests : PublicApiSpec +{ + public PublicApiTests() + : base(typeof(IServiceCollectionExtensions)) + { + } +} diff --git a/test/Correlate.Testing/Correlate.Testing.csproj b/test/Correlate.Testing/Correlate.Testing.csproj index 50fbba6..71b2bc2 100644 --- a/test/Correlate.Testing/Correlate.Testing.csproj +++ b/test/Correlate.Testing/Correlate.Testing.csproj @@ -14,6 +14,18 @@ 8.9.1 + + 28.6.0 + 28.2.1 + true + $(DefineConstants);VERIFY_PUBLIC_API + + + + + + + diff --git a/test/Correlate.Testing/Specs/PublicApiSpec.cs b/test/Correlate.Testing/Specs/PublicApiSpec.cs new file mode 100644 index 0000000..796f897 --- /dev/null +++ b/test/Correlate.Testing/Specs/PublicApiSpec.cs @@ -0,0 +1,81 @@ +#if VERIFY_PUBLIC_API +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.Versioning; +using PublicApiGenerator; + +namespace Correlate.Testing.Specs; + +#if !NET6_0_OR_GREATER && !NET47_OR_GREATER +[UsesVerify] +#endif +public abstract class PublicApiSpec +{ + private readonly Type _assemblyMarkerType; + private readonly string? _sourceFile; + + private readonly ApiGeneratorOptions _options = new() + { + ExcludeAttributes = + [ + typeof(InternalsVisibleToAttribute).FullName! + ], + DenyNamespacePrefixes = [] + }; + + protected PublicApiSpec(Type assemblyMarkerType, [CallerFilePath] string? sourceFile = default) + { + _assemblyMarkerType = assemblyMarkerType; + _sourceFile = sourceFile; + } + + [Fact] + [Trait("Category", "PublicApi")] + public Task Api_has_not_changed() + { + bool runningOnMono = Type.GetType("Mono.Runtime") != null; + if (runningOnMono) + { + return Task.CompletedTask; + } + + Assembly sut = _assemblyMarkerType.Assembly; + var settings = new VerifySettings(); + + string sutTargetFramework = GetTargetFramework(sut); + string testTargetFramework = GetTargetFramework(GetType().Assembly); + settings.UseFileName( + sutTargetFramework == testTargetFramework + ? sutTargetFramework + : $"{sutTargetFramework}_via_{testTargetFramework}" + ); + settings.UseDirectory("PublicApi"); + + // Act + string publicApi = sut.GeneratePublicApi(_options); + + // Assert + // ReSharper disable once ExplicitCallerInfoArgument +#pragma warning disable S3236 + return Verify(publicApi, settings, _sourceFile!); +#pragma warning restore S3236 + } + + private static string GetTargetFramework(Assembly asm) + { + return asm.GetCustomAttribute()?.FrameworkDisplayName?.Replace(' ', '_') + ?? throw new InvalidOperationException("Framework display name is required."); + } +} +#else +namespace Correlate.Testing.Specs; + +// Empty shim for when verification is disabled. +public abstract class PublicApiSpec +{ + // ReSharper disable once UnusedParameter.Local + protected PublicApiSpec(Type assemblyMarkerType) + { + } +} +#endif