Skip to content

Commit 949b5b0

Browse files
committed
Sync up with changes in JsonApiDotNetCore since v5.5.0
1 parent 3f6f926 commit 949b5b0

File tree

25 files changed

+129
-119
lines changed

25 files changed

+129
-119
lines changed

Diff for: .github/workflows/build.yml

+2-32
Original file line numberDiff line numberDiff line change
@@ -43,36 +43,6 @@ jobs:
4343
dotnet-version: |
4444
6.0.x
4545
8.0.x
46-
- name: Setup PowerShell (Ubuntu)
47-
if: matrix.os == 'ubuntu-latest'
48-
run: |
49-
dotnet tool install --global PowerShell
50-
- name: Find latest PowerShell version (Windows)
51-
if: matrix.os == 'windows-latest'
52-
shell: pwsh
53-
run: |
54-
$packageName = "powershell"
55-
$outputText = dotnet tool search $packageName --take 1
56-
$outputLine = ("" + $outputText)
57-
$indexOfVersionLine = $outputLine.IndexOf($packageName)
58-
$latestVersion = $outputLine.substring($indexOfVersionLine + $packageName.length).trim().split(" ")[0].trim()
59-
60-
Write-Output "Found PowerShell version: $latestVersion"
61-
Write-Output "POWERSHELL_LATEST_VERSION=$latestVersion" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
62-
- name: Setup PowerShell (Windows)
63-
if: matrix.os == 'windows-latest'
64-
shell: cmd
65-
run: |
66-
set DOWNLOAD_LINK=https://github.com/PowerShell/PowerShell/releases/download/v%POWERSHELL_LATEST_VERSION%/PowerShell-%POWERSHELL_LATEST_VERSION%-win-x64.msi
67-
set OUTPUT_PATH=%RUNNER_TEMP%\PowerShell-%POWERSHELL_LATEST_VERSION%-win-x64.msi
68-
echo Downloading from: %DOWNLOAD_LINK% to: %OUTPUT_PATH%
69-
curl --location --output %OUTPUT_PATH% %DOWNLOAD_LINK%
70-
msiexec.exe /package %OUTPUT_PATH% /quiet USE_MU=1 ENABLE_MU=1 ADD_PATH=1 DISABLE_TELEMETRY=1
71-
- name: Setup PowerShell (macOS)
72-
if: matrix.os == 'macos-latest'
73-
run: |
74-
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
75-
brew install --cask powershell
7646
- name: Show installed versions
7747
shell: pwsh
7848
run: |
@@ -235,13 +205,13 @@ jobs:
235205
$baseCommitHash = git rev-parse HEAD~1
236206
237207
Write-Output "Running code cleanup on commit range $baseCommitHash..$headCommitHash in pull request."
238-
dotnet regitlint -s JsonApiDotNetCore.MongoDb.sln --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN -f commits -a $headCommitHash -b $baseCommitHash --fail-on-diff --print-diff
208+
dotnet regitlint -s JsonApiDotNetCore.MongoDb.sln --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --verbosity=WARN -f commits -a $headCommitHash -b $baseCommitHash --fail-on-diff --print-diff
239209
- name: CleanupCode (on branch)
240210
if: github.event_name == 'push' || github.event_name == 'release'
241211
shell: pwsh
242212
run: |
243213
Write-Output "Running code cleanup on all files."
244-
dotnet regitlint -s JsonApiDotNetCore.MongoDb.sln --print-command --skip-tool-check --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN --fail-on-diff --print-diff
214+
dotnet regitlint -s JsonApiDotNetCore.MongoDb.sln --print-command --skip-tool-check --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --verbosity=WARN --fail-on-diff --print-diff
245215
246216
publish:
247217
timeout-minutes: 60

Diff for: Directory.Build.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@
2727
<WarnOnPackingNonPackableProject>false</WarnOnPackingNonPackableProject>
2828
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)CodingGuidelines.ruleset</CodeAnalysisRuleSet>
2929
<RunSettingsFilePath>$(MSBuildThisFileDirectory)tests.runsettings</RunSettingsFilePath>
30-
<JsonApiDotNetCoreMongoDbVersionPrefix>5.5.1</JsonApiDotNetCoreMongoDbVersionPrefix>
30+
<JsonApiDotNetCoreMongoDbVersionPrefix>5.6.0</JsonApiDotNetCoreMongoDbVersionPrefix>
3131
</PropertyGroup>
3232
</Project>

Diff for: JsonApiDotNetCore.MongoDb.sln

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
2323
ProjectSection(SolutionItems) = preProject
2424
.editorconfig = .editorconfig
2525
.gitignore = .gitignore
26+
.github\workflows\build.yml = .github\workflows\build.yml
2627
CodingGuidelines.ruleset = CodingGuidelines.ruleset
2728
CSharpGuidelinesAnalyzer.config = CSharpGuidelinesAnalyzer.config
2829
Directory.Build.props = Directory.Build.props
29-
tests.runsettings = tests.runsettings
3030
package-versions.props = package-versions.props
31+
tests.runsettings = tests.runsettings
3132
EndProjectSection
3233
EndProject
3334
Global

Diff for: WarningSeverities.DotSettings

+3-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertToConstant_002ELocal/@EntryIndexedValue">WARNING</s:String>
7070
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertToLambdaExpression/@EntryIndexedValue">WARNING</s:String>
7171
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertToNullCoalescingCompoundAssignment/@EntryIndexedValue">WARNING</s:String>
72+
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertToPrimaryConstructor/@EntryIndexedValue">WARNING</s:String>
7273
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertToStaticClass/@EntryIndexedValue">WARNING</s:String>
7374
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertToUsingDeclaration/@EntryIndexedValue">WARNING</s:String>
7475
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=DoubleNegationInPattern/@EntryIndexedValue">WARNING</s:String>
@@ -122,6 +123,7 @@
122123
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=NestedStringInterpolation/@EntryIndexedValue">WARNING</s:String>
123124
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=NotAccessedField_002EGlobal/@EntryIndexedValue">WARNING</s:String>
124125
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=OutdentIsOffPrevLevel/@EntryIndexedValue">WARNING</s:String>
126+
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PropertyCanBeMadeInitOnly_002EGlobal/@EntryIndexedValue">WARNING</s:String>
125127
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PropertyCanBeMadeInitOnly_002ELocal/@EntryIndexedValue">WARNING</s:String>
126128
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PublicConstructorInAbstractClass/@EntryIndexedValue">WARNING</s:String>
127129
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RawStringCanBeSimplified/@EntryIndexedValue">WARNING</s:String>
@@ -164,7 +166,6 @@
164166
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RemoveRedundantOrStatement_002ETrue/@EntryIndexedValue">WARNING</s:String>
165167
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RemoveToList_002E1/@EntryIndexedValue">WARNING</s:String>
166168
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RemoveToList_002E2/@EntryIndexedValue">WARNING</s:String>
167-
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ReplaceAsyncWithTaskReturn/@EntryIndexedValue">WARNING</s:String>
168169
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ReplaceObjectPatternWithVarPattern/@EntryIndexedValue">WARNING</s:String>
169170
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ReplaceSequenceEqualWithConstantPattern/@EntryIndexedValue">WARNING</s:String>
170171
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ReplaceWithFirstOrDefault_002E1/@EntryIndexedValue">WARNING</s:String>
@@ -196,6 +197,7 @@
196197
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ReplaceWithOfType_002ESingleOrDefault_002E1/@EntryIndexedValue">WARNING</s:String>
197198
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ReplaceWithOfType_002ESingleOrDefault_002E2/@EntryIndexedValue">WARNING</s:String>
198199
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ReplaceWithOfType_002EWhere/@EntryIndexedValue">WARNING</s:String>
200+
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ReplaceWithPrimaryConstructorParameter/@EntryIndexedValue">WARNING</s:String>
199201
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ReplaceWithSimpleAssignment_002EFalse/@EntryIndexedValue">WARNING</s:String>
200202
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ReplaceWithSimpleAssignment_002ETrue/@EntryIndexedValue">WARNING</s:String>
201203
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ReplaceWithSingleAssignment_002EFalse/@EntryIndexedValue">WARNING</s:String>

Diff for: cleanupcode.ps1

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ if ($revision) {
2828

2929
if ($baseCommitHash -eq $headCommitHash) {
3030
Write-Output "Running code cleanup on staged/unstaged files."
31-
dotnet regitlint -s JsonApiDotNetCore.MongoDb.sln --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN -f staged,modified
31+
dotnet regitlint -s JsonApiDotNetCore.MongoDb.sln --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --verbosity=WARN -f staged,modified
3232
VerifySuccessExitCode
3333
}
3434
else {
3535
Write-Output "Running code cleanup on commit range $baseCommitHash..$headCommitHash, including staged/unstaged files."
36-
dotnet regitlint -s JsonApiDotNetCore.MongoDb.sln --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN -f staged,modified,commits -a $headCommitHash -b $baseCommitHash
36+
dotnet regitlint -s JsonApiDotNetCore.MongoDb.sln --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --verbosity=WARN -f staged,modified,commits -a $headCommitHash -b $baseCommitHash
3737
VerifySuccessExitCode
3838
}
3939
}
4040
else {
4141
Write-Output "Running code cleanup on all files."
42-
dotnet regitlint -s JsonApiDotNetCore.MongoDb.sln --print-command --skip-tool-check --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN
42+
dotnet regitlint -s JsonApiDotNetCore.MongoDb.sln --print-command --skip-tool-check --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --verbosity=WARN
4343
VerifySuccessExitCode
4444
}

Diff for: logo.png

-16 KB
Binary file not shown.

Diff for: package-icon.png

2.84 KB
Loading

Diff for: package-versions.props

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<Project>
22
<PropertyGroup>
33
<!-- Published dependencies (only update on major version change) -->
4-
<JsonApiDotNetCoreFrozenVersion>5.5.0</JsonApiDotNetCoreFrozenVersion>
4+
<JsonApiDotNetCoreFrozenVersion>5.6.0</JsonApiDotNetCoreFrozenVersion>
55
<MongoDBDriverFrozenVersion>2.20.0</MongoDBDriverFrozenVersion>
66

77
<!-- Non-published dependencies (these are safe to update, won't cause a breaking change) -->
8-
<BogusVersion>34.0.*</BogusVersion>
8+
<BogusVersion>35.5.*</BogusVersion>
99
<CoverletVersion>6.0.*</CoverletVersion>
1010
<EphemeralMongoVersion>1.1.*</EphemeralMongoVersion>
1111
<FluentAssertionsVersion>6.12.*</FluentAssertionsVersion>
1212
<GitHubActionsTestLoggerVersion>2.3.*</GitHubActionsTestLoggerVersion>
13-
<InheritDocVersion>1.3.*</InheritDocVersion>
14-
<MongoDBDriverVersion>2.22.*</MongoDBDriverVersion>
13+
<InheritDocVersion>2.0.*</InheritDocVersion>
14+
<MongoDBDriverVersion>2.27.*</MongoDBDriverVersion>
1515
<SourceLinkVersion>8.0.*</SourceLinkVersion>
16-
<TestSdkVersion>17.8.*</TestSdkVersion>
17-
<XunitVersion>2.5.*</XunitVersion>
16+
<TestSdkVersion>17.10.*</TestSdkVersion>
17+
<XunitVersion>2.8.*</XunitVersion>
1818
</PropertyGroup>
1919

2020
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">

Diff for: src/Examples/JsonApiDotNetCoreMongoDbExample/Controllers/OperationsController.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ namespace JsonApiDotNetCoreMongoDbExample.Controllers;
88

99
public sealed class OperationsController(
1010
IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory, IOperationsProcessor processor, IJsonApiRequest request,
11-
ITargetedFields targetedFields) : JsonApiOperationsController(options, resourceGraph, loggerFactory, processor, request, targetedFields);
11+
ITargetedFields targetedFields, IAtomicOperationFilter operationFilter) : JsonApiOperationsController(options, resourceGraph, loggerFactory, processor,
12+
request, targetedFields, operationFilter);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System.Reflection;
2+
using JsonApiDotNetCore.Configuration;
3+
using Microsoft.EntityFrameworkCore;
4+
using Microsoft.EntityFrameworkCore.Metadata;
5+
using Microsoft.EntityFrameworkCore.Metadata.Builders;
6+
using MongoDB.Bson.Serialization.Attributes;
7+
8+
namespace JsonApiDotNetCore.MongoDb.Configuration;
9+
10+
internal static class ResourceGraphExtensions
11+
{
12+
public static IReadOnlyModel ToEntityModel(this IResourceGraph resourceGraph)
13+
{
14+
var modelBuilder = new ModelBuilder();
15+
16+
foreach (ResourceType resourceType in resourceGraph.GetResourceTypes())
17+
{
18+
IncludeResourceType(resourceType, modelBuilder);
19+
}
20+
21+
return modelBuilder.Model;
22+
}
23+
24+
private static void IncludeResourceType(ResourceType resourceType, ModelBuilder builder)
25+
{
26+
EntityTypeBuilder entityTypeBuilder = builder.Entity(resourceType.ClrType);
27+
28+
foreach (PropertyInfo property in resourceType.ClrType.GetProperties().Where(property => !IsIgnored(property)))
29+
{
30+
entityTypeBuilder.Property(property.PropertyType, property.Name);
31+
}
32+
}
33+
34+
private static bool IsIgnored(PropertyInfo property)
35+
{
36+
return property.GetCustomAttribute<BsonIgnoreAttribute>() != null;
37+
}
38+
}

Diff for: src/JsonApiDotNetCore.MongoDb/Configuration/ServiceCollectionExtensions.cs

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using JetBrains.Annotations;
22
using JsonApiDotNetCore.AtomicOperations;
3+
using JsonApiDotNetCore.Configuration;
34
using JsonApiDotNetCore.MongoDb.AtomicOperations;
45
using JsonApiDotNetCore.MongoDb.Queries.Internal;
56
using JsonApiDotNetCore.MongoDb.Repositories;
@@ -17,6 +18,12 @@ public static class ServiceCollectionExtensions
1718
[PublicAPI]
1819
public static IServiceCollection AddJsonApiMongoDb(this IServiceCollection services)
1920
{
21+
services.TryAddSingleton(serviceProvider =>
22+
{
23+
var resourceGraph = serviceProvider.GetRequiredService<IResourceGraph>();
24+
return resourceGraph.ToEntityModel();
25+
});
26+
2027
services.TryAddScoped<IMongoDataAccess, MongoDataAccess>();
2128

2229
// Replace the built-in implementations from JsonApiDotNetCore.

Diff for: src/JsonApiDotNetCore.MongoDb/JsonApiDotNetCore.MongoDb.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
<PackageTags>jsonapi;json:api;dotnet;asp.net;rest;web-api;MongoDB</PackageTags>
1313
<Description>Persistence layer implementation for use of MongoDB in APIs using JsonApiDotNetCore.</Description>
1414
<Authors>json-api-dotnet</Authors>
15-
<PackageProjectUrl>https://github.com/json-api-dotnet/JsonApiDotNetCore.MongoDb</PackageProjectUrl>
15+
<PackageProjectUrl>https://www.jsonapi.net/</PackageProjectUrl>
1616
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1717
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
1818
<PackageReleaseNotes>See https://github.com/json-api-dotnet/JsonApiDotNetCore.MongoDb/releases.</PackageReleaseNotes>
19-
<PackageIcon>logo.png</PackageIcon>
19+
<PackageIcon>package-icon.png</PackageIcon>
2020
<PackageReadmeFile>PackageReadme.md</PackageReadmeFile>
2121
<PublishRepositoryUrl>true</PublishRepositoryUrl>
2222
<EmbedUntrackedSources>true</EmbedUntrackedSources>
2323
<DebugType>embedded</DebugType>
2424
</PropertyGroup>
2525

2626
<ItemGroup>
27-
<None Include="..\..\logo.png" Visible="false" Pack="True" PackagePath="" />
27+
<None Include="..\..\package-icon.png" Visible="false" Pack="True" PackagePath="" />
2828
<None Include="..\..\PackageReadme.md" Visible="false" Pack="True" PackagePath="" />
2929
</ItemGroup>
3030

Diff for: src/JsonApiDotNetCore.MongoDb/Repositories/IMongoDataAccess.cs

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Microsoft.EntityFrameworkCore.Metadata;
12
using MongoDB.Driver;
23

34
namespace JsonApiDotNetCore.MongoDb.Repositories;
@@ -7,6 +8,11 @@ namespace JsonApiDotNetCore.MongoDb.Repositories;
78
/// </summary>
89
public interface IMongoDataAccess : IAsyncDisposable
910
{
11+
/// <summary>
12+
/// Provides access to the entity model, which is built at startup.
13+
/// </summary>
14+
IReadOnlyModel EntityModel { get; }
15+
1016
/// <summary>
1117
/// Provides access to the underlying MongoDB database, which data changes can be applied on.
1218
/// </summary>

Diff for: src/JsonApiDotNetCore.MongoDb/Repositories/MongoDataAccess.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
using Microsoft.EntityFrameworkCore.Metadata;
12
using MongoDB.Driver;
23

34
namespace JsonApiDotNetCore.MongoDb.Repositories;
45

56
/// <inheritdoc cref="IMongoDataAccess" />
67
public sealed class MongoDataAccess : IMongoDataAccess
78
{
9+
/// <inheritdoc />
10+
public IReadOnlyModel EntityModel { get; }
11+
812
/// <inheritdoc />
913
public IMongoDatabase MongoDatabase { get; }
1014

@@ -14,10 +18,12 @@ public sealed class MongoDataAccess : IMongoDataAccess
1418
/// <inheritdoc />
1519
public string? TransactionId => ActiveSession is { IsInTransaction: true } ? ActiveSession.GetHashCode().ToString() : null;
1620

17-
public MongoDataAccess(IMongoDatabase mongoDatabase)
21+
public MongoDataAccess(IReadOnlyModel entityModel, IMongoDatabase mongoDatabase)
1822
{
23+
ArgumentGuard.NotNull(entityModel);
1924
ArgumentGuard.NotNull(mongoDatabase);
2025

26+
EntityModel = entityModel;
2127
MongoDatabase = mongoDatabase;
2228
}
2329

Diff for: src/JsonApiDotNetCore.MongoDb/Repositories/MongoModel.cs

-33
This file was deleted.

0 commit comments

Comments
 (0)