From eda30f5c4ee38dbb12c6aa5f70a3ee3a8b443f1e Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Thu, 27 Nov 2025 03:05:03 +0100 Subject: [PATCH] Update to JsonApiDotNetCore v5.10.0, add support for .NET 10 --- .config/dotnet-tools.json | 4 +-- .github/workflows/build.yml | 32 +++++++++++++------ .github/workflows/codeql.yml | 5 ++- .github/workflows/deps-review.yml | 4 ++- Build.ps1 | 17 ++-------- Directory.Build.props | 3 +- JsonApiDotNetCore.MongoDb.sln.DotSettings | 3 ++ cleanupcode.ps1 | 29 +++++++---------- inspectcode.ps1 | 15 ++++----- package-versions.props | 9 ++++-- .../GettingStarted/GettingStarted.csproj | 2 +- .../JsonApiDotNetCoreMongoDbExample.csproj | 2 +- .../JsonApiDotNetCore.MongoDb.csproj | 8 ++++- .../JsonApiDotNetCoreMongoDbTests.csproj | 2 +- test/TestBuildingBlocks/IntegrationTest.cs | 2 +- .../TestBuildingBlocks/MongoRunnerProvider.cs | 16 ++++++---- .../TestBuildingBlocks.csproj | 2 +- ...ateTimeExtensions.cs => TimeExtensions.cs} | 16 ++++++---- test/TestBuildingBlocks/Unknown.cs | 2 +- 19 files changed, 94 insertions(+), 79 deletions(-) rename test/TestBuildingBlocks/{DateTimeExtensions.cs => TimeExtensions.cs} (59%) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index a1fb22d..3437a13 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "jetbrains.resharper.globaltools": { - "version": "2025.2.4", + "version": "2025.3.0.2", "commands": [ "jb" ], @@ -17,7 +17,7 @@ "rollForward": false }, "dotnet-reportgenerator-globaltool": { - "version": "5.4.17", + "version": "5.5.0", "commands": [ "reportgenerator" ], diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f37f6d1..b1dfb6c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,6 +23,7 @@ concurrency: env: DOTNET_NOLOGO: true DOTNET_CLI_TELEMETRY_OPTOUT: true + SOLUTION_FILE: JsonApiDotNetCore.MongoDb.sln jobs: build-and-test: @@ -43,13 +44,16 @@ jobs: dotnet-version: | 8.0.* 9.0.* + 10.0.* - name: Show installed versions shell: pwsh run: | Write-Host "$(pwsh --version) is installed at $PSHOME" Write-Host "Active .NET SDK: $(dotnet --version)" - name: Git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 + with: + persist-credentials: false - name: Restore tools run: dotnet tool restore - name: Restore packages @@ -87,7 +91,7 @@ jobs: - name: Build run: dotnet build --no-restore --configuration Release /p:VersionSuffix=${{ env.PACKAGE_VERSION_SUFFIX }} - name: Test - run: dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --logger "GitHubActions;summary.includeSkippedTests=true" + run: dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --logger "GitHubActions;annotations-title=@test (@framework);annotations-message=@error\n@trace;summary-include-passed=false" - name: Upload coverage to codecov.io if: ${{ matrix.os == 'ubuntu-latest' }} env: @@ -100,7 +104,7 @@ jobs: run: dotnet pack --no-build --configuration Release --output ${{ github.workspace }}/artifacts/packages /p:VersionSuffix=${{ env.PACKAGE_VERSION_SUFFIX }} - name: Upload packages to artifacts if: ${{ matrix.os == 'ubuntu-latest' }} - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 with: name: packages path: artifacts/packages @@ -123,8 +127,11 @@ jobs: dotnet-version: | 8.0.* 9.0.* + 10.0.* - name: Git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 + with: + persist-credentials: false - name: Restore tools run: dotnet tool restore - name: InspectCode @@ -132,7 +139,8 @@ jobs: run: | $inspectCodeOutputPath = Join-Path $env:RUNNER_TEMP 'jetbrains-inspectcode-results.xml' Write-Output "INSPECT_CODE_OUTPUT_PATH=$inspectCodeOutputPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - dotnet jb inspectcode JsonApiDotNetCore.MongoDb.sln --build --dotnetcoresdk=$(dotnet --version) --output="$inspectCodeOutputPath" --format="xml" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --properties:ContinuousIntegrationBuild=false --properties:RunAnalyzers=false --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=GlobalPerProduct -dsl=SolutionPersonal -dsl=ProjectPersonal + dotnet jb inspectcode --version + dotnet jb inspectcode $env:SOLUTION_FILE --build --dotnetcoresdk=$(dotnet --version) --output="$inspectCodeOutputPath" --format="xml" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --properties:ContinuousIntegrationBuild=false --properties:RunAnalyzers=false --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=GlobalPerProduct -dsl=SolutionPersonal -dsl=ProjectPersonal - name: Verify outcome shell: pwsh run: | @@ -177,9 +185,11 @@ jobs: dotnet-version: | 8.0.* 9.0.* + 10.0.* - name: Git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: + persist-credentials: false fetch-depth: 2 - name: Restore tools run: dotnet tool restore @@ -195,13 +205,15 @@ jobs: $baseCommitHash = git rev-parse HEAD~1 Write-Output "Running code cleanup on commit range $baseCommitHash..$headCommitHash in pull request." - dotnet regitlint -s JsonApiDotNetCore.MongoDb.sln --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --verbosity=WARN -f commits -a $headCommitHash -b $baseCommitHash --fail-on-diff --print-diff + dotnet jb cleanupcode --version + dotnet regitlint -s $env:SOLUTION_FILE --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --verbosity=WARN -f commits -a $headCommitHash -b $baseCommitHash --fail-on-diff --print-diff - name: CleanupCode (on branch) if: ${{ github.event_name == 'push' || github.event_name == 'release' || github.event_name == 'workflow_dispatch' }} shell: pwsh run: | Write-Output 'Running code cleanup on all files.' - dotnet regitlint -s JsonApiDotNetCore.MongoDb.sln --print-command --skip-tool-check --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --verbosity=WARN --fail-on-diff --print-diff + dotnet jb cleanupcode --version + dotnet regitlint -s $env:SOLUTION_FILE --print-command --skip-tool-check --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --verbosity=WARN --fail-on-diff --print-diff publish: timeout-minutes: 60 @@ -220,12 +232,12 @@ jobs: if: ${{ github.event_name == 'push' || github.event_name == 'release' }} run: | dotnet nuget add source --username 'json-api-dotnet' --password '${{ secrets.GITHUB_TOKEN }}' --store-password-in-clear-text --name 'github' 'https://nuget.pkg.github.com/json-api-dotnet/index.json' - dotnet nuget push '${{ github.workspace }}/packages/*.nupkg' --api-key '${{ secrets.GITHUB_TOKEN }}' --source 'github' + dotnet nuget push '${{ github.workspace }}/packages/*.nupkg' --api-key '${{ secrets.GITHUB_TOKEN }}' --source 'github' --skip-duplicate - name: Publish to feedz.io if: ${{ github.event_name == 'push' || github.event_name == 'release' }} run: | dotnet nuget add source --name 'feedz-io' 'https://f.feedz.io/json-api-dotnet/jsonapidotnetcore/nuget/index.json' - dotnet nuget push '${{ github.workspace }}/packages/*.nupkg' --api-key '${{ secrets.FEEDZ_IO_API_KEY }}' --source 'feedz-io' + dotnet nuget push '${{ github.workspace }}/packages/*.nupkg' --api-key '${{ secrets.FEEDZ_IO_API_KEY }}' --source 'feedz-io' --skip-duplicate - name: Publish to NuGet if: ${{ github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v') }} run: dotnet nuget push '${{ github.workspace }}/packages/*.nupkg' --api-key '${{ secrets.NUGET_ORG_API_KEY }}' --source 'nuget.org' --skip-duplicate diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 96260f3..7cc1b5d 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -28,8 +28,11 @@ jobs: dotnet-version: | 8.0.* 9.0.* + 10.0.* - name: Git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 + with: + persist-credentials: false - name: Initialize CodeQL uses: github/codeql-action/init@v4 with: diff --git a/.github/workflows/deps-review.yml b/.github/workflows/deps-review.yml index 8461b45..f8c9c7e 100644 --- a/.github/workflows/deps-review.yml +++ b/.github/workflows/deps-review.yml @@ -9,6 +9,8 @@ jobs: runs-on: ubuntu-latest steps: - name: 'Checkout Repository' - uses: actions/checkout@v5 + uses: actions/checkout@v6 + with: + persist-credentials: false - name: 'Dependency Review' uses: actions/dependency-review-action@v4 diff --git a/Build.ps1 b/Build.ps1 index 1c369bd..d1df986 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -1,8 +1,6 @@ -function VerifySuccessExitCode { - if ($LastExitCode -ne 0) { - throw "Command failed with exit code $LastExitCode." - } -} +#Requires -Version 7.4 +$ErrorActionPreference = "Stop" +$PSNativeCommandUseErrorActionPreference = $true Write-Host "$(pwsh --version)" Write-Host ".NET SDK $(dotnet --version)" @@ -11,16 +9,7 @@ Remove-Item -Recurse -Force artifacts -ErrorAction SilentlyContinue Remove-Item -Recurse -Force * -Include coverage.cobertura.xml dotnet tool restore -VerifySuccessExitCode - dotnet build --configuration Release -VerifySuccessExitCode - dotnet test --no-build --configuration Release --verbosity quiet --collect:"XPlat Code Coverage" -VerifySuccessExitCode - dotnet reportgenerator -reports:**\coverage.cobertura.xml -targetdir:artifacts\coverage -filefilters:-*.g.cs -VerifySuccessExitCode - dotnet pack --no-build --configuration Release --output artifacts/packages -VerifySuccessExitCode diff --git a/Directory.Build.props b/Directory.Build.props index 01c226a..91c579a 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -9,9 +9,8 @@ Recommended $(MSBuildThisFileDirectory)CodingGuidelines.ruleset $(MSBuildThisFileDirectory)tests.runsettings - 5.9.0 + 5.10.0 pre - direct diff --git a/JsonApiDotNetCore.MongoDb.sln.DotSettings b/JsonApiDotNetCore.MongoDb.sln.DotSettings index cf02da1..047e40b 100644 --- a/JsonApiDotNetCore.MongoDb.sln.DotSettings +++ b/JsonApiDotNetCore.MongoDb.sln.DotSettings @@ -69,8 +69,10 @@ WARNING SUGGESTION SUGGESTION + WARNING SUGGESTION WARNING + WARNING DO_NOT_SHOW WARNING WARNING @@ -79,6 +81,7 @@ WARNING SUGGESTION WARNING + DO_NOT_SHOW HINT WARNING WARNING diff --git a/cleanupcode.ps1 b/cleanupcode.ps1 index 9a86aba..5fc9dec 100644 --- a/cleanupcode.ps1 +++ b/cleanupcode.ps1 @@ -1,4 +1,4 @@ -#Requires -Version 7.0 +#Requires -Version 7.4 # This script reformats (part of) the codebase to make it compliant with our coding guidelines. @@ -7,38 +7,31 @@ param( [string] $revision ) -function VerifySuccessExitCode { - if ($LastExitCode -ne 0) { - throw "Command failed with exit code $LastExitCode." - } -} +$ErrorActionPreference = "Stop" +$PSNativeCommandUseErrorActionPreference = $true dotnet tool restore -VerifySuccessExitCode - dotnet restore -VerifySuccessExitCode + +$solutionFile = 'JsonApiDotNetCore.MongoDb.sln' if ($revision) { $headCommitHash = git rev-parse HEAD - VerifySuccessExitCode - $baseCommitHash = git rev-parse $revision - VerifySuccessExitCode if ($baseCommitHash -eq $headCommitHash) { Write-Output "Running code cleanup on staged/unstaged files." - dotnet regitlint -s JsonApiDotNetCore.MongoDb.sln --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --verbosity=WARN -f staged,modified - VerifySuccessExitCode + dotnet jb cleanupcode --version + dotnet regitlint -s $solutionFile --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --verbosity=WARN -f staged,modified } else { Write-Output "Running code cleanup on commit range $baseCommitHash..$headCommitHash, including staged/unstaged files." - dotnet regitlint -s JsonApiDotNetCore.MongoDb.sln --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --verbosity=WARN -f staged,modified,commits -a $headCommitHash -b $baseCommitHash - VerifySuccessExitCode + dotnet jb cleanupcode --version + dotnet regitlint -s $solutionFile --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --verbosity=WARN -f staged,modified,commits -a $headCommitHash -b $baseCommitHash } } else { Write-Output "Running code cleanup on all files." - dotnet regitlint -s JsonApiDotNetCore.MongoDb.sln --print-command --skip-tool-check --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --verbosity=WARN - VerifySuccessExitCode + dotnet jb cleanupcode --version + dotnet regitlint -s $solutionFile --print-command --skip-tool-check --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --verbosity=WARN } diff --git a/inspectcode.ps1 b/inspectcode.ps1 index 25195fe..d9e9d62 100644 --- a/inspectcode.ps1 +++ b/inspectcode.ps1 @@ -1,20 +1,17 @@ -#Requires -Version 7.0 +#Requires -Version 7.4 +$ErrorActionPreference = "Stop" +$PSNativeCommandUseErrorActionPreference = $true # This script runs code inspection and opens the results in a web browser. dotnet tool restore -if ($LastExitCode -ne 0) { - throw "Tool restore failed with exit code $LastExitCode" -} - +$solutionFile = 'JsonApiDotNetCore.MongoDb.sln' $outputPath = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), 'jetbrains-inspectcode-results.xml') $resultPath = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), 'jetbrains-inspectcode-results.html') -dotnet jb inspectcode JsonApiDotNetCore.MongoDb.sln --dotnetcoresdk=$(dotnet --version) --build --output="$outputPath" --format="xml" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --properties:RunAnalyzers=false --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=GlobalPerProduct -dsl=SolutionPersonal -dsl=ProjectPersonal -if ($LastExitCode -ne 0) { - throw "Code inspection failed with exit code $LastExitCode" -} +dotnet jb inspectcode --version +dotnet jb inspectcode $solutionFile --dotnetcoresdk=$(dotnet --version) --build --output="$outputPath" --format="xml" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --properties:RunAnalyzers=false --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=GlobalPerProduct -dsl=SolutionPersonal -dsl=ProjectPersonal [xml]$xml = Get-Content "$outputPath" if ($xml.report.Issues -and $xml.report.Issues.Project) { diff --git a/package-versions.props b/package-versions.props index 3bedcbc..36991b2 100644 --- a/package-versions.props +++ b/package-versions.props @@ -1,7 +1,7 @@ - 5.9.0 + 5.10.0 3.3.0 @@ -9,7 +9,7 @@ 6.0.* 3.2.* 7.2.* - 2.4.* + 3.0.* 2.0.* 3.5.* 18.0.* @@ -17,6 +17,11 @@ 3.1.* + + + 10.0.* + + 9.0.* diff --git a/src/Examples/GettingStarted/GettingStarted.csproj b/src/Examples/GettingStarted/GettingStarted.csproj index 408a434..d78e9a6 100644 --- a/src/Examples/GettingStarted/GettingStarted.csproj +++ b/src/Examples/GettingStarted/GettingStarted.csproj @@ -1,6 +1,6 @@ - net9.0;net8.0 + net10.0;net9.0;net8.0 diff --git a/src/Examples/JsonApiDotNetCoreMongoDbExample/JsonApiDotNetCoreMongoDbExample.csproj b/src/Examples/JsonApiDotNetCoreMongoDbExample/JsonApiDotNetCoreMongoDbExample.csproj index 408a434..d78e9a6 100644 --- a/src/Examples/JsonApiDotNetCoreMongoDbExample/JsonApiDotNetCoreMongoDbExample.csproj +++ b/src/Examples/JsonApiDotNetCoreMongoDbExample/JsonApiDotNetCoreMongoDbExample.csproj @@ -1,6 +1,6 @@ - net9.0;net8.0 + net10.0;net9.0;net8.0 diff --git a/src/JsonApiDotNetCore.MongoDb/JsonApiDotNetCore.MongoDb.csproj b/src/JsonApiDotNetCore.MongoDb/JsonApiDotNetCore.MongoDb.csproj index 13aa46a..b1b6ae0 100644 --- a/src/JsonApiDotNetCore.MongoDb/JsonApiDotNetCore.MongoDb.csproj +++ b/src/JsonApiDotNetCore.MongoDb/JsonApiDotNetCore.MongoDb.csproj @@ -1,6 +1,6 @@  - net8.0 + net10.0;net8.0 true true @@ -32,6 +32,12 @@ + + + diff --git a/test/JsonApiDotNetCoreMongoDbTests/JsonApiDotNetCoreMongoDbTests.csproj b/test/JsonApiDotNetCoreMongoDbTests/JsonApiDotNetCoreMongoDbTests.csproj index 22338d5..d0601af 100644 --- a/test/JsonApiDotNetCoreMongoDbTests/JsonApiDotNetCoreMongoDbTests.csproj +++ b/test/JsonApiDotNetCoreMongoDbTests/JsonApiDotNetCoreMongoDbTests.csproj @@ -1,6 +1,6 @@ - net9.0;net8.0 + net10.0;net9.0;net8.0 diff --git a/test/TestBuildingBlocks/IntegrationTest.cs b/test/TestBuildingBlocks/IntegrationTest.cs index 4fc245a..38fea87 100644 --- a/test/TestBuildingBlocks/IntegrationTest.cs +++ b/test/TestBuildingBlocks/IntegrationTest.cs @@ -26,7 +26,7 @@ public abstract class IntegrationTest : IAsyncLifetime private static SemaphoreSlim GetDefaultThrottleSemaphore() { - int maxConcurrentTestRuns = OperatingSystem.IsWindows() && Environment.GetEnvironmentVariable("CI") != null ? 32 : 64; + int maxConcurrentTestRuns = OperatingSystem.IsWindows() && string.IsNullOrEmpty(Environment.GetEnvironmentVariable("VSAPPIDDIR")) ? 32 : 64; return new SemaphoreSlim(maxConcurrentTestRuns); } diff --git a/test/TestBuildingBlocks/MongoRunnerProvider.cs b/test/TestBuildingBlocks/MongoRunnerProvider.cs index 6339deb..6e5a3b8 100644 --- a/test/TestBuildingBlocks/MongoRunnerProvider.cs +++ b/test/TestBuildingBlocks/MongoRunnerProvider.cs @@ -2,21 +2,23 @@ using MongoDB.Bson; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; +using LockPrimitive = +#if NET9_0_OR_GREATER + System.Threading.Lock +#else + object +#endif + ; namespace TestBuildingBlocks; // Based on https://gist.github.com/asimmon/612b2d54f1a0d2b4e1115590d456e0be. internal sealed class MongoRunnerProvider { - public static readonly MongoRunnerProvider Instance = new(); private static readonly GuidSerializer StandardGuidSerializer = new(GuidRepresentation.Standard); + public static readonly MongoRunnerProvider Instance = new(); -#if NET8_0 - private readonly object _lockObject = new(); -#else - private readonly Lock _lockObject = new(); -#endif - + private readonly LockPrimitive _lockObject = new(); private IMongoRunner? _runner; private int _useCounter; diff --git a/test/TestBuildingBlocks/TestBuildingBlocks.csproj b/test/TestBuildingBlocks/TestBuildingBlocks.csproj index 79c9947..ccb0cdb 100644 --- a/test/TestBuildingBlocks/TestBuildingBlocks.csproj +++ b/test/TestBuildingBlocks/TestBuildingBlocks.csproj @@ -1,6 +1,6 @@  - net9.0;net8.0 + net10.0;net9.0;net8.0 diff --git a/test/TestBuildingBlocks/DateTimeExtensions.cs b/test/TestBuildingBlocks/TimeExtensions.cs similarity index 59% rename from test/TestBuildingBlocks/DateTimeExtensions.cs rename to test/TestBuildingBlocks/TimeExtensions.cs index a6afc92..8222994 100644 --- a/test/TestBuildingBlocks/DateTimeExtensions.cs +++ b/test/TestBuildingBlocks/TimeExtensions.cs @@ -1,9 +1,9 @@ namespace TestBuildingBlocks; -public static class DateTimeExtensions +public static class TimeExtensions { - // The milliseconds precision in DateTime/DateTimeOffset values that fakers produce is higher - // than what MongoDB can store. This results in our resource change tracker to detect + // The milliseconds precision in DateTime/DateTimeOffset/TimeSpan/TimeOnly values that fakers produce + // is higher than what MongoDB can store. This results in our resource change tracker to detect // that the time stored in the database differs from the time in the request body. While that's // technically correct, we don't want such side effects influencing our tests everywhere. @@ -18,9 +18,13 @@ public static DateTimeOffset TruncateToWholeMilliseconds(this DateTimeOffset val public static DateTime TruncateToWholeMilliseconds(this DateTime value) { - long ticksToSubtract = value.Ticks % TimeSpan.TicksPerMillisecond; - long ticksInWholeMilliseconds = value.Ticks - ticksToSubtract; - + long ticksInWholeMilliseconds = TruncateTicksInWholeMilliseconds(value.Ticks); return new DateTime(ticksInWholeMilliseconds, value.Kind); } + + private static long TruncateTicksInWholeMilliseconds(long ticks) + { + long ticksToSubtract = ticks % TimeSpan.TicksPerMillisecond; + return ticks - ticksToSubtract; + } } diff --git a/test/TestBuildingBlocks/Unknown.cs b/test/TestBuildingBlocks/Unknown.cs index f8fde85..e864a5e 100644 --- a/test/TestBuildingBlocks/Unknown.cs +++ b/test/TestBuildingBlocks/Unknown.cs @@ -21,7 +21,7 @@ public static string For() } throw new NotSupportedException( - $"Unsupported '{nameof(Identifiable.Id)}' property of type '{type}' on resource type '{typeof(TResource).Name}'."); + $"Unsupported '{nameof(Identifiable<>.Id)}' property of type '{type}' on resource type '{typeof(TResource).Name}'."); } } }