As<> Implicit Explicit convertion breaks if multiple methods with the same parameter exists
reflection-emit opened this issue · comments
Reflection Emit commented
Use this instead
public static MethodInfo GetImplicitOrExplicit(this Type type, Type resultType)
{
var result = resultType.GetMethods(BindingFlags.Static | BindingFlags.Public)
.FirstOrDefault(x => (x.Name == "op_Implicit" || x.Name == "op_Explicit") && x.ReturnType == resultType && x.GetParameters()[0].ParameterType == type);
if (result == null)
return type.GetMethods(BindingFlags.Static | BindingFlags.Public)
.FirstOrDefault(x => (x.Name == "op_Implicit" || x.Name == "op_Explicit") && x.ReturnType == resultType && x.GetParameters()[0].ParameterType == type);
return result;
}
Reflection Emit commented
fixed