Пример #1
0
 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);
 }
Пример #2
0
        internal static bool IsGeneric(MemberInfo Member)
        {
            MethodBase Method = Member as MethodBase;

            if (Method == null)
            {
                return(false);
            }
            return(Symbols.IsGeneric(Method));
        }
Пример #3
0
 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);
 }
Пример #4
0
        /// <summary>Returns a Visual Basic method signature.</summary>
        /// <param name="Method">A <see cref="T:System.Reflection.MethodBase" /> object to return a Visual Basic method signature for.</param>
        /// <returns>The Visual Basic method signature for the supplied <see cref="T:System.Reflection.MethodBase" /> object.</returns>
        public static string MethodToString(MethodBase Method)
        {
            Type   typ1 = (Type)null;
            string str1 = "";

            if (Method.MemberType == MemberTypes.Method)
            {
                typ1 = ((MethodInfo)Method).ReturnType;
            }
            if (Method.IsPublic)
            {
                str1 += "Public ";
            }
            else if (Method.IsPrivate)
            {
                str1 += "Private ";
            }
            else if (Method.IsAssembly)
            {
                str1 += "Friend ";
            }
            if ((Method.Attributes & MethodAttributes.Virtual) != MethodAttributes.PrivateScope)
            {
                if (!Method.DeclaringType.IsInterface)
                {
                    str1 += "Overrides ";
                }
            }
            else if (Symbols.IsShared((MemberInfo)Method))
            {
                str1 += "Shared ";
            }
            Symbols.UserDefinedOperator userDefinedOperator = Symbols.UserDefinedOperator.UNDEF;
            if (Symbols.IsUserDefinedOperator(Method))
            {
                userDefinedOperator = Symbols.MapToUserDefinedOperator(Method);
            }
            string str2;

            switch (userDefinedOperator)
            {
            case Symbols.UserDefinedOperator.UNDEF:
                str2 = typ1 == null || typ1 == Utils.VoidType ? str1 + "Sub " : str1 + "Function ";
                break;

            case Symbols.UserDefinedOperator.Narrow:
                str1 += "Narrowing ";
                goto default;

            case Symbols.UserDefinedOperator.Widen:
                str1 += "Widening ";
                goto default;

            default:
                str2 = str1 + "Operator ";
                break;
            }
            string str3 = userDefinedOperator == Symbols.UserDefinedOperator.UNDEF ? (Method.MemberType != MemberTypes.Constructor ? str2 + Method.Name : str2 + "New") : str2 + Symbols.OperatorNames[(int)userDefinedOperator];

            if (Symbols.IsGeneric(Method))
            {
                string str4           = str3 + "(Of ";
                bool   flag           = true;
                Type[] typeParameters = Symbols.GetTypeParameters((MemberInfo)Method);
                int    index          = 0;
                while (index < typeParameters.Length)
                {
                    Type typ2 = typeParameters[index];
                    if (!flag)
                    {
                        str4 += ", ";
                    }
                    else
                    {
                        flag = false;
                    }
                    str4 += Utils.VBFriendlyNameOfType(typ2, false);
                    checked { ++index; }
                }
                str3 = str4 + ")";
            }
            string str5  = str3 + "(";
            bool   flag1 = true;

            ParameterInfo[] parameters = Method.GetParameters();
            int             index1     = 0;

            while (index1 < parameters.Length)
            {
                ParameterInfo Parameter = parameters[index1];
                if (!flag1)
                {
                    str5 += ", ";
                }
                else
                {
                    flag1 = false;
                }
                str5 += Utils.ParameterToString(Parameter);
                checked { ++index1; }
            }
            string str6 = str5 + ")";

            if (typ1 != null && typ1 != Utils.VoidType)
            {
                str6 = str6 + " As " + Utils.VBFriendlyNameOfType(typ1, true);
            }
            return(str6);
        }