internal static bool RefersToGenericParameterCLRSemantics(Type ReferringType, Type Typ) { if (ReferringType.IsByRef) { ReferringType = Symbols.GetElementType(ReferringType); } if (Symbols.IsGenericParameter(ReferringType)) { if (ReferringType.DeclaringType == Typ) { return(true); } } else if (Symbols.IsGeneric(ReferringType)) { Type[] typeArguments = Symbols.GetTypeArguments(ReferringType); int index = 0; while (index < typeArguments.Length) { if (Symbols.RefersToGenericParameterCLRSemantics(typeArguments[index], Typ)) { return(true); } checked { ++index; } } } else if (Symbols.IsArrayType(ReferringType)) { return(Symbols.RefersToGenericParameterCLRSemantics(ReferringType.GetElementType(), Typ)); } return(false); }
internal static int IndexIn(Type PossibleGenericParameter, MethodBase GenericMethodDef) { if (Symbols.IsGenericParameter(PossibleGenericParameter) && PossibleGenericParameter.DeclaringMethod != null && Symbols.AreGenericMethodDefsEqual(PossibleGenericParameter.DeclaringMethod, GenericMethodDef)) { return(PossibleGenericParameter.GenericParameterPosition); } return(-1); }
internal MemberInfo[] LookupNamedMembers(string MemberName) { MemberInfo[] Members; if (Symbols.IsGenericParameter(this.m_Type)) { Type classConstraint = Symbols.GetClassConstraint(this.m_Type); Members = classConstraint == null ? (MemberInfo[])null : classConstraint.GetMember(MemberName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy); } else { Members = this.m_IReflect.GetMember(MemberName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy); } MemberInfo[] memberInfoArray = Symbols.Container.FilterInvalidMembers(Members); if (memberInfoArray == null) { memberInfoArray = Symbols.Container.NoMembers; } else if (memberInfoArray.Length > 1) { Array.Sort((Array)memberInfoArray, (IComparer)Symbols.Container.InheritanceSorter.Instance); } return(memberInfoArray); }
internal static bool RefersToGenericParameter(Type ReferringType, MethodBase Method) { if (!Symbols.IsRawGeneric(Method)) { return(false); } if (ReferringType.IsByRef) { ReferringType = Symbols.GetElementType(ReferringType); } if (Symbols.IsGenericParameter(ReferringType)) { if (Symbols.AreGenericMethodDefsEqual(ReferringType.DeclaringMethod, Method)) { return(true); } } else if (Symbols.IsGeneric(ReferringType)) { Type[] typeArguments = Symbols.GetTypeArguments(ReferringType); int index = 0; while (index < typeArguments.Length) { if (Symbols.RefersToGenericParameter(typeArguments[index], Method)) { return(true); } checked { ++index; } } } else if (Symbols.IsArrayType(ReferringType)) { return(Symbols.RefersToGenericParameter(ReferringType.GetElementType(), Method)); } return(false); }
internal static string VBFriendlyNameOfType(Type typ, bool FullName = false) { string suffixAndElementType = Utils.GetArraySuffixAndElementType(ref typ); string str1; switch (!typ.IsEnum ? Type.GetTypeCode(typ) : TypeCode.Object) { case TypeCode.DBNull: str1 = "DBNull"; break; case TypeCode.Boolean: str1 = "Boolean"; break; case TypeCode.Char: str1 = "Char"; break; case TypeCode.SByte: str1 = "SByte"; break; case TypeCode.Byte: str1 = "Byte"; break; case TypeCode.Int16: str1 = "Short"; break; case TypeCode.UInt16: str1 = "UShort"; break; case TypeCode.Int32: str1 = "Integer"; break; case TypeCode.UInt32: str1 = "UInteger"; break; case TypeCode.Int64: str1 = "Long"; break; case TypeCode.UInt64: str1 = "ULong"; break; case TypeCode.Single: str1 = "Single"; break; case TypeCode.Double: str1 = "Double"; break; case TypeCode.Decimal: str1 = "Decimal"; break; case TypeCode.DateTime: str1 = "Date"; break; case TypeCode.String: str1 = "String"; break; default: if (Symbols.IsGenericParameter(typ)) { str1 = typ.Name; break; } string str2 = (string)null; string genericArgsSuffix = Utils.GetGenericArgsSuffix(typ); string str3; if (FullName) { if (typ.IsNested) { str2 = Utils.VBFriendlyNameOfType(typ.DeclaringType, true); str3 = typ.Name; } else { str3 = typ.FullName; } } else { str3 = typ.Name; } if (genericArgsSuffix != null) { int length = str3.LastIndexOf('`'); if (length != -1) { str3 = str3.Substring(0, length); } str1 = str3 + genericArgsSuffix; } else { str1 = str3; } if (str2 != null) { str1 = str2 + "." + str1; break; } break; } if (suffixAndElementType != null) { str1 += suffixAndElementType; } return(str1); }