diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index f161416014..6344f46965 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "jetbrains.resharper.globaltools": { - "version": "2023.3.4", + "version": "2024.1.0", "commands": [ "jb" ] diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0e41da591a..65fd3ff64d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -206,7 +206,7 @@ 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.sln --build --dotnetcoresdk=$(dotnet --version) --output="$inspectCodeOutputPath" --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 JsonApiDotNetCore.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 - name: Verify outcome shell: pwsh run: | diff --git a/JsonApiDotNetCore.sln.DotSettings b/JsonApiDotNetCore.sln.DotSettings index 4f68cc519a..399be60883 100644 --- a/JsonApiDotNetCore.sln.DotSettings +++ b/JsonApiDotNetCore.sln.DotSettings @@ -590,11 +590,14 @@ JsonApiDotNetCore.ArgumentGuard.NotNull($EXPR$); False <Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /> <Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /> + <Policy><Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /></Policy> + <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"><ElementKinds><Kind Name="FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /></Policy> True True True True True + True True Replace argument null check using throw expression with Guard clause True diff --git a/benchmarks/Serialization/SerializationBenchmarkBase.cs b/benchmarks/Serialization/SerializationBenchmarkBase.cs index 4b16afb393..eba222c9d1 100644 --- a/benchmarks/Serialization/SerializationBenchmarkBase.cs +++ b/benchmarks/Serialization/SerializationBenchmarkBase.cs @@ -41,7 +41,7 @@ protected SerializationBenchmarkBase() var linkBuilder = new FakeLinkBuilder(); var metaBuilder = new NoMetaBuilder(); - IQueryConstraintProvider[] constraintProviders = Array.Empty(); + IQueryConstraintProvider[] constraintProviders = []; var resourceDefinitionAccessor = new NeverResourceDefinitionAccessor(); var sparseFieldSetCache = new SparseFieldSetCache(constraintProviders, resourceDefinitionAccessor); var requestQueryStringAccessor = new FakeRequestQueryStringAccessor(); diff --git a/inspectcode.ps1 b/inspectcode.ps1 index aa816da5e9..21e96eac67 100644 --- a/inspectcode.ps1 +++ b/inspectcode.ps1 @@ -10,7 +10,7 @@ if ($LastExitCode -ne 0) { $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 --dotnetcoresdk=$(dotnet --version) --build --output="$outputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --properties:RunAnalyzers=false --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=GlobalPerProduct -dsl=SolutionPersonal -dsl=ProjectPersonal +dotnet jb inspectcode JsonApiDotNetCore.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" diff --git a/src/Examples/NoEntityFrameworkExample/NullSafeExpressionRewriter.cs b/src/Examples/NoEntityFrameworkExample/NullSafeExpressionRewriter.cs index 67b04d1d3d..61ebb8b8b0 100644 --- a/src/Examples/NoEntityFrameworkExample/NullSafeExpressionRewriter.cs +++ b/src/Examples/NoEntityFrameworkExample/NullSafeExpressionRewriter.cs @@ -300,7 +300,7 @@ private static ConstantExpression CreateConstantForMemberIsNull(Type type) if (getter != null) { - object? value = getter.Invoke(null, Array.Empty()); + object? value = getter.Invoke(null, []); return Expression.Constant(value, type); } } diff --git a/src/JsonApiDotNetCore/Middleware/TraceLogWriter.cs b/src/JsonApiDotNetCore/Middleware/TraceLogWriter.cs index c02b8c02d3..e17f02ed21 100644 --- a/src/JsonApiDotNetCore/Middleware/TraceLogWriter.cs +++ b/src/JsonApiDotNetCore/Middleware/TraceLogWriter.cs @@ -201,7 +201,7 @@ private static void WriteObject(StringBuilder builder, object? value) private static bool HasToStringOverload(Type type) { - MethodInfo? toStringMethod = type.GetMethod("ToString", Array.Empty()); + MethodInfo? toStringMethod = type.GetMethod("ToString", []); return toStringMethod != null && toStringMethod.DeclaringType != typeof(object); } diff --git a/src/JsonApiDotNetCore/Queries/Expressions/LogicalExpression.cs b/src/JsonApiDotNetCore/Queries/Expressions/LogicalExpression.cs index 21a1b61e1c..f1a9ba8c1c 100644 --- a/src/JsonApiDotNetCore/Queries/Expressions/LogicalExpression.cs +++ b/src/JsonApiDotNetCore/Queries/Expressions/LogicalExpression.cs @@ -52,6 +52,8 @@ public LogicalExpression(LogicalOperator @operator, IImmutableList terms = filters.WhereNotNull().ToImmutableArray(); return terms.Length > 1 ? new LogicalExpression(@operator, terms) : terms.FirstOrDefault(); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/Blobs/ImageContainer.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/Blobs/ImageContainer.cs index 4ad0e54d5a..3462cdb2df 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/Blobs/ImageContainer.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/Blobs/ImageContainer.cs @@ -12,7 +12,7 @@ public sealed class ImageContainer : Identifiable public string FileName { get; set; } = null!; [Attr] - public byte[] Data { get; set; } = Array.Empty(); + public byte[] Data { get; set; } = []; [Attr] public byte[]? Thumbnail { get; set; } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/ResourceInheritanceWriteTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/ResourceInheritanceWriteTests.cs index 0fcd65e701..0e55f5ad85 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/ResourceInheritanceWriteTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/ResourceInheritanceWriteTests.cs @@ -1766,7 +1766,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }); tandemStore.AssertLeftType(); - tandemStore.AssertRightTypes(Array.Empty()); + tandemStore.AssertRightTypes([]); } [Fact] diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/ResourceTypeCapturingDefinition.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/ResourceTypeCapturingDefinition.cs index e2754968a7..8e9a49dbfc 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/ResourceTypeCapturingDefinition.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/ResourceTypeCapturingDefinition.cs @@ -82,7 +82,7 @@ public override Task OnWriteSucceededAsync(TResource resource, WriteOperationKin private void EnsureSnapshot(TResource leftType, IIdentifiable? rightResourceId = null) { - IIdentifiable[] rightResourceIds = rightResourceId != null ? [rightResourceId] : Array.Empty(); + IIdentifiable[] rightResourceIds = rightResourceId != null ? [rightResourceId] : []; EnsureSnapshot(leftType, rightResourceIds); }