From 987b0899a6103561cd7551f06c500d500e292608 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 20 Nov 2025 22:24:30 +0200 Subject: [PATCH] Update to .NET 10 Update HC 15 to latest Update report generator to latest Update github pipelines Update docs Format csproj files to use 2 space indentation --- .config/dotnet-tools.json | 2 +- .github/workflows/dotnet.yml | 1 + .../GraphHealthChecks.Tests.csproj | 58 +++++----- .../GraphQLHealthCheckTests.cs | 103 ++++++++++++------ GraphHealthChecks.Tests/Usings.cs | 2 +- GraphHealthChecks/GraphHealthChecks.csproj | 54 ++++----- GraphHealthChecks/README.md | 22 ++-- NOTES.md | 6 +- README.md | 20 ++-- global.json | 2 +- 10 files changed, 156 insertions(+), 114 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 1903d86..96b7185 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "dotnet-reportgenerator-globaltool": { - "version": "5.4.3", + "version": "5.5.0", "commands": [ "reportgenerator" ], diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 0b821fe..16cd3f4 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -22,6 +22,7 @@ jobs: dotnet-version: | 8.0.x 9.0.x + 10.0.x - name: Restore dependencies run: dotnet restore - name: Build diff --git a/GraphHealthChecks.Tests/GraphHealthChecks.Tests.csproj b/GraphHealthChecks.Tests/GraphHealthChecks.Tests.csproj index 4f5f1c1..73596ac 100644 --- a/GraphHealthChecks.Tests/GraphHealthChecks.Tests.csproj +++ b/GraphHealthChecks.Tests/GraphHealthChecks.Tests.csproj @@ -1,36 +1,34 @@ - - net8.0;net9.0 - enable - enable - false - true - + + net8.0;net9.0;net10.0 + enable + enable + false + true + - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + - - - + + + diff --git a/GraphHealthChecks.Tests/GraphQLHealthCheckTests.cs b/GraphHealthChecks.Tests/GraphQLHealthCheckTests.cs index 89ca40c..a302c5a 100644 --- a/GraphHealthChecks.Tests/GraphQLHealthCheckTests.cs +++ b/GraphHealthChecks.Tests/GraphQLHealthCheckTests.cs @@ -3,6 +3,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Diagnostics.HealthChecks; using Microsoft.Extensions.Logging; +using NSubstitute.ExceptionExtensions; using Snapshooter.Xunit; namespace GraphHealthChecks.Tests; @@ -24,12 +25,12 @@ private static object GetErrorResult(HealthCheckResult result) => [Fact(DisplayName = "GraphQLHealthCheck - No Logger - Unhealthy Schema")] public async Task NoLoggerUnhealthySchema() { - var mockRequestExecutorResolver = new Mock(); + var mockRequestExecutorResolver = Substitute.For(); mockRequestExecutorResolver - .Setup(m => m.GetRequestExecutorAsync(It.IsAny(), It.IsAny())) - .ThrowsAsync(new SchemaException()); + .GetRequestExecutorAsync(Arg.Any(), Arg.Any()) + .Throws(new SchemaException()); - var result = await new GraphHealthCheck(mockRequestExecutorResolver.Object) + var result = await new GraphHealthCheck(mockRequestExecutorResolver) .CheckHealthAsync(null!); Assert.Equal(HealthStatus.Unhealthy, result.Status); @@ -41,12 +42,12 @@ public async Task NoLoggerUnhealthySchema() [Fact(DisplayName = "GraphQLHealthCheck - No Logger - General Error")] public async Task NoLoggerGeneralError() { - var mockRequestExecutorResolver = new Mock(); + var mockRequestExecutorResolver = Substitute.For(); mockRequestExecutorResolver - .Setup(m => m.GetRequestExecutorAsync(It.IsAny(), It.IsAny())) - .ThrowsAsync(new Exception("Splash!")); + .GetRequestExecutorAsync(Arg.Any(), Arg.Any()) + .Throws(new Exception("Splash!")); - var result = await new GraphHealthCheck(mockRequestExecutorResolver.Object).CheckHealthAsync(null!); + var result = await new GraphHealthCheck(mockRequestExecutorResolver).CheckHealthAsync(null!); Assert.Equal(HealthStatus.Unhealthy, result.Status); Assert.IsAssignableFrom(result.Exception); @@ -76,15 +77,15 @@ public async Task NoLoggerHealthy() [Fact(DisplayName = "GraphQLHealthCheck - ILogger - General Error")] public async Task ILoggerGeneralError() { - var mockLogger = new Mock>(); - var mockResolver = new Mock(); + var mockLogger = Substitute.For>(); + var mockResolver = Substitute.For(); mockResolver - .Setup(m => m.GetRequestExecutorAsync(It.IsAny(), It.IsAny())) - .ThrowsAsync(new Exception("Splash!")); + .GetRequestExecutorAsync(Arg.Any(), Arg.Any()) + .Throws(new Exception("Splash!")); var result = await new GraphHealthCheck( - mockResolver.Object, - mockLogger.Object + mockResolver, + mockLogger ) .CheckHealthAsync(null!); @@ -93,7 +94,13 @@ public async Task ILoggerGeneralError() Assert.NotNull(result.Description); Assert.Contains("general", result.Description); - mockLogger.VerifyLog(m => m.LogError(It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); + mockLogger.Received(1).Log( + LogLevel.Error, + Arg.Any(), + Arg.Any(), + Arg.Is(x => x.Message == "Splash!"), + Arg.Any>() + ); GetErrorResult(result).MatchSnapshot(); } @@ -101,7 +108,7 @@ public async Task ILoggerGeneralError() [Fact(DisplayName = "GraphQLHealthCheck - ILogger - Unhealthy Schema")] public async Task ILoggerUnhealthySchema() { - var mockLogger = new Mock>(); + var mockLogger = Substitute.For>(); var result = await new GraphHealthCheck( new ServiceCollection() @@ -110,7 +117,7 @@ public async Task ILoggerUnhealthySchema() .Services .BuildServiceProvider() .GetRequiredService(), - mockLogger.Object + mockLogger ) .CheckHealthAsync(null!); @@ -119,7 +126,13 @@ public async Task ILoggerUnhealthySchema() Assert.NotNull(result.Description); Assert.Contains("schema", result.Description); - mockLogger.VerifyLog(m => m.LogError(It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); + mockLogger.Received(1).Log( + LogLevel.Error, + Arg.Any(), + Arg.Any(), + Arg.Any(), + Arg.Any>() + ); GetErrorResult(result).MatchSnapshot(); } @@ -127,7 +140,7 @@ public async Task ILoggerUnhealthySchema() [Fact(DisplayName = "GraphQLHealthCheck - ILogger - Unhealthy Schema - No Auth")] public async Task ILoggerUnhealthySchemaNoAuth() { - var mockLogger = new Mock>(); + var mockLogger = Substitute.For>(); var result = await new GraphHealthCheck( new ServiceCollection() @@ -136,7 +149,7 @@ public async Task ILoggerUnhealthySchemaNoAuth() .Services .BuildServiceProvider() .GetRequiredService(), - mockLogger.Object + mockLogger ) .CheckHealthAsync(null!); @@ -145,7 +158,13 @@ public async Task ILoggerUnhealthySchemaNoAuth() Assert.NotNull(result.Description); Assert.Contains("schema", result.Description); - mockLogger.VerifyLog(m => m.LogError(It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); + mockLogger.Received(1).Log( + LogLevel.Error, + Arg.Any(), + Arg.Any(), + Arg.Any(), + Arg.Any>() + ); GetErrorResult(result).MatchSnapshot(); } @@ -153,19 +172,25 @@ public async Task ILoggerUnhealthySchemaNoAuth() [Fact(DisplayName = "GraphQLHealthCheck - ILogger - Unhealthy Schema - No Auth - General Error")] public async Task ILoggerUnhealthySchemaNoAuthGeneralError() { - var mockLogger = new Mock>(); - var mockRequestExecutorResolver = new Mock(); + var mockLogger = Substitute.For>(); + var mockRequestExecutorResolver = Substitute.For(); mockRequestExecutorResolver - .Setup(m => m.GetRequestExecutorAsync(It.IsAny(), It.IsAny())) - .ThrowsAsync(new Exception("Splash!")); + .GetRequestExecutorAsync(Arg.Any(), Arg.Any()) + .Throws(new Exception("Splash!")); - var result = await new GraphHealthCheck(mockRequestExecutorResolver.Object, mockLogger.Object) + var result = await new GraphHealthCheck(mockRequestExecutorResolver, mockLogger) .CheckHealthAsync(null!); Assert.Equal(HealthStatus.Unhealthy, result.Status); Assert.IsAssignableFrom(result.Exception); - mockLogger.VerifyLog(m => m.LogError(It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); + mockLogger.Received(1).Log( + LogLevel.Error, + Arg.Any(), + Arg.Any(), + Arg.Is(x => x.Message == "Splash!"), + Arg.Any>() + ); GetErrorResult(result).MatchSnapshot(); } @@ -173,7 +198,7 @@ public async Task ILoggerUnhealthySchemaNoAuthGeneralError() [Fact(DisplayName = "GraphQLHealthCheck - ILogger - Healthy - Auth")] public async Task ILoggerHealthyAuth() { - var mockLogger = new Mock>(); + var mockLogger = Substitute.For>(); var result = await new GraphHealthCheck( new ServiceCollection() @@ -183,14 +208,20 @@ public async Task ILoggerHealthyAuth() .Services .BuildServiceProvider() .GetRequiredService(), - mockLogger.Object + mockLogger ) .CheckHealthAsync(null!); Assert.Equal(HealthStatus.Healthy, result.Status); Assert.Null(result.Description); - mockLogger.VerifyLog(m => m.LogError(It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); + mockLogger.Received(0).Log( + LogLevel.Error, + Arg.Any(), + Arg.Any(), + Arg.Any(), + Arg.Any>() + ); result.MatchSnapshot(); } @@ -198,7 +229,7 @@ public async Task ILoggerHealthyAuth() [Fact(DisplayName = "GraphQLHealthCheck - ILogger - Healthy")] public async Task ILoggerHealthy() { - var mockLogger = new Mock>(); + var mockLogger = Substitute.For>(); var result = await new GraphHealthCheck( new ServiceCollection() @@ -207,14 +238,20 @@ public async Task ILoggerHealthy() .Services .BuildServiceProvider() .GetRequiredService(), - mockLogger.Object + mockLogger ) .CheckHealthAsync(null!); Assert.Equal(HealthStatus.Healthy, result.Status); Assert.Null(result.Description); - mockLogger.VerifyLog(m => m.LogError(It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); + mockLogger.Received(0).Log( + LogLevel.Error, + Arg.Any(), + Arg.Any(), + Arg.Any(), + Arg.Any>() + ); result.MatchSnapshot(); } diff --git a/GraphHealthChecks.Tests/Usings.cs b/GraphHealthChecks.Tests/Usings.cs index 38aced3..22997d3 100644 --- a/GraphHealthChecks.Tests/Usings.cs +++ b/GraphHealthChecks.Tests/Usings.cs @@ -1,2 +1,2 @@ global using Xunit; -global using Moq; +global using NSubstitute; diff --git a/GraphHealthChecks/GraphHealthChecks.csproj b/GraphHealthChecks/GraphHealthChecks.csproj index 80a197a..105d132 100644 --- a/GraphHealthChecks/GraphHealthChecks.csproj +++ b/GraphHealthChecks/GraphHealthChecks.csproj @@ -1,31 +1,33 @@ - - net8.0;net9.0 - enable - true - true - $(MSBuildProjectName) - 4.0.1 - Adamos Fiakkas - Graph Health Checks for HotChocolate - Adamos Fiakkas - MIT - https://github.com/fiakkasa/GraphHealthChecks - https://github.com/fiakkasa/GraphHealthChecks - git - README.md - - - - + + net8.0;net9.0;net10.0 + enable + true + true + $(MSBuildProjectName) + 5.0.0 + Adamos Fiakkas + Graph Health Checks for HotChocolate + Adamos Fiakkas + MIT + https://github.com/fiakkasa/GraphHealthChecks + https://github.com/fiakkasa/GraphHealthChecks + git + README.md + - - - - + + + + + + + + + + + + - - - \ No newline at end of file diff --git a/GraphHealthChecks/README.md b/GraphHealthChecks/README.md index 7a0c8a7..f1d3f94 100644 --- a/GraphHealthChecks/README.md +++ b/GraphHealthChecks/README.md @@ -10,19 +10,20 @@ The purpose of this middleware is to provide feedback regarding the health of th ### Current Releases -| HotChocolate Version | GraphHealthChecks Version | .NET Version | -|----------------------|---------------------------|--------------| -| 15.0.3 or higher | 4.0.1 | .NET 8, 9 | -| 15.0.3 or higher | 4.0.0 | .NET 8, 9 | -| 14.3.0 or higher | 3.3.0 | .NET 8, 9 | -| 14.2.0 or higher | 3.2.0 | .NET 8, 9 | -| 14.1.0 or higher | 3.1.0 | .NET 8, 9 | -| 14.0.0 or higher | 3.0.0 | .NET 8 | +| HotChocolate Version | GraphHealthChecks Version | .NET Version | +| -------------------- | ------------------------- | ------------- | +| 15.1.11 or higher | 5.0.0 | .NET 8, 9, 10 | +| 15.0.3 or higher | 4.0.1 | .NET 8, 9 | +| 15.0.3 or higher | 4.0.0 | .NET 8, 9 | +| 14.3.0 or higher | 3.3.0 | .NET 8, 9 | +| 14.2.0 or higher | 3.2.0 | .NET 8, 9 | +| 14.1.0 or higher | 3.1.0 | .NET 8, 9 | +| 14.0.0 or higher | 3.0.0 | .NET 8 | ### Past Releases | HotChocolate Version | Last GraphHealthChecks Version | .NET Version | -|----------------------|--------------------------------|--------------| +| -------------------- | ------------------------------ | ------------ | | 13.7.0 or higher | 2.0.1 | .NET 6, 8 | | 13.3.3 or higher | 1.0.2 | .NET 6, 7 | @@ -35,6 +36,7 @@ There appears to be a compatibility issue for projects targeting .NET 7 and asse `OptionsBuilderExtensions.ValidateOnStart` resulting in error: > The call is ambiguous between the following methods or properties: +> > ```csharp > Microsoft.Extensions.DependencyInjection.OptionsBuilderExtensions.ValidateOnStart(Microsoft.Extensions.Options.OptionsBuilder) > ``` @@ -83,4 +85,4 @@ public void ConfigureServices(IServiceCollection services) .AddGraphHealthWithILogger(healthName: "health2", schemaName: "schema2"); // ... } -``` \ No newline at end of file +``` diff --git a/NOTES.md b/NOTES.md index 2552ad2..f68e89d 100644 --- a/NOTES.md +++ b/NOTES.md @@ -11,17 +11,17 @@ ## Tests -📝 _The produced coverage.cobertura file is per .NET version ex. `coverage.cobertura.net9.0.xml`_ +📝 _The produced coverage.cobertura file is per .NET version ex. `coverage.cobertura.net10.0.xml`_ - Run: `dotnet test /p:CollectCoverage=true /p:Threshold=80 /p:CoverletOutputFormat=cobertura /p:CoverletOutput='../coverage.cobertura.xml'` -- Report: `dotnet reportgenerator -reports:./coverage.cobertura.net9.0.xml -targetdir:./TestResults -reporttypes:Html` +- Report: `dotnet reportgenerator -reports:./coverage.cobertura.net10.0.xml -targetdir:./TestResults -reporttypes:Html` In one Go! ```powershell dotnet test /p:CollectCoverage=true /p:Threshold=80 /p:CoverletOutputFormat=cobertura /p:CoverletOutput='../coverage.cobertura.xml' -dotnet reportgenerator -reports:./coverage.cobertura.net9.0.xml -targetdir:./TestResults -reporttypes:Html +dotnet reportgenerator -reports:./coverage.cobertura.net10.0.xml -targetdir:./TestResults -reporttypes:Html ``` ## Info diff --git a/README.md b/README.md index 2e827b9..c000e1e 100644 --- a/README.md +++ b/README.md @@ -14,19 +14,20 @@ The purpose of this middleware is to provide feedback regarding the health of th ### Current Releases -| HotChocolate Version | GraphHealthChecks Version | .NET Version | -|----------------------|---------------------------|--------------| -| 15.0.3 or higher | 4.0.1 | .NET 8, 9 | -| 15.0.3 or higher | 4.0.0 | .NET 8, 9 | -| 14.3.0 or higher | 3.3.0 | .NET 8, 9 | -| 14.2.0 or higher | 3.2.0 | .NET 8, 9 | -| 14.1.0 or higher | 3.1.0 | .NET 8, 9 | -| 14.0.0 or higher | 3.0.0 | .NET 8 | +| HotChocolate Version | GraphHealthChecks Version | .NET Version | +| -------------------- | ------------------------- | ------------- | +| 15.1.11 or higher | 5.0.0 | .NET 8, 9, 10 | +| 15.0.3 or higher | 4.0.1 | .NET 8, 9 | +| 15.0.3 or higher | 4.0.0 | .NET 8, 9 | +| 14.3.0 or higher | 3.3.0 | .NET 8, 9 | +| 14.2.0 or higher | 3.2.0 | .NET 8, 9 | +| 14.1.0 or higher | 3.1.0 | .NET 8, 9 | +| 14.0.0 or higher | 3.0.0 | .NET 8 | ### Past Releases | HotChocolate Version | Last GraphHealthChecks Version | .NET Version | -|----------------------|--------------------------------|--------------| +| -------------------- | ------------------------------ | ------------ | | 13.7.0 or higher | 2.0.1 | .NET 6, 8 | | 13.3.3 or higher | 1.0.2 | .NET 6, 7 | @@ -39,6 +40,7 @@ There appears to be a compatibility issue for projects targeting .NET 7 and asse `OptionsBuilderExtensions.ValidateOnStart` resulting in error: > The call is ambiguous between the following methods or properties: +> > ```csharp > Microsoft.Extensions.DependencyInjection.OptionsBuilderExtensions.ValidateOnStart(Microsoft.Extensions.Options.OptionsBuilder) > ``` diff --git a/global.json b/global.json index cdbb589..512142d 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "9.0.100", + "version": "10.0.100", "rollForward": "latestFeature" } }