private static MethodDesc FindMatchingVirtualMethodOnTypeByNameAndSig(MethodDesc targetMethod, DefType currentType)
        {
            string          name = targetMethod.Name;
            MethodSignature sig  = targetMethod.Signature;

            // TODO: InstantiatedType.GetMethod can't handle this for a situation like
            // an instantiation of Foo<T>.M(T) because sig is instantiated, but it compares
            // it to the uninstantiated version
            //MethodDesc implMethod = currentType.GetMethod(name, sig);
            MethodDesc implMethod = null;

            foreach (MethodDesc candidate in currentType.GetMethods())
            {
                if (candidate.Name == name)
                {
                    if (candidate.Signature.Equals(sig))
                    {
                        if (implMethod != null)
                        {
                            throw new NotImplementedException("NYI: differentiating between overloads on instantiations when the instantiated signatures match.");
                        }
                        implMethod = candidate;
                    }
                }
            }

            // Only find virtual methods
            if ((implMethod != null) && !implMethod.IsVirtual)
            {
                implMethod = null;
            }

            return(implMethod);
        }
Exemplo n.º 2
0
 public override IEnumerable <MethodDesc> GetMethods()
 {
     foreach (var method in _rawCanonType.GetMethods())
     {
         yield return(Context.GetMethodForRuntimeDeterminedType(method.GetTypicalMethodDefinition(), this));
     }
 }