Skip to content

Commit bd31216

Browse files
committed
Simplify expressions
1 parent 41d6d67 commit bd31216

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/JsonApiDotNetCore.OpenApi.Client/JsonApiClient.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,9 @@ private void AssertRequiredAttributesHaveNonDefaultValues(object attributesObjec
280280

281281
private static void AssertPropertyHasNonDefaultValueIfRequired(object attributesObject, PropertyInfo propertyInfo, string jsonPath)
282282
{
283-
JsonPropertyAttribute jsonProperty = propertyInfo.GetCustomAttributes<JsonPropertyAttribute>().Single();
283+
var jsonProperty = propertyInfo.GetCustomAttribute<JsonPropertyAttribute>();
284284

285-
if (jsonProperty.Required is Required.Always or Required.AllowNull)
285+
if (jsonProperty is { Required: Required.Always or Required.AllowNull })
286286
{
287287
bool propertyHasDefaultValue = PropertyHasDefaultValue(propertyInfo, attributesObject);
288288

@@ -311,8 +311,7 @@ private static bool PropertyHasDefaultValue(PropertyInfo propertyInfo, object in
311311
/// <summary>
312312
/// Corrects the <see cref="NullValueHandling" /> and <see cref="DefaultValueHandling" /> JSON annotations at runtime, which appear on the auto-generated
313313
/// properties for JSON:API attributes. For example:
314-
/// <code>
315-
/// <![CDATA[
314+
/// <code><![CDATA[
316315
/// [Newtonsoft.Json.JsonProperty("firstName", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
317316
/// ]]>
318317
/// </code>

src/JsonApiDotNetCore.OpenApi/ActionDescriptorExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static MethodInfo GetActionMethod(this ActionDescriptor descriptor)
2121
ArgumentGuard.NotNull(descriptor);
2222

2323
IFilterMetadata? filterMetadata = descriptor.FilterDescriptors.Select(filterDescriptor => filterDescriptor.Filter)
24-
.FirstOrDefault(filter => filter is TFilterMetaData);
24+
.OfType<TFilterMetaData>().FirstOrDefault();
2525

2626
return (TFilterMetaData?)filterMetadata;
2727
}

0 commit comments

Comments
 (0)