From dd4dc37f03b63a076701db58e8977f611a7c37c5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Apr 2024 00:36:58 +0000 Subject: [PATCH 1/3] Bump docfx from 2.74.0 to 2.76.0 (#1524) --- .config/dotnet-tools.json | 2 +- docs/docfx.json | 3 +++ docs/request-examples/index.md | 4 ++++ docs/request-examples/toc.md | 0 .../FieldChains/FieldChainPattern.cs | 20 +++++++++++++++---- .../Request/Adapters/IDocumentAdapter.cs | 8 ++++---- .../Response/IResponseModelAdapter.cs | 12 +++++------ 7 files changed, 34 insertions(+), 15 deletions(-) create mode 100644 docs/request-examples/toc.md diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index b255005e33..f161416014 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -21,7 +21,7 @@ ] }, "docfx": { - "version": "2.74.0", + "version": "2.76.0", "commands": [ "docfx" ] diff --git a/docs/docfx.json b/docs/docfx.json index 1d0e192ac2..eb94da412e 100644 --- a/docs/docfx.json +++ b/docs/docfx.json @@ -24,6 +24,9 @@ "internals/**.md", "toc.yml", "*.md" + ], + "exclude": [ + "**/README.md" ] } ], diff --git a/docs/request-examples/index.md b/docs/request-examples/index.md index c34b3d713a..614aa4814f 100644 --- a/docs/request-examples/index.md +++ b/docs/request-examples/index.md @@ -1,3 +1,7 @@ +--- +_disableToc: true +--- + # Example requests These requests have been generated against the "GettingStarted" application and are updated on every deployment. diff --git a/docs/request-examples/toc.md b/docs/request-examples/toc.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/JsonApiDotNetCore/QueryStrings/FieldChains/FieldChainPattern.cs b/src/JsonApiDotNetCore/QueryStrings/FieldChains/FieldChainPattern.cs index 4928984030..fb63c6a03d 100644 --- a/src/JsonApiDotNetCore/QueryStrings/FieldChains/FieldChainPattern.cs +++ b/src/JsonApiDotNetCore/QueryStrings/FieldChains/FieldChainPattern.cs @@ -49,7 +49,7 @@ internal FieldChainPattern(FieldTypes choices, bool atLeastOne, bool atMostOne, /// /// /// Patterns are similar to regular expressions, but a lot simpler. They consist of a sequence of terms. A term can be a single character or a character - /// choice, optionally followed by a quantifier. + /// choice. A term is optionally followed by a quantifier. ///

/// The following characters can be used: /// @@ -58,18 +58,26 @@ internal FieldChainPattern(FieldTypes choices, bool atLeastOne, bool atMostOne, /// /// Matches a to-many relationship. /// + /// + /// /// O /// /// Matches a to-one relationship. /// + /// + /// /// R /// /// Matches a relationship. /// + /// + /// /// A /// /// Matches an attribute. /// + /// + /// /// F /// /// Matches a field. @@ -86,15 +94,19 @@ internal FieldChainPattern(FieldTypes choices, bool atLeastOne, bool atMostOne, /// /// ? /// - /// Matches its term zero or one times. + /// Matches its preceding term zero or one times. /// + /// + /// /// * /// - /// Matches its term zero or more times. + /// Matches its preceding term zero or more times. /// + /// + /// /// + /// - /// Matches its term one or more times. + /// Matches its preceding term one or more times. /// /// /// diff --git a/src/JsonApiDotNetCore/Serialization/Request/Adapters/IDocumentAdapter.cs b/src/JsonApiDotNetCore/Serialization/Request/Adapters/IDocumentAdapter.cs index 794278fc73..5480d41c01 100644 --- a/src/JsonApiDotNetCore/Serialization/Request/Adapters/IDocumentAdapter.cs +++ b/src/JsonApiDotNetCore/Serialization/Request/Adapters/IDocumentAdapter.cs @@ -13,22 +13,22 @@ public interface IDocumentAdapter /// /// /// - /// ]]> (operations) + /// ]]> (operations) /// /// /// /// - /// ]]> (to-many relationship, unknown relationship) + /// ]]> (to-many relationship, unknown relationship) /// /// /// /// - /// (resource, to-one relationship) + /// (resource, to-one relationship) /// /// /// /// - /// (to-one relationship) + /// (to-one relationship) /// /// /// diff --git a/src/JsonApiDotNetCore/Serialization/Response/IResponseModelAdapter.cs b/src/JsonApiDotNetCore/Serialization/Response/IResponseModelAdapter.cs index f458edf33a..49b0f65c95 100644 --- a/src/JsonApiDotNetCore/Serialization/Response/IResponseModelAdapter.cs +++ b/src/JsonApiDotNetCore/Serialization/Response/IResponseModelAdapter.cs @@ -12,32 +12,32 @@ public interface IResponseModelAdapter /// /// /// - /// ]]> + /// ]]> /// /// /// /// - /// + /// /// /// /// /// - /// + /// /// /// /// /// - /// ]]> + /// ]]> /// /// /// /// - /// ]]> + /// ]]> /// /// /// /// - /// + /// /// /// /// From 872c7d6770feb77e01eda0956d1f71676fdd41a8 Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Tue, 9 Apr 2024 00:03:21 +0200 Subject: [PATCH 2/3] Fix whitespace in query string parameters within pagination links. See conversation at https://github.com/dotnet/runtime/issues/100792. --- src/JsonApiDotNetCore/Serialization/Response/LinkBuilder.cs | 2 +- .../QueryStrings/Filtering/FilterOperatorTests.cs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/JsonApiDotNetCore/Serialization/Response/LinkBuilder.cs b/src/JsonApiDotNetCore/Serialization/Response/LinkBuilder.cs index ffb8b8e9b7..27cf775d70 100644 --- a/src/JsonApiDotNetCore/Serialization/Response/LinkBuilder.cs +++ b/src/JsonApiDotNetCore/Serialization/Response/LinkBuilder.cs @@ -214,7 +214,7 @@ private string GetLinkForPagination(int pageOffset, string? pageSizeValue) }; UriComponents components = _options.UseRelativeLinks ? UriComponents.PathAndQuery : UriComponents.AbsoluteUri; - return builder.Uri.GetComponents(components, UriFormat.SafeUnescaped); + return builder.Uri.GetComponents(components, UriFormat.UriEscaped); } private string GetQueryStringInPaginationLink(int pageOffset, string? pageSizeValue) diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Filtering/FilterOperatorTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Filtering/FilterOperatorTests.cs index bc3c70c59a..a955baa230 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Filtering/FilterOperatorTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Filtering/FilterOperatorTests.cs @@ -85,6 +85,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Data.ManyValue.ShouldHaveCount(1); responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someString").With(value => value.Should().Be(resource.SomeString)); + + responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Self.Should().Be("http://localhost/filterableResources?filter=equals(someString,'This%2c+that+%26+more+%2b+some')"); + responseDocument.Links.First.Should().Be("http://localhost/filterableResources?filter=equals(someString,%27This,%20that%20%26%20more%20%2B%20some%27)"); } [Fact] From 6be44a401a18a649f109c89467569e0b4e27c1c1 Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Wed, 10 Apr 2024 02:24:04 +0200 Subject: [PATCH 3/3] Update to Resharper v2024.1.0 (#1520) Update to Resharper v2024.1.0 --- .config/dotnet-tools.json | 2 +- .github/workflows/build.yml | 2 +- JsonApiDotNetCore.sln.DotSettings | 3 +++ benchmarks/Serialization/SerializationBenchmarkBase.cs | 2 +- inspectcode.ps1 | 2 +- .../NoEntityFrameworkExample/NullSafeExpressionRewriter.cs | 2 +- src/JsonApiDotNetCore/Middleware/TraceLogWriter.cs | 2 +- src/JsonApiDotNetCore/Queries/Expressions/LogicalExpression.cs | 2 ++ .../IntegrationTests/Blobs/ImageContainer.cs | 2 +- .../ResourceInheritance/ResourceInheritanceWriteTests.cs | 2 +- .../ResourceInheritance/ResourceTypeCapturingDefinition.cs | 2 +- 11 files changed, 14 insertions(+), 9 deletions(-) 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); }