Skip to content

Commit

Permalink
Merge pull request #1105 from json-api-dotnet/master-into-openapi
Browse files Browse the repository at this point in the history
Update openapi branch
  • Loading branch information
Bart Koelman authored Nov 23, 2021
2 parents 6832181 + d50719b commit c948a6a
Show file tree
Hide file tree
Showing 930 changed files with 22,759 additions and 16,788 deletions.
4 changes: 2 additions & 2 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"isRoot": true,
"tools": {
"jetbrains.resharper.globaltools": {
"version": "2021.1.4",
"version": "2021.2.2",
"commands": [
"jb"
]
},
"regitlint": {
"version": "2.1.4",
"version": "6.0.6",
"commands": [
"regitlint"
]
Expand Down
8 changes: 4 additions & 4 deletions Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function CheckLastExitCode {

function RunInspectCode {
$outputPath = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), 'jetbrains-inspectcode-results.xml')
dotnet jb inspectcode JsonApiDotNetCore.sln --output="$outputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=SolutionPersonal -dsl=ProjectPersonal
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
CheckLastExitCode

[xml]$xml = Get-Content "$outputPath"
Expand Down Expand Up @@ -47,7 +47,7 @@ function RunCleanupCode {
$mergeCommitHash = git rev-parse "HEAD"
$targetCommitHash = git rev-parse "$env:APPVEYOR_REPO_BRANCH"

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
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
CheckLastExitCode
}
}
Expand All @@ -73,10 +73,10 @@ function CreateNuGetPackage {
$versionSuffix = $suffixSegments -join "-"
}
else {
# Get the version suffix from the auto-incrementing build number. Example: "123" => "pre-0123".
# Get the version suffix from the auto-incrementing build number. Example: "123" => "master-0123".
if ($env:APPVEYOR_BUILD_NUMBER) {
$revision = "{0:D4}" -f [convert]::ToInt32($env:APPVEYOR_BUILD_NUMBER, 10)
$versionSuffix = "pre-$revision"
$versionSuffix = "$($env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH ?? $env:APPVEYOR_REPO_BRANCH)-$revision"
}
else {
$versionSuffix = "pre-0001"
Expand Down
2 changes: 1 addition & 1 deletion CSharpGuidelinesAnalyzer.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<cSharpGuidelinesAnalyzerSettings>
<setting rule="AV1561" name="MaxParameterCount" value="6" />
<setting rule="AV1561" name="MaxConstructorParameterCount" value="12" />
<setting rule="AV1561" name="MaxConstructorParameterCount" value="13" />
</cSharpGuidelinesAnalyzerSettings>
9 changes: 5 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
<EFCoreVersion>5.0.*</EFCoreVersion>
<NpgsqlPostgreSQLVersion>5.0.*</NpgsqlPostgreSQLVersion>
<SwashbuckleVersion>6.2.*</SwashbuckleVersion>
<JsonApiDotNetCoreVersionPrefix>4.2.0</JsonApiDotNetCoreVersionPrefix>
<JsonApiDotNetCoreVersionPrefix>5.0.0</JsonApiDotNetCoreVersionPrefix>
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)CodingGuidelines.ruleset</CodeAnalysisRuleSet>
<WarningLevel>9999</WarningLevel>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2021.1.0" PrivateAssets="All" />
<PackageReference Include="JetBrains.Annotations" Version="2021.3.0" PrivateAssets="All" />
<PackageReference Include="CSharpGuidelinesAnalyzer" Version="3.7.0" PrivateAssets="All" />
<AdditionalFiles Include="$(MSBuildThisFileDirectory)CSharpGuidelinesAnalyzer.config" Visible="False" />
</ItemGroup>
Expand All @@ -26,9 +27,9 @@
<PropertyGroup>
<BogusVersion>33.1.1</BogusVersion>
<CoverletVersion>3.1.0</CoverletVersion>
<FluentAssertionsVersion>6.1.0</FluentAssertionsVersion>
<FluentAssertionsVersion>6.2.0</FluentAssertionsVersion>
<MoqVersion>4.16.1</MoqVersion>
<XUnitVersion>2.4.*</XUnitVersion>
<TestSdkVersion>16.11.0</TestSdkVersion>
<TestSdkVersion>17.0.0</TestSdkVersion>
</PropertyGroup>
</Project>
31 changes: 18 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,23 @@ See [our documentation](https://www.jsonapi.net/) for detailed usage.
### Models

```c#
public class Article : Identifiable
#nullable enable

public class Article : Identifiable<int>
{
[Attr]
public string Name { get; set; }
public string Name { get; set; } = null!;
}
```

### Controllers

```c#
public class ArticlesController : JsonApiController<Article>
public class ArticlesController : JsonApiController<Article, int>
{
public ArticlesController(IJsonApiOptions options, ILoggerFactory loggerFactory,
IResourceService<Article> resourceService,)
: base(options, loggerFactory, resourceService)
public ArticlesController(IJsonApiOptions options, IResourceGraph resourceGraph,
ILoggerFactory loggerFactory, IResourceService<Article, int> resourceService)
: base(options, resourceGraph, loggerFactory, resourceService)
{
}
}
Expand Down Expand Up @@ -87,13 +89,16 @@ public class Startup
The following chart should help you pick the best version, based on your environment.
See also our [versioning policy](./VERSIONING_POLICY.md).

| .NET version | EF Core version | JsonApiDotNetCore version |
| ------------ | --------------- | ------------------------- |
| Core 2.x | 2.x | 3.x |
| Core 3.1 | 3.1 | 4.x |
| Core 3.1 | 5 | 4.x |
| 5 | 5 | 4.x or 5.x |
| 6 | 6 | 5.x |
| JsonApiDotNetCore | .NET | Entity Framework Core | Status |
| ----------------- | -------- | --------------------- | -------------------------- |
| 3.x | Core 2.x | 2.x | Released |
| 4.x | Core 3.1 | 3.1 | Released |
| | Core 3.1 | 5 | |
| | 5 | 5 | |
| | 6 | 5 | |
| v5.x (pending) | 5 | 5 | On AppVeyor, to-be-dropped |
| | 6 | 5 | On AppVeyor, to-be-dropped |
| | 6 | 6 | Requires build from master |

## Contributing

Expand Down
11 changes: 6 additions & 5 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,22 @@ We've completed active development on v4.x, but we'll still fix important bugs o
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.

- [x] Remove Resource Hooks [#1025](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1025)
- [x] Update to .NET/EFCORE 5 [#1026](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1026)
- [x] Update to .NET 5 with EF Core 5 [#1026](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1026)
- [x] Native many-to-many [#935](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/935)
- [x] Refactorings [#1027](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1027) [#944](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/944)
- [x] Tweak trace logging [#1033](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1033)
- [x] Instrumentation [#1032](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1032)
- [x] Optimized delete to-many [#1030](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1030)
- [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)
- [ ] 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)
- [ ] Nullable reference types [#1029](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1029)
- [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)
- [x] Nullable reference types [#1029](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1029)
- [x] Improved paging links [#1010](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1010)
- [x] Configuration validation [#170](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/170)
- [ ] Support .NET 6 with EF Core 6 [#1109](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1109)

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.

- Improved paging links [#1010](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1010)
- Auto-generated controllers [#732](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/732) [#365](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/365)
- Configuration validation [#170](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/170)
- Optimistic concurrency [#1004](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1004)
- Extract annotations into separate package [#730](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/730)
- OpenAPI (Swagger) [#1046](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1046)
Expand Down
7 changes: 5 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
image:
- Ubuntu
- Visual Studio 2019
- Visual Studio 2022

version: '{build}'

Expand Down Expand Up @@ -33,7 +33,7 @@ for:
-
matrix:
only:
- image: Visual Studio 2019
- image: Visual Studio 2022
services:
- postgresql13
# REF: https://github.com/docascode/docfx-seed/blob/master/appveyor.yml
Expand All @@ -44,6 +44,9 @@ for:
git checkout $env:APPVEYOR_REPO_BRANCH -q
}
choco install docfx -y
if ($lastexitcode -ne 0) {
throw "docfx install failed with exit code $lastexitcode."
}
after_build:
- pwsh: |
CD ./docs
Expand Down
16 changes: 0 additions & 16 deletions benchmarks/BenchmarkResource.cs

This file was deleted.

10 changes: 0 additions & 10 deletions benchmarks/BenchmarkResourcePublicNames.cs

This file was deleted.

2 changes: 1 addition & 1 deletion benchmarks/Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.0" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
<PackageReference Include="Moq" Version="$(MoqVersion)" />
</ItemGroup>
</Project>
18 changes: 0 additions & 18 deletions benchmarks/DependencyFactory.cs

This file was deleted.

124 changes: 124 additions & 0 deletions benchmarks/Deserialization/DeserializationBenchmarkBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Text.Json;
using JetBrains.Annotations;
using JsonApiDotNetCore.Configuration;
using JsonApiDotNetCore.Middleware;
using JsonApiDotNetCore.Resources;
using JsonApiDotNetCore.Resources.Annotations;
using JsonApiDotNetCore.Serialization.JsonConverters;
using JsonApiDotNetCore.Serialization.Request.Adapters;
using Microsoft.Extensions.Logging.Abstractions;

namespace Benchmarks.Deserialization
{
public abstract class DeserializationBenchmarkBase
{
protected readonly JsonSerializerOptions SerializerReadOptions;
protected readonly DocumentAdapter DocumentAdapter;

protected DeserializationBenchmarkBase()
{
var options = new JsonApiOptions();
IResourceGraph resourceGraph = new ResourceGraphBuilder(options, NullLoggerFactory.Instance).Add<IncomingResource, int>().Build();
options.SerializerOptions.Converters.Add(new ResourceObjectConverter(resourceGraph));
SerializerReadOptions = ((IJsonApiOptions)options).SerializerReadOptions;

var serviceContainer = new ServiceContainer();
var resourceFactory = new ResourceFactory(serviceContainer);
var resourceDefinitionAccessor = new ResourceDefinitionAccessor(resourceGraph, serviceContainer);

serviceContainer.AddService(typeof(IResourceDefinitionAccessor), resourceDefinitionAccessor);

serviceContainer.AddService(typeof(IResourceDefinition<IncomingResource, int>),
new JsonApiResourceDefinition<IncomingResource, int>(resourceGraph));

// ReSharper disable once VirtualMemberCallInConstructor
JsonApiRequest request = CreateJsonApiRequest(resourceGraph);
var targetedFields = new TargetedFields();

var resourceIdentifierObjectAdapter = new ResourceIdentifierObjectAdapter(resourceGraph, resourceFactory);
var relationshipDataAdapter = new RelationshipDataAdapter(resourceIdentifierObjectAdapter);
var resourceObjectAdapter = new ResourceObjectAdapter(resourceGraph, resourceFactory, options, relationshipDataAdapter);
var resourceDataAdapter = new ResourceDataAdapter(resourceDefinitionAccessor, resourceObjectAdapter);

var atomicReferenceAdapter = new AtomicReferenceAdapter(resourceGraph, resourceFactory);
var atomicOperationResourceDataAdapter = new ResourceDataInOperationsRequestAdapter(resourceDefinitionAccessor, resourceObjectAdapter);

var atomicOperationObjectAdapter = new AtomicOperationObjectAdapter(options, atomicReferenceAdapter,
atomicOperationResourceDataAdapter, relationshipDataAdapter);

var resourceDocumentAdapter = new DocumentInResourceOrRelationshipRequestAdapter(options, resourceDataAdapter, relationshipDataAdapter);
var operationsDocumentAdapter = new DocumentInOperationsRequestAdapter(options, atomicOperationObjectAdapter);

DocumentAdapter = new DocumentAdapter(request, targetedFields, resourceDocumentAdapter, operationsDocumentAdapter);
}

protected abstract JsonApiRequest CreateJsonApiRequest(IResourceGraph resourceGraph);

[UsedImplicitly(ImplicitUseTargetFlags.Members)]
public sealed class IncomingResource : Identifiable<int>
{
[Attr]
public bool Attribute01 { get; set; }

[Attr]
public char Attribute02 { get; set; }

[Attr]
public ulong? Attribute03 { get; set; }

[Attr]
public decimal Attribute04 { get; set; }

[Attr]
public float? Attribute05 { get; set; }

[Attr]
public string Attribute06 { get; set; } = null!;

[Attr]
public DateTime? Attribute07 { get; set; }

[Attr]
public DateTimeOffset? Attribute08 { get; set; }

[Attr]
public TimeSpan? Attribute09 { get; set; }

[Attr]
public DayOfWeek Attribute10 { get; set; }

[HasOne]
public IncomingResource Single1 { get; set; } = null!;

[HasOne]
public IncomingResource Single2 { get; set; } = null!;

[HasOne]
public IncomingResource Single3 { get; set; } = null!;

[HasOne]
public IncomingResource Single4 { get; set; } = null!;

[HasOne]
public IncomingResource Single5 { get; set; } = null!;

[HasMany]
public ISet<IncomingResource> Multi1 { get; set; } = null!;

[HasMany]
public ISet<IncomingResource> Multi2 { get; set; } = null!;

[HasMany]
public ISet<IncomingResource> Multi3 { get; set; } = null!;

[HasMany]
public ISet<IncomingResource> Multi4 { get; set; } = null!;

[HasMany]
public ISet<IncomingResource> Multi5 { get; set; } = null!;
}
}
}
Loading

0 comments on commit c948a6a

Please sign in to comment.