Skip to content

Commit 375a0ed

Browse files
authored
Merge pull request #1186 from json-api-dotnet/merge-master-v503-into-openapi
Merge master (v5.0.3) into openapi branch
2 parents a3fd9bc + 47320f0 commit 375a0ed

File tree

51 files changed

+986
-768
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+986
-768
lines changed

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
]
1010
},
1111
"regitlint": {
12-
"version": "6.0.8",
12+
"version": "6.1.1",
1313
"commands": [
1414
"regitlint"
1515
]

.github/CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ Please follow these steps to have your contribution considered by the maintainer
5858

5959
We use [CSharpGuidelines](https://csharpcodingguidelines.com/) as our coding standard (with a few minor exceptions). Coding style is validated during PR build, where we inject an extra settings layer that promotes various suggestions to warning level. This ensures a high-quality codebase without interfering too much when editing code.
6060
You can run the following [PowerShell scripts](https://github.com/PowerShell/PowerShell/releases) locally:
61-
- `pwsh inspectcode.ps1`: Scans the code for style violations and opens the result in your web browser.
62-
- `pwsh cleanupcode.ps1`: Reformats the entire codebase to match with our configured style.
61+
- `pwsh ./inspectcode.ps1`: Scans the code for style violations and opens the result in your web browser.
62+
- `pwsh ./cleanupcode.ps1 [branch-name-or-commit-hash]`: Reformats the codebase to match with our configured style, optionally only changed files since the specified branch (usually master).
6363

6464
Code inspection violations can be addressed in several ways, depending on the situation:
6565
- Types that are reported to be never instantiated (because the IoC container creates them dynamically) should be decorated with `[UsedImplicitly(ImplicitUseKindFlags.InstantiatedNoFixedConstructorSignature)]`.

Build.ps1

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,21 @@ function RunCleanupCode {
4040
# When running in cibuild for a pull request, this reformats only the files changed in the PR and fails if the reformat produces changes.
4141

4242
if ($env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT) {
43-
Write-Output "Running code cleanup on changed files in pull request"
44-
4543
# In the past, we used $env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT for the merge commit hash. That is the pinned hash at the time the build is enqueued.
4644
# When a force-push happens after that, while the build hasn't yet started, this hash becomes invalid during the build, resulting in a lookup error.
47-
# To prevent failing the build for unobvious reasons we use HEAD, which is always the latest version.
48-
$mergeCommitHash = git rev-parse "HEAD"
49-
$targetCommitHash = git rev-parse "$env:APPVEYOR_REPO_BRANCH"
45+
# To prevent failing the build for unobvious reasons we use HEAD, which is always a detached head (the PR merge result).
46+
47+
$headCommitHash = git rev-parse HEAD
48+
CheckLastExitCode
5049

51-
dotnet regitlint -s JsonApiDotNetCore.sln --print-command --disable-jb-path-hack --jb --profile='\"JADNC Full Cleanup\"' --jb --properties:Configuration=Release --jb --verbosity=WARN -f commits -a $mergeCommitHash -b $targetCommitHash --fail-on-diff --print-diff
50+
$baseCommitHash = git rev-parse "$env:APPVEYOR_REPO_BRANCH"
5251
CheckLastExitCode
52+
53+
if ($baseCommitHash -ne $headCommitHash) {
54+
Write-Output "Running code cleanup on commit range $baseCommitHash..$headCommitHash in pull request."
55+
dotnet regitlint -s JsonApiDotNetCore.sln --print-command --skip-tool-check --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN -f commits -a $headCommitHash -b $baseCommitHash --fail-on-diff --print-diff
56+
CheckLastExitCode
57+
}
5358
}
5459
}
5560

Directory.Build.props

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
<AspNetVersion>6.0.*</AspNetVersion>
55
<EFCoreVersion>6.0.*</EFCoreVersion>
66
<EFCorePostgresVersion>6.0.*</EFCorePostgresVersion>
7-
<MicrosoftCodeAnalysisVersion>4.2.*</MicrosoftCodeAnalysisVersion>
7+
<MicrosoftCodeAnalysisVersion>4.3.*</MicrosoftCodeAnalysisVersion>
88
<HumanizerVersion>2.14.1</HumanizerVersion>
9-
<SwashbuckleVersion>6.2.*</SwashbuckleVersion>
10-
<JsonApiDotNetCoreVersionPrefix>5.0.3</JsonApiDotNetCoreVersionPrefix>
9+
<SwashbuckleVersion>6.4.*</SwashbuckleVersion>
10+
<NSwagApiClientVersion>13.16.*</NSwagApiClientVersion>
11+
<MicrosoftApiClientVersion>6.0.*</MicrosoftApiClientVersion>
12+
<NewtonsoftJsonVersion>13.0.*</NewtonsoftJsonVersion>
13+
<JsonApiDotNetCoreVersionPrefix>5.0.4</JsonApiDotNetCoreVersionPrefix>
1114
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)CodingGuidelines.ruleset</CodeAnalysisRuleSet>
1215
<WarningLevel>9999</WarningLevel>
1316
<Nullable>enable</Nullable>
@@ -18,7 +21,7 @@
1821

1922
<ItemGroup>
2023
<PackageReference Include="JetBrains.Annotations" Version="2022.1.0" PrivateAssets="All" />
21-
<PackageReference Include="CSharpGuidelinesAnalyzer" Version="3.8.1" PrivateAssets="All" />
24+
<PackageReference Include="CSharpGuidelinesAnalyzer" Version="3.8.2" PrivateAssets="All" />
2225
<AdditionalFiles Include="$(MSBuildThisFileDirectory)CSharpGuidelinesAnalyzer.config" Visible="False" />
2326
</ItemGroup>
2427

@@ -35,7 +38,7 @@
3538
<!-- Test Project Dependencies -->
3639
<PropertyGroup>
3740
<CoverletVersion>3.1.2</CoverletVersion>
38-
<MoqVersion>4.18.1</MoqVersion>
39-
<TestSdkVersion>17.2.0</TestSdkVersion>
41+
<MoqVersion>4.18.2</MoqVersion>
42+
<TestSdkVersion>17.3.1</TestSdkVersion>
4043
</PropertyGroup>
4144
</Project>

JsonApiDotNetCore.sln.DotSettings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ JsonApiDotNetCore.ArgumentGuard.NotNull($EXPR$, $NAME$);</s:String>
5757
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceUsingStatementBraces/@EntryIndexedValue">WARNING</s:String>
5858
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceWhileStatementBraces/@EntryIndexedValue">WARNING</s:String>
5959
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EventNeverSubscribedTo_002ELocal/@EntryIndexedValue">WARNING</s:String>
60+
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=LambdaExpressionMustBeStatic/@EntryIndexedValue">WARNING</s:String>
6061
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=LocalizableElement/@EntryIndexedValue">DO_NOT_SHOW</s:String>
6162
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=LoopCanBePartlyConvertedToQuery/@EntryIndexedValue">HINT</s:String>
6263
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MemberCanBeInternal/@EntryIndexedValue">SUGGESTION</s:String>

benchmarks/Benchmarks.csproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
44
<TargetFramework>$(TargetFrameworkName)</TargetFramework>
5+
<ServerGarbageCollection>true</ServerGarbageCollection>
56
</PropertyGroup>
67

78
<ItemGroup>
89
<ProjectReference Include="..\src\JsonApiDotNetCore\JsonApiDotNetCore.csproj" />
910
</ItemGroup>
1011

1112
<ItemGroup>
12-
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
13-
<PackageReference Include="Moq" Version="$(MoqVersion)" />
13+
<PackageReference Include="BenchmarkDotNet" Version="0.13.2" />
14+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="$(MicrosoftCodeAnalysisVersion)" PrivateAssets="all">
15+
<!-- This reference solely exists to prevent build warnings for conflicting versions of Microsoft.CodeAnalysis. -->
16+
</PackageReference>
1417
</ItemGroup>
1518
</Project>

benchmarks/Deserialization/OperationsDeserializationBenchmarks.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Benchmarks.Deserialization;
88

99
[MarkdownExporter]
10+
[MemoryDiagnoser]
1011
// ReSharper disable once ClassCanBeSealed.Global
1112
public class OperationsDeserializationBenchmarks : DeserializationBenchmarkBase
1213
{

benchmarks/Deserialization/ResourceDeserializationBenchmarks.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Benchmarks.Deserialization;
88

99
[MarkdownExporter]
10+
[MemoryDiagnoser]
1011
// ReSharper disable once ClassCanBeSealed.Global
1112
public class ResourceDeserializationBenchmarks : DeserializationBenchmarkBase
1213
{

benchmarks/QueryString/QueryStringParserBenchmarks.cs

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
using System.ComponentModel.Design;
22
using BenchmarkDotNet.Attributes;
3+
using Benchmarks.Tools;
34
using JsonApiDotNetCore;
45
using JsonApiDotNetCore.Configuration;
56
using JsonApiDotNetCore.Middleware;
67
using JsonApiDotNetCore.QueryStrings;
78
using JsonApiDotNetCore.QueryStrings.Internal;
89
using JsonApiDotNetCore.Resources;
9-
using Microsoft.AspNetCore.Http;
10-
using Microsoft.AspNetCore.WebUtilities;
1110
using Microsoft.Extensions.Logging.Abstractions;
1211

1312
namespace Benchmarks.QueryString;
@@ -71,31 +70,9 @@ public void DescendingSort()
7170
[Benchmark]
7271
public void ComplexQuery()
7372
{
74-
Run(100, () =>
75-
{
76-
const string queryString =
77-
"?filter[alt-attr-name]=abc,eq:abc&sort=-alt-attr-name&include=child&page[size]=1&fields[alt-resource-name]=alt-attr-name";
78-
79-
_queryStringAccessor.SetQueryString(queryString);
80-
_queryStringReader.ReadAll(null);
81-
});
82-
}
83-
84-
private void Run(int iterations, Action action)
85-
{
86-
for (int index = 0; index < iterations; index++)
87-
{
88-
action();
89-
}
90-
}
91-
92-
private sealed class FakeRequestQueryStringAccessor : IRequestQueryStringAccessor
93-
{
94-
public IQueryCollection Query { get; private set; } = new QueryCollection();
73+
const string queryString = "?filter[alt-attr-name]=abc,eq:abc&sort=-alt-attr-name&include=child&page[size]=1&fields[alt-resource-name]=alt-attr-name";
9574

96-
public void SetQueryString(string queryString)
97-
{
98-
Query = new QueryCollection(QueryHelpers.ParseQuery(queryString));
99-
}
75+
_queryStringAccessor.SetQueryString(queryString);
76+
_queryStringReader.ReadAll(null);
10077
}
10178
}

benchmarks/Serialization/OperationsSerializationBenchmarks.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace Benchmarks.Serialization;
1010

1111
[MarkdownExporter]
12+
[MemoryDiagnoser]
1213
// ReSharper disable once ClassCanBeSealed.Global
1314
public class OperationsSerializationBenchmarks : SerializationBenchmarkBase
1415
{

0 commit comments

Comments
 (0)