public ExtensionMethodGroupExpression LookupExtensionMethod(Type extensionType, string name, SourceSpan location) { var openExtendedType = TypeManager.DropGenericTypeArguments(extensionType); var extendingTypes = _languageContext.DefaultBinderState.Binder.GetExtensionTypes(openExtendedType); var members = ( from extendingType in extendingTypes where IsTypeVisible(extendingType) let memberCache = TypeHandle.GetMemberCache(extendingType) from MemberInfo method in memberCache.FindExtensionMethods( thisAssembly: extensionType.Assembly, extensionType: openExtendedType, name: name, publicOnly: true) select method ).ToArray(); if (members.Length == 0) { return(null); } return(new ExtensionMethodGroupExpression( members, extensionType, location)); }
/// /// Looks for extension method in this namespace /// public ArrayList LookupExtensionMethod(Type extensionType, ClassOrStruct currentClass, string name) { ArrayList found = null; if (declspaces != null) { IEnumerator e = declspaces.Values.GetEnumerator(); e.Reset(); while (e.MoveNext()) { Class c = e.Current as Class; if (c == null) { continue; } if (!c.IsStaticClass) { continue; } ArrayList res = c.MemberCache.FindExtensionMethods(extensionType, name, c != currentClass); if (res == null) { continue; } if (found == null) { found = res; } else { found.AddRange(res); } } } if (external_exmethod_classes == null) { return(found); } foreach (Type t in external_exmethod_classes) { MemberCache m = TypeHandle.GetMemberCache(t); ArrayList res = m.FindExtensionMethods(extensionType, name, true); if (res == null) { continue; } if (found == null) { found = res; } else { found.AddRange(res); } } return(found); }