Skip to content

Commit 9117f30

Browse files
committed
Package updates
1 parent 45a0a8b commit 9117f30

File tree

10 files changed

+57
-26
lines changed

10 files changed

+57
-26
lines changed

.config/dotnet-tools.json

Lines changed: 4 additions & 4 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.3.0",
6+
"version": "2021.3.4",
77
"commands": [
88
"jb"
99
]
1010
},
1111
"regitlint": {
12-
"version": "6.0.6",
12+
"version": "6.0.8",
1313
"commands": [
1414
"regitlint"
1515
]
@@ -21,10 +21,10 @@
2121
]
2222
},
2323
"dotnet-reportgenerator-globaltool": {
24-
"version": "5.0.0",
24+
"version": "5.1.4",
2525
"commands": [
2626
"reportgenerator"
2727
]
2828
}
2929
}
30-
}
30+
}

CodingGuidelines.ruleset

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414
<Rule Id="AV1555" Action="Warning" />
1515
<Rule Id="AV1564" Action="Info" />
1616
<Rule Id="AV1568" Action="Warning" />
17+
<Rule Id="AV1580" Action="None" />
1718
<Rule Id="AV1706" Action="Warning" />
1819
<Rule Id="AV1710" Action="Info" />
1920
<Rule Id="AV1711" Action="Info" />
2021
<Rule Id="AV1738" Action="Warning" />
2122
<Rule Id="AV1739" Action="Warning" />
2223
<Rule Id="AV1745" Action="Warning" />
2324
<Rule Id="AV1755" Action="Warning" />
24-
<Rule Id="AV2210" Action="None" />
25+
<Rule Id="AV2210" Action="Warning" />
2526
<Rule Id="AV2220" Action="Warning" />
2627
<Rule Id="AV2230" Action="Info" />
2728
<Rule Id="AV2305" Action="None" />

Directory.Build.props

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<PropertyGroup>
33
<TargetFrameworkName>net6.0</TargetFrameworkName>
44
<AspNetVersion>6.0.*</AspNetVersion>
5-
<JsonApiDotNetCoreVersion>5.0.0-pre1</JsonApiDotNetCoreVersion>
6-
<MongoDBDriverVersion>2.14.*</MongoDBDriverVersion>
7-
<JsonApiDotNetCoreMongoDbVersionPrefix>5.0.0</JsonApiDotNetCoreMongoDbVersionPrefix>
5+
<JsonApiDotNetCoreVersion>5.0.1</JsonApiDotNetCoreVersion>
6+
<MongoDBDriverVersion>2.15.0</MongoDBDriverVersion>
7+
<JsonApiDotNetCoreMongoDbVersionPrefix>5.0.1</JsonApiDotNetCoreMongoDbVersionPrefix>
88
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)CodingGuidelines.ruleset</CodeAnalysisRuleSet>
99
<WarningLevel>9999</WarningLevel>
1010
<Nullable>enable</Nullable>
@@ -15,7 +15,7 @@
1515

1616
<ItemGroup>
1717
<PackageReference Include="JetBrains.Annotations" Version="2021.3.0" PrivateAssets="All" />
18-
<PackageReference Include="CSharpGuidelinesAnalyzer" Version="3.7.1" PrivateAssets="All" />
18+
<PackageReference Include="CSharpGuidelinesAnalyzer" Version="3.8.0" PrivateAssets="All" />
1919
<AdditionalFiles Include="$(MSBuildThisFileDirectory)CSharpGuidelinesAnalyzer.config" Visible="False" />
2020
</ItemGroup>
2121

@@ -25,10 +25,14 @@
2525
<GenerateDocumentationFile>true</GenerateDocumentationFile>
2626
</PropertyGroup>
2727

28+
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
29+
<NoWarn>$(NoWarn);AV2210</NoWarn>
30+
</PropertyGroup>
31+
2832
<!-- Test Project Dependencies -->
2933
<PropertyGroup>
30-
<CoverletVersion>3.1.0</CoverletVersion>
34+
<CoverletVersion>3.1.2</CoverletVersion>
3135
<MoqVersion>4.16.1</MoqVersion>
32-
<TestSdkVersion>17.0.0</TestSdkVersion>
36+
<TestSdkVersion>17.1.0</TestSdkVersion>
3337
</PropertyGroup>
3438
</Project>

src/JsonApiDotNetCore.MongoDb/Configuration/ServiceCollectionExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
using JsonApiDotNetCore.Queries.Internal;
77
using Microsoft.Extensions.DependencyInjection;
88

9+
#pragma warning disable AV1130 // Return type in method signature should be an interface to an unchangeable collection
10+
911
namespace JsonApiDotNetCore.MongoDb.Configuration;
1012

1113
public static class ServiceCollectionExtensions

src/JsonApiDotNetCore.MongoDb/Repositories/MongoModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public MongoModel(IResourceGraph resourceGraph)
1313

1414
foreach (ResourceType resourceType in resourceGraph.GetResourceTypes())
1515
{
16-
RuntimeEntityType entityType = AddEntityType(resourceType.ClrType.Name, resourceType.ClrType);
16+
RuntimeEntityType entityType = AddEntityType(resourceType.ClrType.FullName!, resourceType.ClrType);
1717
SetEntityProperties(entityType, resourceType);
1818
}
1919
}

src/JsonApiDotNetCore.MongoDb/Repositories/MongoQueryExpressionValidator.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using JsonApiDotNetCore.Configuration;
12
using JsonApiDotNetCore.MongoDb.Errors;
23
using JsonApiDotNetCore.Queries;
34
using JsonApiDotNetCore.Queries.Expressions;
@@ -12,9 +13,8 @@ public void Validate(QueryLayer layer)
1213
ArgumentGuard.NotNull(layer, nameof(layer));
1314

1415
bool hasIncludes = layer.Include?.Elements.Any() == true;
15-
bool hasSparseRelationshipSets = layer.Projection?.Any(pair => pair.Key is RelationshipAttribute) == true;
1616

17-
if (hasIncludes || hasSparseRelationshipSets)
17+
if (hasIncludes || HasSparseRelationshipSets(layer.Selection))
1818
{
1919
throw new UnsupportedRelationshipException();
2020
}
@@ -24,6 +24,24 @@ public void Validate(QueryLayer layer)
2424
ValidateExpression(layer.Pagination);
2525
}
2626

27+
private static bool HasSparseRelationshipSets(FieldSelection? selection)
28+
{
29+
if (selection is { IsEmpty: false })
30+
{
31+
foreach (ResourceType resourceType in selection.GetResourceTypes())
32+
{
33+
FieldSelectors selectors = selection.GetOrCreateSelectors(resourceType);
34+
35+
if (selectors.Any(pair => pair.Key is RelationshipAttribute))
36+
{
37+
return true;
38+
}
39+
}
40+
}
41+
42+
return false;
43+
}
44+
2745
private void ValidateExpression(QueryExpression? expression)
2846
{
2947
if (expression != null)

src/JsonApiDotNetCore.MongoDb/Repositories/MongoRepository.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ public virtual Task<int> CountAsync(FilterExpression? topFilter, CancellationTok
8282
return query.CountAsync(cancellationToken);
8383
}
8484

85+
#pragma warning disable AV1130 // Return type in method signature should be an interface to an unchangeable collection
8586
protected virtual IMongoQueryable<TResource> ApplyQueryLayer(QueryLayer queryLayer)
87+
#pragma warning restore AV1130 // Return type in method signature should be an interface to an unchangeable collection
8688
{
8789
ArgumentGuard.NotNull(queryLayer, nameof(queryLayer));
8890

@@ -120,7 +122,9 @@ protected virtual IMongoQueryable<TResource> ApplyQueryLayer(QueryLayer queryLay
120122
return (IMongoQueryable<TResource>)source.Provider.CreateQuery<TResource>(expression);
121123
}
122124

125+
#pragma warning disable AV1130 // Return type in method signature should be an interface to an unchangeable collection
123126
protected virtual IQueryable<TResource> GetAll()
127+
#pragma warning restore AV1130 // Return type in method signature should be an interface to an unchangeable collection
124128
{
125129
return _mongoDataAccess.ActiveSession != null ? Collection.AsQueryable(_mongoDataAccess.ActiveSession) : Collection.AsQueryable();
126130
}
@@ -150,9 +154,9 @@ private void AssertNoRelationshipsInSparseFieldSets()
150154
}
151155

152156
/// <inheritdoc />
153-
public virtual Task<TResource> GetForCreateAsync(TId id, CancellationToken cancellationToken)
157+
public virtual Task<TResource> GetForCreateAsync(Type resourceClrType, TId id, CancellationToken cancellationToken)
154158
{
155-
var resource = _resourceFactory.CreateInstance<TResource>();
159+
var resource = (TResource)_resourceFactory.CreateInstance(resourceClrType);
156160
resource.Id = id;
157161

158162
return Task.FromResult(resource);
@@ -228,9 +232,9 @@ await SaveChangesAsync(async () =>
228232
}
229233

230234
/// <inheritdoc />
231-
public virtual async Task DeleteAsync(TId id, CancellationToken cancellationToken)
235+
public virtual async Task DeleteAsync(TResource? resourceFromDatabase, TId id, CancellationToken cancellationToken)
232236
{
233-
var placeholderResource = _resourceFactory.CreateInstance<TResource>();
237+
TResource placeholderResource = resourceFromDatabase ?? _resourceFactory.CreateInstance<TResource>();
234238
placeholderResource.Id = id;
235239

236240
await _resourceDefinitionAccessor.OnWritingAsync(placeholderResource, WriteOperationKind.DeleteResource, cancellationToken);
@@ -263,7 +267,8 @@ public virtual Task SetRelationshipAsync(TResource leftResource, object? rightVa
263267
}
264268

265269
/// <inheritdoc />
266-
public virtual Task AddToToManyRelationshipAsync(TId leftId, ISet<IIdentifiable> rightResourceIds, CancellationToken cancellationToken)
270+
public virtual Task AddToToManyRelationshipAsync(TResource? leftResource, TId leftId, ISet<IIdentifiable> rightResourceIds,
271+
CancellationToken cancellationToken)
267272
{
268273
throw new UnsupportedRelationshipException();
269274
}

test/JsonApiDotNetCoreMongoDbTests/IntegrationTests/AtomicOperations/Transactions/PerformerRepository.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public Task<int> CountAsync(FilterExpression? filter, CancellationToken cancella
2121
throw new NotImplementedException();
2222
}
2323

24-
public Task<Performer> GetForCreateAsync(string? id, CancellationToken cancellationToken)
24+
public Task<Performer> GetForCreateAsync(Type resourceClrType, string? id, CancellationToken cancellationToken)
2525
{
2626
throw new NotImplementedException();
2727
}
@@ -41,7 +41,7 @@ public Task UpdateAsync(Performer resourceFromRequest, Performer resourceFromDat
4141
throw new NotImplementedException();
4242
}
4343

44-
public Task DeleteAsync(string? id, CancellationToken cancellationToken)
44+
public Task DeleteAsync(Performer? resourceFromDatabase, string? id, CancellationToken cancellationToken)
4545
{
4646
throw new NotImplementedException();
4747
}
@@ -51,7 +51,8 @@ public Task SetRelationshipAsync(Performer leftResource, object? rightValue, Can
5151
throw new NotImplementedException();
5252
}
5353

54-
public Task AddToToManyRelationshipAsync(string? leftId, ISet<IIdentifiable> rightResourceIds, CancellationToken cancellationToken)
54+
public Task AddToToManyRelationshipAsync(Performer? leftResource, string? leftId, ISet<IIdentifiable> rightResourceIds,
55+
CancellationToken cancellationToken)
5556
{
5657
throw new NotImplementedException();
5758
}

test/JsonApiDotNetCoreMongoDbTests/IntegrationTests/HitCountingResourceDefinition.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,15 @@ public override Task OnSetToManyRelationshipAsync(TResource leftResource, HasMan
126126
return base.OnSetToManyRelationshipAsync(leftResource, hasManyRelationship, rightResourceIds, writeOperation, cancellationToken);
127127
}
128128

129-
public override Task OnAddToRelationshipAsync(TId leftResourceId, HasManyAttribute hasManyRelationship, ISet<IIdentifiable> rightResourceIds,
129+
public override Task OnAddToRelationshipAsync(TResource leftResource, HasManyAttribute hasManyRelationship, ISet<IIdentifiable> rightResourceIds,
130130
CancellationToken cancellationToken)
131131
{
132132
if (ExtensibilityPointsToTrack.HasFlag(ResourceDefinitionExtensibilityPoints.OnAddToRelationshipAsync))
133133
{
134134
_hitCounter.TrackInvocation<TResource>(ResourceDefinitionExtensibilityPoints.OnAddToRelationshipAsync);
135135
}
136136

137-
return base.OnAddToRelationshipAsync(leftResourceId, hasManyRelationship, rightResourceIds, cancellationToken);
137+
return base.OnAddToRelationshipAsync(leftResource, hasManyRelationship, rightResourceIds, cancellationToken);
138138
}
139139

140140
public override Task OnRemoveFromRelationshipAsync(TResource leftResource, HasManyAttribute hasManyRelationship, ISet<IIdentifiable> rightResourceIds,

test/TestBuildingBlocks/TestBuildingBlocks.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
</ItemGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Bogus" Version="34.0.1" />
11+
<PackageReference Include="Bogus" Version="34.0.2" />
1212
<PackageReference Include="coverlet.collector" Version="$(CoverletVersion)" PrivateAssets="All" />
13-
<PackageReference Include="FluentAssertions" Version="6.2.0" />
13+
<PackageReference Include="FluentAssertions" Version="6.5.1" />
1414
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="$(AspNetVersion)" />
1515
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
1616
<PackageReference Include="Mongo2Go" Version="3.1.3" />

0 commit comments

Comments
 (0)