From 334593dc4f7e80dbcfbc8acbe45860a9b74cefc6 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 7 Oct 2023 22:48:40 +1100 Subject: [PATCH] Update VerifierSettings.cs --- src/Verify/Naming/VerifierSettings.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Verify/Naming/VerifierSettings.cs b/src/Verify/Naming/VerifierSettings.cs index 31f99c91a7..68c5512b7e 100644 --- a/src/Verify/Naming/VerifierSettings.cs +++ b/src/Verify/Naming/VerifierSettings.cs @@ -54,11 +54,13 @@ static void GetNameForParameter(object? parameter, StringBuilder builder, bool i return; } - foreach (var parameterToName in parameterToNameLookup) + var type = parameter.GetType(); + + foreach (var (key, value) in parameterToNameLookup) { - if (parameterToName.Key.IsInstanceOfType(parameter)) + if (key.IsAssignableFrom(type)) { - builder.Append(parameterToName.Value(parameter)); + builder.Append(value(parameter)); return; } } @@ -90,7 +92,6 @@ static void GetNameForParameter(object? parameter, StringBuilder builder, bool i return; } - var type = parameter.GetType(); if (type.IsGeneric(typeof(KeyValuePair<,>))) { var keyMember = type.GetProperty("Key")!.GetMethod!.Invoke(parameter, null);