Skip to content

Commit c948a6a

Browse files
author
Bart Koelman
authored
Merge pull request #1105 from json-api-dotnet/master-into-openapi
Update openapi branch
2 parents 6832181 + d50719b commit c948a6a

File tree

930 files changed

+22759
-16788
lines changed

Some content is hidden

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

930 files changed

+22759
-16788
lines changed

.config/dotnet-tools.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
"isRoot": true,
44
"tools": {
55
"jetbrains.resharper.globaltools": {
6-
"version": "2021.1.4",
6+
"version": "2021.2.2",
77
"commands": [
88
"jb"
99
]
1010
},
1111
"regitlint": {
12-
"version": "2.1.4",
12+
"version": "6.0.6",
1313
"commands": [
1414
"regitlint"
1515
]

Build.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function CheckLastExitCode {
88

99
function RunInspectCode {
1010
$outputPath = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), 'jetbrains-inspectcode-results.xml')
11-
dotnet jb inspectcode JsonApiDotNetCore.sln --output="$outputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=SolutionPersonal -dsl=ProjectPersonal
11+
dotnet jb inspectcode JsonApiDotNetCore.sln --no-build --output="$outputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=GlobalPerProduct -dsl=SolutionPersonal -dsl=ProjectPersonal
1212
CheckLastExitCode
1313

1414
[xml]$xml = Get-Content "$outputPath"
@@ -47,7 +47,7 @@ function RunCleanupCode {
4747
$mergeCommitHash = git rev-parse "HEAD"
4848
$targetCommitHash = git rev-parse "$env:APPVEYOR_REPO_BRANCH"
4949

50-
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
50+
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
5151
CheckLastExitCode
5252
}
5353
}
@@ -73,10 +73,10 @@ function CreateNuGetPackage {
7373
$versionSuffix = $suffixSegments -join "-"
7474
}
7575
else {
76-
# Get the version suffix from the auto-incrementing build number. Example: "123" => "pre-0123".
76+
# Get the version suffix from the auto-incrementing build number. Example: "123" => "master-0123".
7777
if ($env:APPVEYOR_BUILD_NUMBER) {
7878
$revision = "{0:D4}" -f [convert]::ToInt32($env:APPVEYOR_BUILD_NUMBER, 10)
79-
$versionSuffix = "pre-$revision"
79+
$versionSuffix = "$($env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH ?? $env:APPVEYOR_REPO_BRANCH)-$revision"
8080
}
8181
else {
8282
$versionSuffix = "pre-0001"

CSharpGuidelinesAnalyzer.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<cSharpGuidelinesAnalyzerSettings>
33
<setting rule="AV1561" name="MaxParameterCount" value="6" />
4-
<setting rule="AV1561" name="MaxConstructorParameterCount" value="12" />
4+
<setting rule="AV1561" name="MaxConstructorParameterCount" value="13" />
55
</cSharpGuidelinesAnalyzerSettings>

Directory.Build.props

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
<EFCoreVersion>5.0.*</EFCoreVersion>
66
<NpgsqlPostgreSQLVersion>5.0.*</NpgsqlPostgreSQLVersion>
77
<SwashbuckleVersion>6.2.*</SwashbuckleVersion>
8-
<JsonApiDotNetCoreVersionPrefix>4.2.0</JsonApiDotNetCoreVersionPrefix>
8+
<JsonApiDotNetCoreVersionPrefix>5.0.0</JsonApiDotNetCoreVersionPrefix>
99
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)CodingGuidelines.ruleset</CodeAnalysisRuleSet>
1010
<WarningLevel>9999</WarningLevel>
11+
<Nullable>enable</Nullable>
1112
</PropertyGroup>
1213

1314
<ItemGroup>
14-
<PackageReference Include="JetBrains.Annotations" Version="2021.1.0" PrivateAssets="All" />
15+
<PackageReference Include="JetBrains.Annotations" Version="2021.3.0" PrivateAssets="All" />
1516
<PackageReference Include="CSharpGuidelinesAnalyzer" Version="3.7.0" PrivateAssets="All" />
1617
<AdditionalFiles Include="$(MSBuildThisFileDirectory)CSharpGuidelinesAnalyzer.config" Visible="False" />
1718
</ItemGroup>
@@ -26,9 +27,9 @@
2627
<PropertyGroup>
2728
<BogusVersion>33.1.1</BogusVersion>
2829
<CoverletVersion>3.1.0</CoverletVersion>
29-
<FluentAssertionsVersion>6.1.0</FluentAssertionsVersion>
30+
<FluentAssertionsVersion>6.2.0</FluentAssertionsVersion>
3031
<MoqVersion>4.16.1</MoqVersion>
3132
<XUnitVersion>2.4.*</XUnitVersion>
32-
<TestSdkVersion>16.11.0</TestSdkVersion>
33+
<TestSdkVersion>17.0.0</TestSdkVersion>
3334
</PropertyGroup>
3435
</Project>

README.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,23 @@ See [our documentation](https://www.jsonapi.net/) for detailed usage.
4343
### Models
4444

4545
```c#
46-
public class Article : Identifiable
46+
#nullable enable
47+
48+
public class Article : Identifiable<int>
4749
{
4850
[Attr]
49-
public string Name { get; set; }
51+
public string Name { get; set; } = null!;
5052
}
5153
```
5254

5355
### Controllers
5456

5557
```c#
56-
public class ArticlesController : JsonApiController<Article>
58+
public class ArticlesController : JsonApiController<Article, int>
5759
{
58-
public ArticlesController(IJsonApiOptions options, ILoggerFactory loggerFactory,
59-
IResourceService<Article> resourceService,)
60-
: base(options, loggerFactory, resourceService)
60+
public ArticlesController(IJsonApiOptions options, IResourceGraph resourceGraph,
61+
ILoggerFactory loggerFactory, IResourceService<Article, int> resourceService)
62+
: base(options, resourceGraph, loggerFactory, resourceService)
6163
{
6264
}
6365
}
@@ -87,13 +89,16 @@ public class Startup
8789
The following chart should help you pick the best version, based on your environment.
8890
See also our [versioning policy](./VERSIONING_POLICY.md).
8991

90-
| .NET version | EF Core version | JsonApiDotNetCore version |
91-
| ------------ | --------------- | ------------------------- |
92-
| Core 2.x | 2.x | 3.x |
93-
| Core 3.1 | 3.1 | 4.x |
94-
| Core 3.1 | 5 | 4.x |
95-
| 5 | 5 | 4.x or 5.x |
96-
| 6 | 6 | 5.x |
92+
| JsonApiDotNetCore | .NET | Entity Framework Core | Status |
93+
| ----------------- | -------- | --------------------- | -------------------------- |
94+
| 3.x | Core 2.x | 2.x | Released |
95+
| 4.x | Core 3.1 | 3.1 | Released |
96+
| | Core 3.1 | 5 | |
97+
| | 5 | 5 | |
98+
| | 6 | 5 | |
99+
| v5.x (pending) | 5 | 5 | On AppVeyor, to-be-dropped |
100+
| | 6 | 5 | On AppVeyor, to-be-dropped |
101+
| | 6 | 6 | Requires build from master |
97102

98103
## Contributing
99104

ROADMAP.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,22 @@ We've completed active development on v4.x, but we'll still fix important bugs o
1313
The need for breaking changes has blocked several efforts in the v4.x release, so now that we're starting work on v5, we're going to catch up.
1414

1515
- [x] Remove Resource Hooks [#1025](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1025)
16-
- [x] Update to .NET/EFCORE 5 [#1026](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1026)
16+
- [x] Update to .NET 5 with EF Core 5 [#1026](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1026)
1717
- [x] Native many-to-many [#935](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/935)
1818
- [x] Refactorings [#1027](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1027) [#944](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/944)
1919
- [x] Tweak trace logging [#1033](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1033)
2020
- [x] Instrumentation [#1032](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1032)
2121
- [x] Optimized delete to-many [#1030](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1030)
2222
- [x] Support System.Text.Json [#664](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/664) [#999](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/999) [1077](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1077) [1078](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1078)
23-
- [ ] Optimize IIdentifiable to ResourceObject conversion [#1028](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1028) [#1024](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1024) [#233](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/233)
24-
- [ ] Nullable reference types [#1029](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1029)
23+
- [x] Optimize IIdentifiable to ResourceObject conversion [#1028](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1028) [#1024](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1024) [#233](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/233)
24+
- [x] Nullable reference types [#1029](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1029)
25+
- [x] Improved paging links [#1010](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1010)
26+
- [x] Configuration validation [#170](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/170)
27+
- [ ] Support .NET 6 with EF Core 6 [#1109](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1109)
2528

2629
Aside from the list above, we have interest in the following topics. It's too soon yet to decide whether they'll make it into v5.x or in a later major version.
2730

28-
- Improved paging links [#1010](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1010)
2931
- Auto-generated controllers [#732](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/732) [#365](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/365)
30-
- Configuration validation [#170](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/170)
3132
- Optimistic concurrency [#1004](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1004)
3233
- Extract annotations into separate package [#730](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/730)
3334
- OpenAPI (Swagger) [#1046](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1046)

appveyor.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
image:
22
- Ubuntu
3-
- Visual Studio 2019
3+
- Visual Studio 2022
44

55
version: '{build}'
66

@@ -33,7 +33,7 @@ for:
3333
-
3434
matrix:
3535
only:
36-
- image: Visual Studio 2019
36+
- image: Visual Studio 2022
3737
services:
3838
- postgresql13
3939
# REF: https://github.com/docascode/docfx-seed/blob/master/appveyor.yml
@@ -44,6 +44,9 @@ for:
4444
git checkout $env:APPVEYOR_REPO_BRANCH -q
4545
}
4646
choco install docfx -y
47+
if ($lastexitcode -ne 0) {
48+
throw "docfx install failed with exit code $lastexitcode."
49+
}
4750
after_build:
4851
- pwsh: |
4952
CD ./docs

benchmarks/BenchmarkResource.cs

Lines changed: 0 additions & 16 deletions
This file was deleted.

benchmarks/BenchmarkResourcePublicNames.cs

Lines changed: 0 additions & 10 deletions
This file was deleted.

benchmarks/Benchmarks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</ItemGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="BenchmarkDotNet" Version="0.13.0" />
12+
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
1313
<PackageReference Include="Moq" Version="$(MoqVersion)" />
1414
</ItemGroup>
1515
</Project>

benchmarks/DependencyFactory.cs

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel.Design;
4+
using System.Text.Json;
5+
using JetBrains.Annotations;
6+
using JsonApiDotNetCore.Configuration;
7+
using JsonApiDotNetCore.Middleware;
8+
using JsonApiDotNetCore.Resources;
9+
using JsonApiDotNetCore.Resources.Annotations;
10+
using JsonApiDotNetCore.Serialization.JsonConverters;
11+
using JsonApiDotNetCore.Serialization.Request.Adapters;
12+
using Microsoft.Extensions.Logging.Abstractions;
13+
14+
namespace Benchmarks.Deserialization
15+
{
16+
public abstract class DeserializationBenchmarkBase
17+
{
18+
protected readonly JsonSerializerOptions SerializerReadOptions;
19+
protected readonly DocumentAdapter DocumentAdapter;
20+
21+
protected DeserializationBenchmarkBase()
22+
{
23+
var options = new JsonApiOptions();
24+
IResourceGraph resourceGraph = new ResourceGraphBuilder(options, NullLoggerFactory.Instance).Add<IncomingResource, int>().Build();
25+
options.SerializerOptions.Converters.Add(new ResourceObjectConverter(resourceGraph));
26+
SerializerReadOptions = ((IJsonApiOptions)options).SerializerReadOptions;
27+
28+
var serviceContainer = new ServiceContainer();
29+
var resourceFactory = new ResourceFactory(serviceContainer);
30+
var resourceDefinitionAccessor = new ResourceDefinitionAccessor(resourceGraph, serviceContainer);
31+
32+
serviceContainer.AddService(typeof(IResourceDefinitionAccessor), resourceDefinitionAccessor);
33+
34+
serviceContainer.AddService(typeof(IResourceDefinition<IncomingResource, int>),
35+
new JsonApiResourceDefinition<IncomingResource, int>(resourceGraph));
36+
37+
// ReSharper disable once VirtualMemberCallInConstructor
38+
JsonApiRequest request = CreateJsonApiRequest(resourceGraph);
39+
var targetedFields = new TargetedFields();
40+
41+
var resourceIdentifierObjectAdapter = new ResourceIdentifierObjectAdapter(resourceGraph, resourceFactory);
42+
var relationshipDataAdapter = new RelationshipDataAdapter(resourceIdentifierObjectAdapter);
43+
var resourceObjectAdapter = new ResourceObjectAdapter(resourceGraph, resourceFactory, options, relationshipDataAdapter);
44+
var resourceDataAdapter = new ResourceDataAdapter(resourceDefinitionAccessor, resourceObjectAdapter);
45+
46+
var atomicReferenceAdapter = new AtomicReferenceAdapter(resourceGraph, resourceFactory);
47+
var atomicOperationResourceDataAdapter = new ResourceDataInOperationsRequestAdapter(resourceDefinitionAccessor, resourceObjectAdapter);
48+
49+
var atomicOperationObjectAdapter = new AtomicOperationObjectAdapter(options, atomicReferenceAdapter,
50+
atomicOperationResourceDataAdapter, relationshipDataAdapter);
51+
52+
var resourceDocumentAdapter = new DocumentInResourceOrRelationshipRequestAdapter(options, resourceDataAdapter, relationshipDataAdapter);
53+
var operationsDocumentAdapter = new DocumentInOperationsRequestAdapter(options, atomicOperationObjectAdapter);
54+
55+
DocumentAdapter = new DocumentAdapter(request, targetedFields, resourceDocumentAdapter, operationsDocumentAdapter);
56+
}
57+
58+
protected abstract JsonApiRequest CreateJsonApiRequest(IResourceGraph resourceGraph);
59+
60+
[UsedImplicitly(ImplicitUseTargetFlags.Members)]
61+
public sealed class IncomingResource : Identifiable<int>
62+
{
63+
[Attr]
64+
public bool Attribute01 { get; set; }
65+
66+
[Attr]
67+
public char Attribute02 { get; set; }
68+
69+
[Attr]
70+
public ulong? Attribute03 { get; set; }
71+
72+
[Attr]
73+
public decimal Attribute04 { get; set; }
74+
75+
[Attr]
76+
public float? Attribute05 { get; set; }
77+
78+
[Attr]
79+
public string Attribute06 { get; set; } = null!;
80+
81+
[Attr]
82+
public DateTime? Attribute07 { get; set; }
83+
84+
[Attr]
85+
public DateTimeOffset? Attribute08 { get; set; }
86+
87+
[Attr]
88+
public TimeSpan? Attribute09 { get; set; }
89+
90+
[Attr]
91+
public DayOfWeek Attribute10 { get; set; }
92+
93+
[HasOne]
94+
public IncomingResource Single1 { get; set; } = null!;
95+
96+
[HasOne]
97+
public IncomingResource Single2 { get; set; } = null!;
98+
99+
[HasOne]
100+
public IncomingResource Single3 { get; set; } = null!;
101+
102+
[HasOne]
103+
public IncomingResource Single4 { get; set; } = null!;
104+
105+
[HasOne]
106+
public IncomingResource Single5 { get; set; } = null!;
107+
108+
[HasMany]
109+
public ISet<IncomingResource> Multi1 { get; set; } = null!;
110+
111+
[HasMany]
112+
public ISet<IncomingResource> Multi2 { get; set; } = null!;
113+
114+
[HasMany]
115+
public ISet<IncomingResource> Multi3 { get; set; } = null!;
116+
117+
[HasMany]
118+
public ISet<IncomingResource> Multi4 { get; set; } = null!;
119+
120+
[HasMany]
121+
public ISet<IncomingResource> Multi5 { get; set; } = null!;
122+
}
123+
}
124+
}

0 commit comments

Comments
 (0)