Skip to content

Commit f476ce2

Browse files
committed
Post-merge fixes
1 parent e39a870 commit f476ce2

Some content is hidden

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

41 files changed

+99
-104
lines changed
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1+
using System.Runtime.CompilerServices;
12
using JetBrains.Annotations;
23
using SysNotNull = System.Diagnostics.CodeAnalysis.NotNullAttribute;
34

45
#pragma warning disable AV1008 // Class should not be static
6+
#pragma warning disable AV1553 // Do not use optional parameters with default value null for strings, collections or tasks
57

68
namespace JsonApiDotNetCore.OpenApi.Client;
79

810
internal static class ArgumentGuard
911
{
1012
[AssertionMethod]
11-
public static void NotNull<T>([NoEnumeration] [SysNotNull] T? value, [InvokerParameterName] string name)
13+
public static void NotNull<T>([NoEnumeration] [SysNotNull] T? value, [CallerArgumentExpression("value")] string? parameterName = null)
1214
where T : class
1315
{
14-
if (value is null)
15-
{
16-
throw new ArgumentNullException(name);
17-
}
16+
ArgumentNullException.ThrowIfNull(value, parameterName);
1817
}
1918
}

src/JsonApiDotNetCore.OpenApi.Client/JsonApiClient.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public abstract class JsonApiClient : IJsonApiClient
1717

1818
protected void SetSerializerSettingsForJsonApi(JsonSerializerSettings settings)
1919
{
20-
ArgumentGuard.NotNull(settings, nameof(settings));
20+
ArgumentGuard.NotNull(settings);
2121

2222
settings.Converters.Add(_jsonApiJsonConverter);
2323
}
@@ -27,7 +27,7 @@ public IDisposable RegisterAttributesForRequestDocument<TRequestDocument, TAttri
2727
params Expression<Func<TAttributesObject, object?>>[] alwaysIncludedAttributeSelectors)
2828
where TRequestDocument : class
2929
{
30-
ArgumentGuard.NotNull(requestDocument, nameof(requestDocument));
30+
ArgumentGuard.NotNull(requestDocument);
3131

3232
var attributeNames = new HashSet<string>();
3333

@@ -105,7 +105,7 @@ public void RemoveAttributeRegistration(object requestDocument)
105105

106106
public override bool CanConvert(Type objectType)
107107
{
108-
ArgumentGuard.NotNull(objectType, nameof(objectType));
108+
ArgumentGuard.NotNull(objectType);
109109

110110
return !_isSerializing && _requestDocumentInstancesPerRequestDocumentType.ContainsKey(objectType);
111111
}
@@ -117,8 +117,8 @@ public override object ReadJson(JsonReader reader, Type objectType, object? exis
117117

118118
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
119119
{
120-
ArgumentGuard.NotNull(writer, nameof(writer));
121-
ArgumentGuard.NotNull(serializer, nameof(serializer));
120+
ArgumentGuard.NotNull(writer);
121+
ArgumentGuard.NotNull(serializer);
122122

123123
if (value != null)
124124
{
@@ -148,8 +148,8 @@ private sealed class AttributeNamesContainer
148148

149149
public AttributeNamesContainer(ISet<string> attributeNames, Type containerType)
150150
{
151-
ArgumentGuard.NotNull(attributeNames, nameof(attributeNames));
152-
ArgumentGuard.NotNull(containerType, nameof(containerType));
151+
ArgumentGuard.NotNull(attributeNames);
152+
ArgumentGuard.NotNull(containerType);
153153

154154
_attributeNames = attributeNames;
155155
_containerType = containerType;
@@ -173,8 +173,8 @@ private sealed class AttributesRegistrationScope : IDisposable
173173

174174
public AttributesRegistrationScope(JsonApiJsonConverter jsonApiJsonConverter, object requestDocument)
175175
{
176-
ArgumentGuard.NotNull(jsonApiJsonConverter, nameof(jsonApiJsonConverter));
177-
ArgumentGuard.NotNull(requestDocument, nameof(requestDocument));
176+
ArgumentGuard.NotNull(jsonApiJsonConverter);
177+
ArgumentGuard.NotNull(requestDocument);
178178

179179
_jsonApiJsonConverter = jsonApiJsonConverter;
180180
_requestDocument = requestDocument;
@@ -192,7 +192,7 @@ private sealed class JsonApiDocumentContractResolver : DefaultContractResolver
192192

193193
public JsonApiDocumentContractResolver(AttributeNamesContainer attributeNamesContainer)
194194
{
195-
ArgumentGuard.NotNull(attributeNamesContainer, nameof(attributeNamesContainer));
195+
ArgumentGuard.NotNull(attributeNamesContainer);
196196

197197
_attributeNamesContainer = attributeNamesContainer;
198198
}

src/JsonApiDotNetCore.OpenApi.Client/JsonApiDotNetCore.OpenApi.Client.csproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@
2828
</ItemGroup>
2929

3030
<ItemGroup>
31-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
32-
<PrivateAssets>all</PrivateAssets>
33-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
34-
</PackageReference>
31+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
32+
<PackageReference Include="SauceControl.InheritDoc" Version="1.3.0" PrivateAssets="All" />
3533
<PackageReference Include="Swashbuckle.AspNetCore" Version="$(SwashbuckleVersion)" />
3634
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="$(SwashbuckleVersion)" />
3735
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="$(SwashbuckleVersion)" />

src/JsonApiDotNetCore.OpenApi/ActionDescriptorExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ internal static class ActionDescriptorExtensions
1010
{
1111
public static MethodInfo GetActionMethod(this ActionDescriptor descriptor)
1212
{
13-
ArgumentGuard.NotNull(descriptor, nameof(descriptor));
13+
ArgumentGuard.NotNull(descriptor);
1414

1515
return ((ControllerActionDescriptor)descriptor).MethodInfo;
1616
}
1717

1818
public static TFilterMetaData? GetFilterMetadata<TFilterMetaData>(this ActionDescriptor descriptor)
1919
where TFilterMetaData : IFilterMetadata
2020
{
21-
ArgumentGuard.NotNull(descriptor, nameof(descriptor));
21+
ArgumentGuard.NotNull(descriptor);
2222

2323
IFilterMetadata? filterMetadata = descriptor.FilterDescriptors.Select(filterDescriptor => filterDescriptor.Filter)
2424
.FirstOrDefault(filter => filter is TFilterMetaData);
@@ -28,7 +28,7 @@ public static MethodInfo GetActionMethod(this ActionDescriptor descriptor)
2828

2929
public static ControllerParameterDescriptor? GetBodyParameterDescriptor(this ActionDescriptor descriptor)
3030
{
31-
ArgumentGuard.NotNull(descriptor, nameof(descriptor));
31+
ArgumentGuard.NotNull(descriptor);
3232

3333
return (ControllerParameterDescriptor?)descriptor.Parameters.FirstOrDefault(parameterDescriptor =>
3434
// ReSharper disable once ConstantConditionalAccessQualifier

src/JsonApiDotNetCore.OpenApi/JsonApiActionDescriptorCollectionProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ internal sealed class JsonApiActionDescriptorCollectionProvider : IActionDescrip
2424

2525
public JsonApiActionDescriptorCollectionProvider(IControllerResourceMapping controllerResourceMapping, IActionDescriptorCollectionProvider defaultProvider)
2626
{
27-
ArgumentGuard.NotNull(controllerResourceMapping, nameof(controllerResourceMapping));
28-
ArgumentGuard.NotNull(defaultProvider, nameof(defaultProvider));
27+
ArgumentGuard.NotNull(controllerResourceMapping);
28+
ArgumentGuard.NotNull(defaultProvider);
2929

3030
_defaultProvider = defaultProvider;
3131
_jsonApiEndpointMetadataProvider = new JsonApiEndpointMetadataProvider(controllerResourceMapping);

src/JsonApiDotNetCore.OpenApi/JsonApiDotNetCore.OpenApi.csproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@
3232
</ItemGroup>
3333

3434
<ItemGroup>
35-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
36-
<PrivateAssets>all</PrivateAssets>
37-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
38-
</PackageReference>
35+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
36+
<PackageReference Include="SauceControl.InheritDoc" Version="1.3.0" PrivateAssets="All" />
3937
<PackageReference Include="Swashbuckle.AspNetCore" Version="$(SwashbuckleVersion)" />
4038
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="$(SwashbuckleVersion)" />
4139
</ItemGroup>

src/JsonApiDotNetCore.OpenApi/JsonApiMetadata/EndpointResolver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ internal sealed class EndpointResolver
99
{
1010
public JsonApiEndpoint? Get(MethodInfo controllerAction)
1111
{
12-
ArgumentGuard.NotNull(controllerAction, nameof(controllerAction));
12+
ArgumentGuard.NotNull(controllerAction);
1313

1414
// This is a temporary work-around to prevent the JsonApiDotNetCoreExample project from crashing upon startup.
1515
if (!IsJsonApiController(controllerAction) || IsOperationsController(controllerAction))

src/JsonApiDotNetCore.OpenApi/JsonApiMetadata/JsonApiEndpointMetadataProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ internal sealed class JsonApiEndpointMetadataProvider
1818

1919
public JsonApiEndpointMetadataProvider(IControllerResourceMapping controllerResourceMapping)
2020
{
21-
ArgumentGuard.NotNull(controllerResourceMapping, nameof(controllerResourceMapping));
21+
ArgumentGuard.NotNull(controllerResourceMapping);
2222

2323
_controllerResourceMapping = controllerResourceMapping;
2424
}
2525

2626
public JsonApiEndpointMetadataContainer Get(MethodInfo controllerAction)
2727
{
28-
ArgumentGuard.NotNull(controllerAction, nameof(controllerAction));
28+
ArgumentGuard.NotNull(controllerAction);
2929

3030
JsonApiEndpoint? endpoint = _endpointResolver.Get(controllerAction);
3131

src/JsonApiDotNetCore.OpenApi/JsonApiMetadata/NonPrimaryEndpointMetadata.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ internal abstract class NonPrimaryEndpointMetadata
66

77
protected NonPrimaryEndpointMetadata(IDictionary<string, Type> documentTypesByRelationshipName)
88
{
9-
ArgumentGuard.NotNull(documentTypesByRelationshipName, nameof(documentTypesByRelationshipName));
9+
ArgumentGuard.NotNull(documentTypesByRelationshipName);
1010

1111
DocumentTypesByRelationshipName = documentTypesByRelationshipName;
1212
}

src/JsonApiDotNetCore.OpenApi/JsonApiMetadata/PrimaryRequestMetadata.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ internal sealed class PrimaryRequestMetadata : IJsonApiRequestMetadata
66

77
public PrimaryRequestMetadata(Type documentType)
88
{
9-
ArgumentGuard.NotNull(documentType, nameof(documentType));
9+
ArgumentGuard.NotNull(documentType);
1010

1111
DocumentType = documentType;
1212
}

src/JsonApiDotNetCore.OpenApi/JsonApiMetadata/PrimaryResponseMetadata.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ internal sealed class PrimaryResponseMetadata : IJsonApiResponseMetadata
66

77
public PrimaryResponseMetadata(Type documentType)
88
{
9-
ArgumentGuard.NotNull(documentType, nameof(documentType));
9+
ArgumentGuard.NotNull(documentType);
1010

1111
DocumentType = documentType;
1212
}

src/JsonApiDotNetCore.OpenApi/JsonApiObjects/NonPrimaryDocumentTypeFactory.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@ private NonPrimaryDocumentTypeFactory()
2323

2424
public Type GetForSecondaryResponse(RelationshipAttribute relationship)
2525
{
26-
ArgumentGuard.NotNull(relationship, nameof(relationship));
26+
ArgumentGuard.NotNull(relationship);
2727

2828
return Get(relationship, SecondaryResponseDocumentOpenTypes);
2929
}
3030

3131
public Type GetForRelationshipRequest(RelationshipAttribute relationship)
3232
{
33-
ArgumentGuard.NotNull(relationship, nameof(relationship));
33+
ArgumentGuard.NotNull(relationship);
3434

3535
return Get(relationship, RelationshipRequestDocumentOpenTypes);
3636
}
3737

3838
public Type GetForRelationshipResponse(RelationshipAttribute relationship)
3939
{
40-
ArgumentGuard.NotNull(relationship, nameof(relationship));
40+
ArgumentGuard.NotNull(relationship);
4141

4242
return Get(relationship, RelationshipResponseDocumentOpenTypes);
4343
}
@@ -65,9 +65,9 @@ private sealed class DocumentOpenTypes
6565

6666
public DocumentOpenTypes(Type manyDataOpenType, Type nullableSingleDataOpenType, Type singleDataOpenType)
6767
{
68-
ArgumentGuard.NotNull(manyDataOpenType, nameof(manyDataOpenType));
69-
ArgumentGuard.NotNull(nullableSingleDataOpenType, nameof(nullableSingleDataOpenType));
70-
ArgumentGuard.NotNull(singleDataOpenType, nameof(singleDataOpenType));
68+
ArgumentGuard.NotNull(manyDataOpenType);
69+
ArgumentGuard.NotNull(nullableSingleDataOpenType);
70+
ArgumentGuard.NotNull(singleDataOpenType);
7171

7272
ManyDataOpenType = manyDataOpenType;
7373
NullableSingleDataOpenType = nullableSingleDataOpenType;

src/JsonApiDotNetCore.OpenApi/JsonApiObjects/RelationshipTypeFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ private RelationshipTypeFactory()
1313

1414
public Type GetForRequest(RelationshipAttribute relationship)
1515
{
16-
ArgumentGuard.NotNull(relationship, nameof(relationship));
16+
ArgumentGuard.NotNull(relationship);
1717

1818
return NonPrimaryDocumentTypeFactory.Instance.GetForRelationshipRequest(relationship);
1919
}
2020

2121
public Type GetForResponse(RelationshipAttribute relationship)
2222
{
23-
ArgumentGuard.NotNull(relationship, nameof(relationship));
23+
ArgumentGuard.NotNull(relationship);
2424

2525
// @formatter:nested_ternary_style expanded
2626

src/JsonApiDotNetCore.OpenApi/JsonApiOperationIdSelector.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ internal sealed class JsonApiOperationIdSelector
3939

4040
public JsonApiOperationIdSelector(IControllerResourceMapping controllerResourceMapping, JsonNamingPolicy? namingPolicy)
4141
{
42-
ArgumentGuard.NotNull(controllerResourceMapping, nameof(controllerResourceMapping));
42+
ArgumentGuard.NotNull(controllerResourceMapping);
4343

4444
_controllerResourceMapping = controllerResourceMapping;
4545
_namingPolicy = namingPolicy;
4646
}
4747

4848
public string GetOperationId(ApiDescription endpoint)
4949
{
50-
ArgumentGuard.NotNull(endpoint, nameof(endpoint));
50+
ArgumentGuard.NotNull(endpoint);
5151

5252
ResourceType? primaryResourceType = _controllerResourceMapping.GetResourceTypeForController(endpoint.ActionDescriptor.GetActionMethod().ReflectedType);
5353

src/JsonApiDotNetCore.OpenApi/JsonApiRequestFormatMetadataProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public Task<InputFormatterResult> ReadAsync(InputFormatterContext context)
3333
/// <inheritdoc />
3434
public IReadOnlyList<string> GetSupportedContentTypes(string contentType, Type objectType)
3535
{
36-
ArgumentGuard.NotNullNorEmpty(contentType, nameof(contentType));
37-
ArgumentGuard.NotNull(objectType, nameof(objectType));
36+
ArgumentGuard.NotNullNorEmpty(contentType);
37+
ArgumentGuard.NotNull(objectType);
3838

3939
if (contentType == HeaderConstants.MediaType && objectType.IsGenericType &&
4040
JsonApiRequestObjectOpenType.Contains(objectType.GetGenericTypeDefinition()))

src/JsonApiDotNetCore.OpenApi/JsonApiSchemaIdSelector.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ internal sealed class JsonApiSchemaIdSelector
4343

4444
public JsonApiSchemaIdSelector(JsonNamingPolicy? namingPolicy, IResourceGraph resourceGraph)
4545
{
46-
ArgumentGuard.NotNull(resourceGraph, nameof(resourceGraph));
46+
ArgumentGuard.NotNull(resourceGraph);
4747

4848
_namingPolicy = namingPolicy;
4949
_resourceGraph = resourceGraph;
5050
}
5151

5252
public string GetSchemaId(Type type)
5353
{
54-
ArgumentGuard.NotNull(type, nameof(type));
54+
ArgumentGuard.NotNull(type);
5555

5656
ResourceType? resourceType = _resourceGraph.FindResourceType(type);
5757

src/JsonApiDotNetCore.OpenApi/MemberInfoExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ internal static class MemberInfoExtensions
77
{
88
public static TypeCategory GetTypeCategory(this MemberInfo source)
99
{
10-
ArgumentGuard.NotNull(source, nameof(source));
10+
ArgumentGuard.NotNull(source);
1111

1212
Type memberType;
1313

src/JsonApiDotNetCore.OpenApi/ObjectExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ internal static class ObjectExtensions
1010

1111
public static object MemberwiseClone(this object source)
1212
{
13-
ArgumentGuard.NotNull(source, nameof(source));
13+
ArgumentGuard.NotNull(source);
1414

1515
return MemberwiseCloneMethod.Value.Invoke(source, null)!;
1616
}

src/JsonApiDotNetCore.OpenApi/OpenApiEndpointConvention.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ internal sealed class OpenApiEndpointConvention : IActionModelConvention
1818

1919
public OpenApiEndpointConvention(IControllerResourceMapping controllerResourceMapping)
2020
{
21-
ArgumentGuard.NotNull(controllerResourceMapping, nameof(controllerResourceMapping));
21+
ArgumentGuard.NotNull(controllerResourceMapping);
2222

2323
_controllerResourceMapping = controllerResourceMapping;
2424
}
2525

2626
public void Apply(ActionModel action)
2727
{
28-
ArgumentGuard.NotNull(action, nameof(action));
28+
ArgumentGuard.NotNull(action);
2929

3030
JsonApiEndpoint? endpoint = _endpointResolver.Get(action.ActionMethod);
3131

src/JsonApiDotNetCore.OpenApi/ParameterInfoExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ internal static class ParameterInfoExtensions
1212

1313
public static ParameterInfo WithName(this ParameterInfo source, string name)
1414
{
15-
ArgumentGuard.NotNull(source, nameof(source));
16-
ArgumentGuard.NotNullNorEmpty(name, nameof(name));
15+
ArgumentGuard.NotNull(source);
16+
ArgumentGuard.NotNullNorEmpty(name);
1717

1818
var cloned = (ParameterInfo)source.MemberwiseClone();
1919
NameField.Value.SetValue(cloned, name);
@@ -23,8 +23,8 @@ public static ParameterInfo WithName(this ParameterInfo source, string name)
2323

2424
public static ParameterInfo WithParameterType(this ParameterInfo source, Type parameterType)
2525
{
26-
ArgumentGuard.NotNull(source, nameof(source));
27-
ArgumentGuard.NotNull(parameterType, nameof(parameterType));
26+
ArgumentGuard.NotNull(source);
27+
ArgumentGuard.NotNull(parameterType);
2828

2929
var cloned = (ParameterInfo)source.MemberwiseClone();
3030
ParameterTypeField.Value.SetValue(cloned, parameterType);

src/JsonApiDotNetCore.OpenApi/ServiceCollectionExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ public static class ServiceCollectionExtensions
1818
/// </summary>
1919
public static void AddOpenApi(this IServiceCollection services, IMvcCoreBuilder mvcBuilder, Action<SwaggerGenOptions>? setupSwaggerGenAction = null)
2020
{
21-
ArgumentGuard.NotNull(services, nameof(services));
22-
ArgumentGuard.NotNull(mvcBuilder, nameof(mvcBuilder));
21+
ArgumentGuard.NotNull(services);
22+
ArgumentGuard.NotNull(mvcBuilder);
2323

2424
AddCustomApiExplorer(services, mvcBuilder);
2525

src/JsonApiDotNetCore.OpenApi/SwaggerComponents/CachingSwaggerGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ internal sealed class CachingSwaggerGenerator : ISwaggerProvider
1818

1919
public CachingSwaggerGenerator(SwaggerGenerator defaultSwaggerGenerator)
2020
{
21-
ArgumentGuard.NotNull(defaultSwaggerGenerator, nameof(defaultSwaggerGenerator));
21+
ArgumentGuard.NotNull(defaultSwaggerGenerator);
2222
_defaultSwaggerGenerator = defaultSwaggerGenerator;
2323
}
2424

2525
public OpenApiDocument GetSwagger(string documentName, string? host = null, string? basePath = null)
2626
{
27-
ArgumentGuard.NotNullNorEmpty(documentName, nameof(documentName));
27+
ArgumentGuard.NotNullNorEmpty(documentName);
2828

2929
string cacheKey = $"{documentName}#{host}#{basePath}";
3030

0 commit comments

Comments
 (0)