Skip to content

Commit 9bdea37

Browse files
authored
Merge pull request #1527 from json-api-dotnet/merge-master-into-openapi
Merge master into openapi
2 parents 1f38b99 + 67ce105 commit 9bdea37

File tree

19 files changed

+53
-25
lines changed

19 files changed

+53
-25
lines changed

.config/dotnet-tools.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"isRoot": true,
44
"tools": {
55
"jetbrains.resharper.globaltools": {
6-
"version": "2023.3.4",
6+
"version": "2024.1.0",
77
"commands": [
88
"jb"
99
]
@@ -21,7 +21,7 @@
2121
]
2222
},
2323
"docfx": {
24-
"version": "2.74.0",
24+
"version": "2.76.0",
2525
"commands": [
2626
"docfx"
2727
]

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ jobs:
206206
run: |
207207
$inspectCodeOutputPath = Join-Path $env:RUNNER_TEMP 'jetbrains-inspectcode-results.xml'
208208
Write-Output "INSPECT_CODE_OUTPUT_PATH=$inspectCodeOutputPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
209-
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
209+
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
210210
- name: Verify outcome
211211
shell: pwsh
212212
run: |

JsonApiDotNetCore.sln.DotSettings

+3
Original file line numberDiff line numberDiff line change
@@ -594,11 +594,14 @@ JsonApiDotNetCore.ArgumentGuard.NotNull($EXPR$);</s:String>
594594
<s:Boolean x:Key="/Default/CodeStyle/Naming/CSharpNaming/ApplyAutoDetectedRules/@EntryValue">False</s:Boolean>
595595
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;</s:String>
596596
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;</s:String>
597+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=4a98fdf6_002D7d98_002D4f5a_002Dafeb_002Dea44ad98c70c/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
598+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=f9fce829_002De6f4_002D4cb2_002D80f1_002D5497c44f51df/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
597599
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
598600
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
599601
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
600602
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAlwaysTreatStructAsNotReorderableMigration/@EntryIndexedValue">True</s:Boolean>
601603
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
604+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EPredefinedNamingRulesToUserRulesUpgrade/@EntryIndexedValue">True</s:Boolean>
602605
<s:Boolean x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=546845333F49494AB6CF8F0477A0F71D/@KeyIndexDefined">True</s:Boolean>
603606
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=546845333F49494AB6CF8F0477A0F71D/Comment/@EntryValue">Replace argument null check using throw expression with Guard clause</s:String>
604607
<s:Boolean x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=546845333F49494AB6CF8F0477A0F71D/CustomPatternPlaceholder/=argument/@KeyIndexDefined">True</s:Boolean>

benchmarks/Serialization/SerializationBenchmarkBase.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ protected SerializationBenchmarkBase()
4141

4242
var linkBuilder = new FakeLinkBuilder();
4343
var metaBuilder = new NoMetaBuilder();
44-
IQueryConstraintProvider[] constraintProviders = Array.Empty<IQueryConstraintProvider>();
44+
IQueryConstraintProvider[] constraintProviders = [];
4545
var resourceDefinitionAccessor = new NeverResourceDefinitionAccessor();
4646
var sparseFieldSetCache = new SparseFieldSetCache(constraintProviders, resourceDefinitionAccessor);
4747
var requestQueryStringAccessor = new FakeRequestQueryStringAccessor();

docs/docfx.json

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
"internals/**.md",
2525
"toc.yml",
2626
"*.md"
27+
],
28+
"exclude": [
29+
"**/README.md"
2730
]
2831
}
2932
],

docs/request-examples/index.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
_disableToc: true
3+
---
4+
15
# Example requests
26

37
These requests have been generated against the "GettingStarted" application and are updated on every deployment.

docs/request-examples/toc.md

Whitespace-only changes.

inspectcode.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if ($LastExitCode -ne 0) {
1010

1111
$outputPath = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), 'jetbrains-inspectcode-results.xml')
1212
$resultPath = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), 'jetbrains-inspectcode-results.html')
13-
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
13+
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
1414

1515
if ($LastExitCode -ne 0) {
1616
throw "Code inspection failed with exit code $LastExitCode"

src/Examples/NoEntityFrameworkExample/NullSafeExpressionRewriter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ private static ConstantExpression CreateConstantForMemberIsNull(Type type)
300300

301301
if (getter != null)
302302
{
303-
object? value = getter.Invoke(null, Array.Empty<object>());
303+
object? value = getter.Invoke(null, []);
304304
return Expression.Constant(value, type);
305305
}
306306
}

src/JsonApiDotNetCore/Middleware/TraceLogWriter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ private static void WriteObject(StringBuilder builder, object? value)
201201

202202
private static bool HasToStringOverload(Type type)
203203
{
204-
MethodInfo? toStringMethod = type.GetMethod("ToString", Array.Empty<Type>());
204+
MethodInfo? toStringMethod = type.GetMethod("ToString", []);
205205
return toStringMethod != null && toStringMethod.DeclaringType != typeof(object);
206206
}
207207

src/JsonApiDotNetCore/Queries/Expressions/LogicalExpression.cs

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public LogicalExpression(LogicalOperator @operator, IImmutableList<FilterExpress
5252
{
5353
ArgumentGuard.NotNull(filters);
5454

55+
// Workaround for https://youtrack.jetbrains.com/issue/RSRP-496512/Invalid-Use-collection-expression-suggestion.
56+
// ReSharper disable once UseCollectionExpression
5557
ImmutableArray<FilterExpression> terms = filters.WhereNotNull().ToImmutableArray();
5658

5759
return terms.Length > 1 ? new LogicalExpression(@operator, terms) : terms.FirstOrDefault();

src/JsonApiDotNetCore/QueryStrings/FieldChains/FieldChainPattern.cs

+16-4
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ internal FieldChainPattern(FieldTypes choices, bool atLeastOne, bool atMostOne,
4949
/// </summary>
5050
/// <remarks>
5151
/// 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
52-
/// choice, optionally followed by a quantifier.
52+
/// choice. A term is optionally followed by a quantifier.
5353
/// <p>
5454
/// The following characters can be used:
5555
/// <list type="table">
@@ -58,18 +58,26 @@ internal FieldChainPattern(FieldTypes choices, bool atLeastOne, bool atMostOne,
5858
/// <description>
5959
/// Matches a to-many relationship.
6060
/// </description>
61+
/// </item>
62+
/// <item>
6163
/// <term>O</term>
6264
/// <description>
6365
/// Matches a to-one relationship.
6466
/// </description>
67+
/// </item>
68+
/// <item>
6569
/// <term>R</term>
6670
/// <description>
6771
/// Matches a relationship.
6872
/// </description>
73+
/// </item>
74+
/// <item>
6975
/// <term>A</term>
7076
/// <description>
7177
/// Matches an attribute.
7278
/// </description>
79+
/// </item>
80+
/// <item>
7381
/// <term>F</term>
7482
/// <description>
7583
/// Matches a field.
@@ -86,15 +94,19 @@ internal FieldChainPattern(FieldTypes choices, bool atLeastOne, bool atMostOne,
8694
/// <item>
8795
/// <term>?</term>
8896
/// <description>
89-
/// Matches its term zero or one times.
97+
/// Matches its preceding term zero or one times.
9098
/// </description>
99+
/// </item>
100+
/// <item>
91101
/// <term>*</term>
92102
/// <description>
93-
/// Matches its term zero or more times.
103+
/// Matches its preceding term zero or more times.
94104
/// </description>
105+
/// </item>
106+
/// <item>
95107
/// <term>+</term>
96108
/// <description>
97-
/// Matches its term one or more times.
109+
/// Matches its preceding term one or more times.
98110
/// </description>
99111
/// </item>
100112
/// </list>

src/JsonApiDotNetCore/Serialization/Request/Adapters/IDocumentAdapter.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ public interface IDocumentAdapter
1313
/// <list type="bullet">
1414
/// <item>
1515
/// <description>
16-
/// <code><![CDATA[IList<OperationContainer>]]></code> (operations)
16+
/// <c><![CDATA[IList<OperationContainer>]]></c> (operations)
1717
/// </description>
1818
/// </item>
1919
/// <item>
2020
/// <description>
21-
/// <code><![CDATA[ISet<IIdentifiable>]]></code> (to-many relationship, unknown relationship)
21+
/// <c><![CDATA[ISet<IIdentifiable>]]></c> (to-many relationship, unknown relationship)
2222
/// </description>
2323
/// </item>
2424
/// <item>
2525
/// <description>
26-
/// <code><![CDATA[IIdentifiable]]></code> (resource, to-one relationship)
26+
/// <c><![CDATA[IIdentifiable]]></c> (resource, to-one relationship)
2727
/// </description>
2828
/// </item>
2929
/// <item>
3030
/// <description>
31-
/// <code><![CDATA[null]]></code> (to-one relationship)
31+
/// <c><![CDATA[null]]></c> (to-one relationship)
3232
/// </description>
3333
/// </item>
3434
/// </list>

src/JsonApiDotNetCore/Serialization/Response/IResponseModelAdapter.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,32 @@ public interface IResponseModelAdapter
1212
/// <list type="bullet">
1313
/// <item>
1414
/// <description>
15-
/// <code><![CDATA[IEnumerable<IIdentifiable>]]></code>
15+
/// <c><![CDATA[IEnumerable<IIdentifiable>]]></c>
1616
/// </description>
1717
/// </item>
1818
/// <item>
1919
/// <description>
20-
/// <code><![CDATA[IIdentifiable]]></code>
20+
/// <c><![CDATA[IIdentifiable]]></c>
2121
/// </description>
2222
/// </item>
2323
/// <item>
2424
/// <description>
25-
/// <code><![CDATA[null]]></code>
25+
/// <c><![CDATA[null]]></c>
2626
/// </description>
2727
/// </item>
2828
/// <item>
2929
/// <description>
30-
/// <code><![CDATA[IEnumerable<OperationContainer?>]]></code>
30+
/// <c><![CDATA[IEnumerable<OperationContainer?>]]></c>
3131
/// </description>
3232
/// </item>
3333
/// <item>
3434
/// <description>
35-
/// <code><![CDATA[IEnumerable<ErrorObject>]]></code>
35+
/// <c><![CDATA[IEnumerable<ErrorObject>]]></c>
3636
/// </description>
3737
/// </item>
3838
/// <item>
3939
/// <description>
40-
/// <code><![CDATA[ErrorObject]]></code>
40+
/// <c><![CDATA[ErrorObject]]></c>
4141
/// </description>
4242
/// </item>
4343
/// </list>

src/JsonApiDotNetCore/Serialization/Response/LinkBuilder.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ private string GetLinkForPagination(int pageOffset, string? pageSizeValue)
214214
};
215215

216216
UriComponents components = _options.UseRelativeLinks ? UriComponents.PathAndQuery : UriComponents.AbsoluteUri;
217-
return builder.Uri.GetComponents(components, UriFormat.SafeUnescaped);
217+
return builder.Uri.GetComponents(components, UriFormat.UriEscaped);
218218
}
219219

220220
private string GetQueryStringInPaginationLink(int pageOffset, string? pageSizeValue)

test/JsonApiDotNetCoreTests/IntegrationTests/Blobs/ImageContainer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public sealed class ImageContainer : Identifiable<long>
1212
public string FileName { get; set; } = null!;
1313

1414
[Attr]
15-
public byte[] Data { get; set; } = Array.Empty<byte>();
15+
public byte[] Data { get; set; } = [];
1616

1717
[Attr]
1818
public byte[]? Thumbnail { get; set; }

test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Filtering/FilterOperatorTests.cs

+4
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
8585

8686
responseDocument.Data.ManyValue.ShouldHaveCount(1);
8787
responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someString").With(value => value.Should().Be(resource.SomeString));
88+
89+
responseDocument.Links.ShouldNotBeNull();
90+
responseDocument.Links.Self.Should().Be("http://localhost/filterableResources?filter=equals(someString,'This%2c+that+%26+more+%2b+some')");
91+
responseDocument.Links.First.Should().Be("http://localhost/filterableResources?filter=equals(someString,%27This,%20that%20%26%20more%20%2B%20some%27)");
8892
}
8993

9094
[Fact]

test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/ResourceInheritanceWriteTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1766,7 +1766,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
17661766
});
17671767

17681768
tandemStore.AssertLeftType<Tandem>();
1769-
tandemStore.AssertRightTypes(Array.Empty<Type>());
1769+
tandemStore.AssertRightTypes([]);
17701770
}
17711771

17721772
[Fact]

test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/ResourceTypeCapturingDefinition.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public override Task OnWriteSucceededAsync(TResource resource, WriteOperationKin
8282

8383
private void EnsureSnapshot(TResource leftType, IIdentifiable? rightResourceId = null)
8484
{
85-
IIdentifiable[] rightResourceIds = rightResourceId != null ? [rightResourceId] : Array.Empty<IIdentifiable>();
85+
IIdentifiable[] rightResourceIds = rightResourceId != null ? [rightResourceId] : [];
8686

8787
EnsureSnapshot(leftType, rightResourceIds);
8888
}

0 commit comments

Comments
 (0)