Skip to content

Commit a3a9389

Browse files
author
Bart Koelman
authored
Package updates (#1146)
* Renamed method to avoid clash with built-in method from newer version of FluentAssertions * Package updates * Fix cases for AV1130: Return type should be interface to unchangeable collection * Fix cases for AV1553/AV1554: Optional string/collection/task parameter usage
1 parent b48f02e commit a3a9389

File tree

147 files changed

+1343
-1275
lines changed

Some content is hidden

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

147 files changed

+1343
-1275
lines changed

.config/dotnet-tools.json

Lines changed: 3 additions & 3 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,7 +21,7 @@
2121
]
2222
},
2323
"dotnet-reportgenerator-globaltool": {
24-
"version": "5.0.0",
24+
"version": "5.1.3",
2525
"commands": [
2626
"reportgenerator"
2727
]

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: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<AspNetVersion>6.0.*</AspNetVersion>
55
<EFCoreVersion>6.0.*</EFCoreVersion>
66
<EFCorePostgresVersion>6.0.*</EFCorePostgresVersion>
7-
<MicrosoftCodeAnalysisVersion>4.0.*</MicrosoftCodeAnalysisVersion>
7+
<MicrosoftCodeAnalysisVersion>4.1.*</MicrosoftCodeAnalysisVersion>
88
<HumanizerVersion>2.*</HumanizerVersion>
99
<JsonApiDotNetCoreVersionPrefix>5.0.0</JsonApiDotNetCoreVersionPrefix>
1010
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)CodingGuidelines.ruleset</CodeAnalysisRuleSet>
@@ -17,7 +17,7 @@
1717

1818
<ItemGroup>
1919
<PackageReference Include="JetBrains.Annotations" Version="2021.3.0" PrivateAssets="All" />
20-
<PackageReference Include="CSharpGuidelinesAnalyzer" Version="3.7.1" PrivateAssets="All" />
20+
<PackageReference Include="CSharpGuidelinesAnalyzer" Version="3.8.0" PrivateAssets="All" />
2121
<AdditionalFiles Include="$(MSBuildThisFileDirectory)CSharpGuidelinesAnalyzer.config" Visible="False" />
2222
</ItemGroup>
2323

@@ -27,10 +27,14 @@
2727
<GenerateDocumentationFile>true</GenerateDocumentationFile>
2828
</PropertyGroup>
2929

30+
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
31+
<NoWarn>$(NoWarn);AV2210</NoWarn>
32+
</PropertyGroup>
33+
3034
<!-- Test Project Dependencies -->
3135
<PropertyGroup>
3236
<CoverletVersion>3.1.2</CoverletVersion>
33-
<MoqVersion>4.16.1</MoqVersion>
37+
<MoqVersion>4.17.2</MoqVersion>
3438
<TestSdkVersion>17.1.0</TestSdkVersion>
3539
</PropertyGroup>
3640
</Project>

benchmarks/Serialization/SerializationBenchmarkBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public RelationshipLinks GetRelationshipLinks(RelationshipAttribute relationship
245245

246246
private sealed class FakeMetaBuilder : IMetaBuilder
247247
{
248-
public void Add(IReadOnlyDictionary<string, object?> values)
248+
public void Add(IDictionary<string, object?> values)
249249
{
250250
}
251251

src/JsonApiDotNetCore.Annotations/ArgumentGuard.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,24 @@ public static void NotNull<T>([NoEnumeration] [SysNotNull] T? value, [InvokerPar
1818
}
1919

2020
[AssertionMethod]
21-
public static void NotNullNorEmpty<T>([SysNotNull] IEnumerable<T>? value, [InvokerParameterName] string name, string? collectionName = null)
21+
public static void NotNullNorEmpty<T>([SysNotNull] IEnumerable<T>? value, [InvokerParameterName] string name)
2222
{
2323
NotNull(value, name);
2424

2525
if (!value.Any())
2626
{
27-
throw new ArgumentException($"Must have one or more {collectionName ?? name}.", name);
27+
throw new ArgumentException($"Must have one or more {name}.", name);
28+
}
29+
}
30+
31+
[AssertionMethod]
32+
public static void NotNullNorEmpty<T>([SysNotNull] IEnumerable<T>? value, [InvokerParameterName] string name, string collectionName)
33+
{
34+
NotNull(value, name);
35+
36+
if (!value.Any())
37+
{
38+
throw new ArgumentException($"Must have one or more {collectionName}.", name);
2839
}
2940
}
3041

src/JsonApiDotNetCore.Annotations/CollectionConverter.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,19 @@ private Type ToConcreteCollectionType(Type collectionType)
6666
/// <summary>
6767
/// Returns a collection that contains zero, one or multiple resources, depending on the specified value.
6868
/// </summary>
69-
public ICollection<IIdentifiable> ExtractResources(object? value)
69+
public IReadOnlyCollection<IIdentifiable> ExtractResources(object? value)
7070
{
71-
if (value is ICollection<IIdentifiable> resourceCollection)
71+
if (value is List<IIdentifiable> resourceList)
72+
{
73+
return resourceList;
74+
}
75+
76+
if (value is HashSet<IIdentifiable> resourceSet)
77+
{
78+
return resourceSet;
79+
}
80+
81+
if (value is IReadOnlyCollection<IIdentifiable> resourceCollection)
7282
{
7383
return resourceCollection;
7484
}

src/JsonApiDotNetCore.Annotations/Configuration/ResourceType.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,14 @@ public sealed class ResourceType
8989
/// </remarks>
9090
public LinkTypes RelationshipLinks { get; }
9191

92-
public ResourceType(string publicName, Type clrType, Type identityClrType, IReadOnlyCollection<AttrAttribute>? attributes = null,
93-
IReadOnlyCollection<RelationshipAttribute>? relationships = null, IReadOnlyCollection<EagerLoadAttribute>? eagerLoads = null,
92+
public ResourceType(string publicName, Type clrType, Type identityClrType, LinkTypes topLevelLinks = LinkTypes.NotConfigured,
93+
LinkTypes resourceLinks = LinkTypes.NotConfigured, LinkTypes relationshipLinks = LinkTypes.NotConfigured)
94+
: this(publicName, clrType, identityClrType, null, null, null, topLevelLinks, resourceLinks, relationshipLinks)
95+
{
96+
}
97+
98+
public ResourceType(string publicName, Type clrType, Type identityClrType, IReadOnlyCollection<AttrAttribute>? attributes,
99+
IReadOnlyCollection<RelationshipAttribute>? relationships, IReadOnlyCollection<EagerLoadAttribute>? eagerLoads,
94100
LinkTypes topLevelLinks = LinkTypes.NotConfigured, LinkTypes resourceLinks = LinkTypes.NotConfigured,
95101
LinkTypes relationshipLinks = LinkTypes.NotConfigured)
96102
{

src/JsonApiDotNetCore.Annotations/ObjectExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#pragma warning disable AV1130 // Return type in method signature should be a collection interface instead of a concrete type
1+
#pragma warning disable AV1130 // Return type in method signature should be an interface to an unchangeable collection
22

33
namespace JsonApiDotNetCore;
44

src/JsonApiDotNetCore/ArrayFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#pragma warning disable AV1008 // Class should not be static
2-
#pragma warning disable AV1130 // Return type in method signature should be a collection interface instead of a concrete type
2+
#pragma warning disable AV1130 // Return type in method signature should be an interface to an unchangeable collection
33

44
namespace JsonApiDotNetCore;
55

src/JsonApiDotNetCore/AtomicOperations/Processors/SetRelationshipProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public SetRelationshipProcessor(ISetRelationshipService<TResource, TId> service)
4040

4141
if (relationship is HasManyAttribute)
4242
{
43-
ICollection<IIdentifiable> rightResources = _collectionConverter.ExtractResources(rightValue);
43+
IReadOnlyCollection<IIdentifiable> rightResources = _collectionConverter.ExtractResources(rightValue);
4444
return rightResources.ToHashSet(IdentifiableComparer.Instance);
4545
}
4646

0 commit comments

Comments
 (0)