From b4646454878be92663a0ebe9b6dfbcdd7242f7a7 Mon Sep 17 00:00:00 2001 From: Bart Koelman Date: Wed, 1 Sep 2021 11:09:50 +0200 Subject: [PATCH 1/4] Updated Resharper global tools --- .config/dotnet-tools.json | 4 ++-- Build.ps1 | 2 +- cleanupcode.ps1 | 4 ++-- inspectcode.ps1 | 8 +------- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 1c7cf727cb..714b2b9b76 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "jetbrains.resharper.globaltools": { - "version": "2021.1.4", + "version": "2021.2.1", "commands": [ "jb" ] @@ -27,4 +27,4 @@ ] } } -} +} \ No newline at end of file diff --git a/Build.ps1 b/Build.ps1 index ee1dd68cfb..08e75dd12d 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -8,7 +8,7 @@ function CheckLastExitCode { function RunInspectCode { $outputPath = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), 'jetbrains-inspectcode-results.xml') - dotnet jb inspectcode JsonApiDotNetCore.sln --output="$outputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=SolutionPersonal -dsl=ProjectPersonal + dotnet jb inspectcode --no-build JsonApiDotNetCore.sln --output="$outputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=SolutionPersonal -dsl=ProjectPersonal CheckLastExitCode [xml]$xml = Get-Content "$outputPath" diff --git a/cleanupcode.ps1 b/cleanupcode.ps1 index 605ebff705..dccf70ebc1 100644 --- a/cleanupcode.ps1 +++ b/cleanupcode.ps1 @@ -8,10 +8,10 @@ if ($LASTEXITCODE -ne 0) { throw "Tool restore failed with exit code $LASTEXITCODE" } -dotnet build -c Release +dotnet restore if ($LASTEXITCODE -ne 0) { - throw "Build failed with exit code $LASTEXITCODE" + throw "Package restore failed with exit code $LASTEXITCODE" } dotnet regitlint -s JsonApiDotNetCore.sln --print-command --jb --profile --jb --profile='\"JADNC Full Cleanup\"' --jb --properties:Configuration=Release --jb --verbosity=WARN diff --git a/inspectcode.ps1 b/inspectcode.ps1 index ab4b9c95dd..6c9d90768e 100644 --- a/inspectcode.ps1 +++ b/inspectcode.ps1 @@ -8,15 +8,9 @@ if ($LASTEXITCODE -ne 0) { throw "Tool restore failed with exit code $LASTEXITCODE" } -dotnet build -c Release - -if ($LASTEXITCODE -ne 0) { - throw "Build failed with exit code $LASTEXITCODE" -} - $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.sln --output="$outputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=SolutionPersonal -dsl=ProjectPersonal +dotnet jb inspectcode JsonApiDotNetCore.sln --build --output="$outputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=SolutionPersonal -dsl=ProjectPersonal if ($LASTEXITCODE -ne 0) { throw "Code inspection failed with exit code $LASTEXITCODE" From b9d5e7b1a7d28244d3bbec0a0f10301516900f83 Mon Sep 17 00:00:00 2001 From: Bart Koelman Date: Wed, 1 Sep 2021 11:16:02 +0200 Subject: [PATCH 2/4] Auto-reformat codebase using updated Resharper tools version --- .../ResourcesInRelationshipsNotFoundException.cs | 2 +- src/JsonApiDotNetCore/ObjectExtensions.cs | 4 ++-- .../ResourceObjectBuilderSettingsProvider.cs | 2 +- .../QueryStrings/MusicTrackReleaseDefinition.cs | 2 +- .../Microservices/Messages/OutgoingMessage.cs | 2 +- .../HttpResponseMessageExtensions.cs | 2 +- .../UnitTests/Middleware/JsonApiMiddlewareTests.cs | 14 +++++++++++--- .../Serialization/DeserializerTestsSetup.cs | 4 ++-- 8 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/JsonApiDotNetCore/Errors/ResourcesInRelationshipsNotFoundException.cs b/src/JsonApiDotNetCore/Errors/ResourcesInRelationshipsNotFoundException.cs index d749bca5fa..94503ab343 100644 --- a/src/JsonApiDotNetCore/Errors/ResourcesInRelationshipsNotFoundException.cs +++ b/src/JsonApiDotNetCore/Errors/ResourcesInRelationshipsNotFoundException.cs @@ -19,7 +19,7 @@ public ResourcesInRelationshipsNotFoundException(IEnumerable(this T element) public static List AsList(this T element) { - return new() + return new List { element }; @@ -29,7 +29,7 @@ public static List AsList(this T element) public static HashSet AsHashSet(this T element) { - return new() + return new HashSet { element }; diff --git a/src/JsonApiDotNetCore/Serialization/Building/ResourceObjectBuilderSettingsProvider.cs b/src/JsonApiDotNetCore/Serialization/Building/ResourceObjectBuilderSettingsProvider.cs index 04a5128aed..d28a7591eb 100644 --- a/src/JsonApiDotNetCore/Serialization/Building/ResourceObjectBuilderSettingsProvider.cs +++ b/src/JsonApiDotNetCore/Serialization/Building/ResourceObjectBuilderSettingsProvider.cs @@ -24,7 +24,7 @@ public ResourceObjectBuilderSettingsProvider(IDefaultsQueryStringParameterReader /// public ResourceObjectBuilderSettings Get() { - return new(_nullsReader.SerializerNullValueHandling, _defaultsReader.SerializerDefaultValueHandling); + return new ResourceObjectBuilderSettings(_nullsReader.SerializerNullValueHandling, _defaultsReader.SerializerDefaultValueHandling); } } } diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/QueryStrings/MusicTrackReleaseDefinition.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/QueryStrings/MusicTrackReleaseDefinition.cs index ac3c4b12a3..857f68ef25 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/QueryStrings/MusicTrackReleaseDefinition.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/QueryStrings/MusicTrackReleaseDefinition.cs @@ -24,7 +24,7 @@ public MusicTrackReleaseDefinition(IResourceGraph resourceGraph, ISystemClock sy public override QueryStringParameterHandlers OnRegisterQueryableHandlersForQueryStringParameters() { - return new() + return new QueryStringParameterHandlers { ["isRecentlyReleased"] = FilterOnRecentlyReleased }; diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/Messages/OutgoingMessage.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/Messages/OutgoingMessage.cs index f001514efc..68837f0d12 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/Messages/OutgoingMessage.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/Messages/OutgoingMessage.cs @@ -22,7 +22,7 @@ public T GetContentAs() public static OutgoingMessage CreateFromContent(IMessageContent content) { - return new() + return new OutgoingMessage { Type = content.GetType().Name, FormatVersion = content.FormatVersion, diff --git a/test/TestBuildingBlocks/HttpResponseMessageExtensions.cs b/test/TestBuildingBlocks/HttpResponseMessageExtensions.cs index 681166358a..3edc655e80 100644 --- a/test/TestBuildingBlocks/HttpResponseMessageExtensions.cs +++ b/test/TestBuildingBlocks/HttpResponseMessageExtensions.cs @@ -14,7 +14,7 @@ public static class HttpResponseMessageExtensions { public static HttpResponseMessageAssertions Should(this HttpResponseMessage instance) { - return new(instance); + return new HttpResponseMessageAssertions(instance); } public sealed class HttpResponseMessageAssertions : ReferenceTypeAssertions diff --git a/test/UnitTests/Middleware/JsonApiMiddlewareTests.cs b/test/UnitTests/Middleware/JsonApiMiddlewareTests.cs index 22c4f92f57..faa199c468 100644 --- a/test/UnitTests/Middleware/JsonApiMiddlewareTests.cs +++ b/test/UnitTests/Middleware/JsonApiMiddlewareTests.cs @@ -135,9 +135,17 @@ private static Mock CreateMockOptions(string forcedNamespace) private static DefaultHttpContext CreateHttpContext(string path, bool isRelationship = false, string action = "", string id = null) { - var context = new DefaultHttpContext(); - context.Request.Path = new PathString(path); - context.Response.Body = new MemoryStream(); + var context = new DefaultHttpContext + { + Request = + { + Path = new PathString(path) + }, + Response = + { + Body = new MemoryStream() + } + }; var feature = new RouteValuesFeature { diff --git a/test/UnitTests/Serialization/DeserializerTestsSetup.cs b/test/UnitTests/Serialization/DeserializerTestsSetup.cs index bf851f0f0c..0ffb883b53 100644 --- a/test/UnitTests/Serialization/DeserializerTestsSetup.cs +++ b/test/UnitTests/Serialization/DeserializerTestsSetup.cs @@ -30,7 +30,7 @@ protected Document CreateDocumentWithRelationships(string primaryType, string re protected Document CreateDocumentWithRelationships(string primaryType) { - return new() + return new Document { Data = new ResourceObject { @@ -67,7 +67,7 @@ protected RelationshipEntry CreateRelationshipData(string relatedType = null, bo protected Document CreateTestResourceDocument() { - return new() + return new Document { Data = new ResourceObject { From a84a305c61e8b0e1af45812b0d38be751b5a6f6a Mon Sep 17 00:00:00 2001 From: Bart Koelman Date: Wed, 1 Sep 2021 11:31:52 +0200 Subject: [PATCH 3/4] Increased verbosity to diagnose cibuild hang --- Build.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Build.ps1 b/Build.ps1 index 08e75dd12d..a7714e9673 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -8,7 +8,7 @@ function CheckLastExitCode { function RunInspectCode { $outputPath = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), 'jetbrains-inspectcode-results.xml') - dotnet jb inspectcode --no-build JsonApiDotNetCore.sln --output="$outputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=SolutionPersonal -dsl=ProjectPersonal + dotnet jb inspectcode --debug --no-build JsonApiDotNetCore.sln --output="$outputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --severity=WARNING --verbosity=TRACE -dsl=GlobalAll -dsl=SolutionPersonal -dsl=ProjectPersonal CheckLastExitCode [xml]$xml = Get-Content "$outputPath" @@ -47,7 +47,7 @@ function RunCleanupCode { $mergeCommitHash = git rev-parse "HEAD" $targetCommitHash = git rev-parse "$env:APPVEYOR_REPO_BRANCH" - dotnet regitlint -s JsonApiDotNetCore.sln --print-command --jb --profile --jb --profile='\"JADNC Full Cleanup\"' --jb --properties:Configuration=Release --jb --verbosity=WARN -f commits -a $mergeCommitHash -b $targetCommitHash --fail-on-diff --print-diff + dotnet regitlint -s JsonApiDotNetCore.sln --print-command --jb --verbosity=TRACE --jb --debug --jb --profile --jb --profile='\"JADNC Full Cleanup\"' --jb --properties:Configuration=Release --jb --verbosity=WARN -f commits -a $mergeCommitHash -b $targetCommitHash --fail-on-diff --print-diff CheckLastExitCode } } From eb42f2344e8d1dcf28695008dce1a796c3cd0033 Mon Sep 17 00:00:00 2001 From: Bart Koelman Date: Wed, 1 Sep 2021 11:32:29 +0200 Subject: [PATCH 4/4] Skip the rest of the build after InspectCode step --- Build.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Build.ps1 b/Build.ps1 index a7714e9673..cc8e47d390 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -100,11 +100,11 @@ dotnet build -c Release CheckLastExitCode RunInspectCode -RunCleanupCode +#RunCleanupCode -dotnet test -c Release --no-build --collect:"XPlat Code Coverage" -CheckLastExitCode +#dotnet test -c Release --no-build --collect:"XPlat Code Coverage" +#CheckLastExitCode -ReportCodeCoverage +#ReportCodeCoverage -CreateNuGetPackage +#CreateNuGetPackage