From 3b6c6b5bc6a10a84866f063b91c19f4f737bf3c5 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Fri, 20 Dec 2024 23:08:22 +1100 Subject: [PATCH] Update NullabilityInfoExtensions.cs --- .../Nullability/NullabilityInfoExtensions.cs | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Polyfill/Nullability/NullabilityInfoExtensions.cs b/src/Polyfill/Nullability/NullabilityInfoExtensions.cs index 5f96427e..784737c4 100644 --- a/src/Polyfill/Nullability/NullabilityInfoExtensions.cs +++ b/src/Polyfill/Nullability/NullabilityInfoExtensions.cs @@ -102,11 +102,13 @@ public static bool IsNullable(this PropertyInfo info) } public static NullabilityInfo GetNullabilityInfo(this ParameterInfo info) => - parameterCache.GetOrAdd(info, static inner => - { - var context = new NullabilityInfoContext(); - return context.Create(inner); - }); + parameterCache.GetOrAdd( + info, + static inner => + { + var context = new NullabilityInfoContext(); + return context.Create(inner); + }); public static NullabilityState GetNullability(this ParameterInfo info) => GetReadOrWriteState(info.GetNullabilityInfo()); @@ -129,16 +131,16 @@ static NullabilityState GetReadOrWriteState(NullabilityInfo nullability) static NullabilityState GetKnownState(string name, NullabilityInfo nullability) { - var readState = nullability.ReadState; - if (readState != NullabilityState.Unknown) + var read = nullability.ReadState; + if (read != NullabilityState.Unknown) { - return readState; + return read; } - var writeState = nullability.WriteState; - if (writeState != NullabilityState.Unknown) + var write = nullability.WriteState; + if (write != NullabilityState.Unknown) { - return writeState; + return write; } throw new($"The nullability of '{nullability.Type.FullName}.{name}' is unknown. Assembly: {nullability.Type.Assembly.FullName}.");