Skip to content

Commit

Permalink
test: verify public API so we can detect (breaking) changes (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
skwasjer authored Dec 17, 2024
1 parent 9ccd3ef commit 9b88773
Show file tree
Hide file tree
Showing 21 changed files with 656 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
7 changes: 7 additions & 0 deletions Correlate.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net9.0;net8.0;net6.0</TargetFrameworks>
<TargetFrameworks Condition="'$(NetPreview)'=='true'">$(TargetFrameworks);netx.0</TargetFrameworks>
<IsTestProject>true</IsTestProject>
<RootNamespace>Correlate</RootNamespace>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Correlate.Abstractions\Correlate.Abstractions.csproj" />
<ProjectReference Include="..\Correlate.Testing\Correlate.Testing.csproj" />
</ItemGroup>

</Project>
54 changes: 54 additions & 0 deletions test/Correlate.Abstractions.Tests/PublicApi/.NET_8.0.verified.txt
Original file line number Diff line number Diff line change
@@ -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<T> : 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<System.Threading.Tasks.Task> correlatedTask, Correlate.OnError? onError);
System.Threading.Tasks.Task<T> CorrelateAsync<T>(string? correlationId, System.Func<System.Threading.Tasks.Task<T>> correlatedTask, Correlate.OnError<T>? 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<T>(string? correlationId, System.Func<T> correlatedFunc, Correlate.OnError<T>? onError);
}
public delegate void OnError(Correlate.ErrorContext errorContext);
public delegate void OnError<T>(Correlate.ErrorContext<T> errorContext);
}
54 changes: 54 additions & 0 deletions test/Correlate.Abstractions.Tests/PublicApi/.NET_9.0.verified.txt
Original file line number Diff line number Diff line change
@@ -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<T> : 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<System.Threading.Tasks.Task> correlatedTask, Correlate.OnError? onError);
System.Threading.Tasks.Task<T> CorrelateAsync<T>(string? correlationId, System.Func<System.Threading.Tasks.Task<T>> correlatedTask, Correlate.OnError<T>? 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<T>(string? correlationId, System.Func<T> correlatedFunc, Correlate.OnError<T>? onError);
}
public delegate void OnError(Correlate.ErrorContext errorContext);
public delegate void OnError<T>(Correlate.ErrorContext<T> errorContext);
}
Original file line number Diff line number Diff line change
@@ -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<T> : 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<System.Threading.Tasks.Task> correlatedTask, Correlate.OnError? onError);
System.Threading.Tasks.Task<T> CorrelateAsync<T>(string? correlationId, System.Func<System.Threading.Tasks.Task<T>> correlatedTask, Correlate.OnError<T>? 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<T>(string? correlationId, System.Func<T> correlatedFunc, Correlate.OnError<T>? onError);
}
public delegate void OnError(Correlate.ErrorContext errorContext);
public delegate void OnError<T>(Correlate.ErrorContext<T> errorContext);
}
11 changes: 11 additions & 0 deletions test/Correlate.Abstractions.Tests/PublicApiTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Correlate.Testing.Specs;

namespace Correlate;

public sealed class PublicApiTests : PublicApiSpec
{
public PublicApiTests()
: base(typeof(IActivity))
{
}
}
30 changes: 30 additions & 0 deletions test/Correlate.AspNetCore.Tests/PublicApi/.NET_8.0.verified.txt
Original file line number Diff line number Diff line change
@@ -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<string>? 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<Correlate.AspNetCore.CorrelateOptions> configureOptions) { }
}
}
namespace Correlate
{
public class RequestIdentifierCorrelationIdFactory : Correlate.ICorrelationIdFactory
{
public RequestIdentifierCorrelationIdFactory() { }
public string Create() { }
}
}
30 changes: 30 additions & 0 deletions test/Correlate.AspNetCore.Tests/PublicApi/.NET_9.0.verified.txt
Original file line number Diff line number Diff line change
@@ -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<string>? 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<Correlate.AspNetCore.CorrelateOptions> configureOptions) { }
}
}
namespace Correlate
{
public class RequestIdentifierCorrelationIdFactory : Correlate.ICorrelationIdFactory
{
public RequestIdentifierCorrelationIdFactory() { }
public string Create() { }
}
}
12 changes: 12 additions & 0 deletions test/Correlate.AspNetCore.Tests/PublicApiTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Correlate.AspNetCore;
using Correlate.Testing.Specs;

namespace Correlate;

public sealed class PublicApiTests : PublicApiSpec
{
public PublicApiTests()
: base(typeof(ICorrelateFeature))
{
}
}
75 changes: 75 additions & 0 deletions test/Correlate.Core.Tests/PublicApi/.NET_8.0.verified.txt
Original file line number Diff line number Diff line change
@@ -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<System.Threading.Tasks.Task> correlatedTask) { }
public static System.Threading.Tasks.Task CorrelateAsync(this Correlate.IAsyncCorrelationManager asyncCorrelationManager, System.Func<System.Threading.Tasks.Task> correlatedTask, Correlate.OnError? onError) { }
public static System.Threading.Tasks.Task CorrelateAsync(this Correlate.IAsyncCorrelationManager asyncCorrelationManager, string? correlationId, System.Func<System.Threading.Tasks.Task> correlatedTask) { }
public static System.Threading.Tasks.Task<T> CorrelateAsync<T>(this Correlate.IAsyncCorrelationManager asyncCorrelationManager, System.Func<System.Threading.Tasks.Task<T>> correlatedTask) { }
public static System.Threading.Tasks.Task<T> CorrelateAsync<T>(this Correlate.IAsyncCorrelationManager asyncCorrelationManager, System.Func<System.Threading.Tasks.Task<T>> correlatedTask, Correlate.OnError<T>? onError) { }
public static System.Threading.Tasks.Task<T> CorrelateAsync<T>(this Correlate.IAsyncCorrelationManager asyncCorrelationManager, string? correlationId, System.Func<System.Threading.Tasks.Task<T>> 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<Correlate.CorrelationManager> logger) { }
public CorrelationManager(Correlate.ICorrelationContextFactory correlationContextFactory, Correlate.ICorrelationIdFactory correlationIdFactory, Correlate.ICorrelationContextAccessor correlationContextAccessor, Microsoft.Extensions.Logging.ILogger<Correlate.CorrelationManager> logger, System.Diagnostics.DiagnosticListener diagnosticListener) { }
public CorrelationManager(Correlate.ICorrelationContextFactory correlationContextFactory, Correlate.ICorrelationIdFactory correlationIdFactory, Correlate.ICorrelationContextAccessor correlationContextAccessor, Microsoft.Extensions.Logging.ILogger<Correlate.CorrelationManager> logger, System.Diagnostics.DiagnosticListener diagnosticListener, Microsoft.Extensions.Options.IOptions<Correlate.CorrelationManagerOptions> options) { }
public void Correlate(string? correlationId, System.Action correlatedAction, Correlate.OnError? onError) { }
public T Correlate<T>(string? correlationId, System.Func<T> correlatedFunc, Correlate.OnError<T>? onError) { }
public System.Threading.Tasks.Task CorrelateAsync(string? correlationId, System.Func<System.Threading.Tasks.Task> correlatedTask, Correlate.OnError? onError) { }
public System.Threading.Tasks.Task<T> CorrelateAsync<T>(string? correlationId, System.Func<System.Threading.Tasks.Task<T>> correlatedTask, Correlate.OnError<T>? 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<T>(this Correlate.ICorrelationManager correlationManager, System.Func<T> correlatedFunc) { }
public static T Correlate<T>(this Correlate.ICorrelationManager correlationManager, System.Func<T> correlatedFunc, Correlate.OnError<T>? onError) { }
public static T Correlate<T>(this Correlate.ICorrelationManager correlationManager, string? correlationId, System.Func<T> 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<Correlate.Http.CorrelateClientOptions> options) { }
public CorrelatingHttpMessageHandler(Correlate.ICorrelationContextAccessor correlationContextAccessor, Microsoft.Extensions.Options.IOptions<Correlate.Http.CorrelateClientOptions> options, System.Net.Http.HttpMessageHandler innerHandler) { }
protected override System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> 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";
}
}
Loading

0 comments on commit 9b88773

Please sign in to comment.