Skip to content

Commit 58074c6

Browse files
committed
Fixing dynamic parameterised method call translation
1 parent d8e14ce commit 58074c6

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

ReadableExpressions/Translators/BclMethodInfoWrapper.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,16 @@ public BclMethodInfoWrapper(MethodInfo method, Type[] genericArguments = null)
2727

2828
public MethodInfo GetGenericMethodDefinition() => _method.GetGenericMethodDefinition();
2929

30-
public IEnumerable<Type> GetGenericArguments() => GetGenericArgumentsArray();
31-
32-
private Type[] GetGenericArgumentsArray() =>
30+
public IEnumerable<Type> GetGenericArguments() =>
3331
(_genericArguments ?? (_genericArguments = _method.GetGenericArguments()));
3432

3533
public IEnumerable<ParameterInfo> GetParameters() => _method.GetParameters();
3634

3735
public Type GetGenericArgumentFor(Type parameterType)
3836
{
39-
var genericArguments = GetGenericArgumentsArray();
40-
var parameterIndex = Array.IndexOf(genericArguments, parameterType, 0);
37+
var parameterIndex = Array.IndexOf(_method.GetGenericArguments(), parameterType, 0);
4138

42-
return genericArguments[parameterIndex];
39+
return _genericArguments[parameterIndex];
4340
}
4441
}
4542
}

ReadableExpressions/Translators/Formatting/ParameterSet.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ private static bool IsNotFuncType(ParameterInfo parameter, IMethodInfo method)
138138
parameterType = method.GetGenericArgumentFor(parameter.ParameterType);
139139
}
140140

141-
return !(parameterType.FullName.StartsWith("System.Action", StringComparison.Ordinal) ||
141+
return
142+
!(parameterType.FullName.StartsWith("System.Action", StringComparison.Ordinal) ||
142143
parameterType.FullName.StartsWith("System.Func", StringComparison.Ordinal)) ||
143144
// ReSharper disable once PossibleUnintendedReferenceComparison
144145
(parameter.ParameterType.GetAssembly() != typeof(Action).GetAssembly());

0 commit comments

Comments
 (0)