Skip to content

Commit 74e204d

Browse files
committed
chore: fix nullable annotation of AssertHasValue
1 parent 587ebac commit 74e204d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/BenchmarkDotNet/Characteristics/CharacteristicHelper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ internal static bool IsCharacteristicObjectSubclass(Type type) =>
1919
private static bool IsCharacteristicSubclass(Type type) =>
2020
type.GetTypeInfo().IsSubclassOf(typeof(Characteristic));
2121

22-
private static Characteristic AssertHasValue(MemberInfo member, Characteristic value)
22+
private static Characteristic AssertHasValue(MemberInfo member, Characteristic? value)
2323
{
2424
if (member?.DeclaringType == null)
2525
throw new NullReferenceException($"{nameof(member.DeclaringType)}");
@@ -56,12 +56,12 @@ private static IReadOnlyList<Characteristic> GetThisTypeCharacteristicsCore(
5656
var fieldValues = characteristicObjectType.GetTypeInfo()
5757
.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy | BindingFlags.Static)
5858
.Where(f => IsCharacteristicSubclass(f.FieldType))
59-
.Select(f => AssertHasValue(f, (Characteristic)f.GetValue(null)!));
59+
.Select(f => AssertHasValue(f, (Characteristic?)f.GetValue(null)));
6060

6161
var propertyValues = characteristicObjectType.GetTypeInfo()
6262
.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy | BindingFlags.Static)
6363
.Where(p => p.GetMethod != null && IsCharacteristicSubclass(p.PropertyType))
64-
.Select(p => AssertHasValue(p, (Characteristic)p.GetValue(null)!));
64+
.Select(p => AssertHasValue(p, (Characteristic?)p.GetValue(null)));
6565

6666
// DONTTOUCH: DO NOT change the order of characteristic as it may break logic of some operations.
6767
return fieldValues

0 commit comments

Comments
 (0)