Esempio n. 1
0
 internal static void ExtractCustomAttributeArgumentType(ITypeUniverse universe, Module module, byte[] customAttributeBlob, ref int index, out System.Reflection.Adds.CorElementType argumentTypeId, out Type argumentType)
 {
     argumentTypeId = SignatureUtil.ExtractElementType(customAttributeBlob, ref index);
     SignatureUtil.VerifyElementType((System.Reflection.Adds.CorElementType)((int)argumentTypeId));
     if ((int)argumentTypeId == 29)
     {
         System.Reflection.Adds.CorElementType corElementType = SignatureUtil.ExtractElementType(customAttributeBlob, ref index);
         SignatureUtil.VerifyElementType(corElementType);
         if (corElementType == (System.Reflection.Adds.CorElementType.Byref | System.Reflection.Adds.CorElementType.Modifier | System.Reflection.Adds.CorElementType.Sentinel | System.Reflection.Adds.CorElementType.ValueType | System.Reflection.Adds.CorElementType.Void | System.Reflection.Adds.CorElementType.Type))
         {
             argumentType = universe.GetBuiltInType(System.Reflection.Adds.CorElementType.Object).MakeArrayType();
             return;
         }
         argumentType = universe.GetBuiltInType(corElementType).MakeArrayType();
         return;
     }
     if ((int)argumentTypeId != 85)
     {
         if ((int)argumentTypeId == 81)
         {
             argumentType = null;
             return;
         }
         argumentType = universe.GetBuiltInType((System.Reflection.Adds.CorElementType)((int)argumentTypeId));
     }
     else
     {
         argumentType = SignatureUtil.ExtractTypeValue(universe, module, customAttributeBlob, ref index);
         if (argumentType == null)
         {
             throw new ArgumentException(MetadataStringTable.InvalidCustomAttributeFormatForEnum);
         }
     }
 }
Esempio n. 2
0
        internal static CustomModifiers ExtractCustomModifiers(byte[] sig, ref int index, MetadataOnlyModule resolver, GenericContext context)
        {
            int num = index;

            System.Reflection.Adds.CorElementType corElementType = SignatureUtil.ExtractElementType(sig, ref index);
            List <Type> types  = null;
            List <Type> types1 = null;

            if (corElementType != System.Reflection.Adds.CorElementType.CModOpt && corElementType != System.Reflection.Adds.CorElementType.CModReqd)
            {
                index = num;
                return(null);
            }
            types  = new List <Type>();
            types1 = new List <Type>();
            while (corElementType == System.Reflection.Adds.CorElementType.CModOpt || corElementType == System.Reflection.Adds.CorElementType.CModReqd)
            {
                Token token = SignatureUtil.ExtractToken(sig, ref index);
                Type  type  = resolver.ResolveTypeTokenInternal(token, context);
                if (corElementType != System.Reflection.Adds.CorElementType.CModOpt)
                {
                    types1.Add(type);
                }
                else
                {
                    types.Add(type);
                }
                num            = index;
                corElementType = SignatureUtil.ExtractElementType(sig, ref index);
            }
            index = num;
            return(new CustomModifiers(types, types1));
        }
        public MetadataOnlyPropertyInfo(MetadataOnlyModule resolver, Token propToken, Type[] typeArgs, Type[] methodArgs)
        {
            int num;
            EmbeddedBlobPointer embeddedBlobPointer;
            int                num1;
            int                num2;
            UnusedIntPtr       unusedIntPtr;
            int                num3;
            PropertyAttributes propertyAttribute;
            Token              token;
            Token              token1;
            Token              token2;
            uint               num4;

            this.m_resolver      = resolver;
            this.m_PropertyToken = propToken;
            this.m_context       = new GenericContext(typeArgs, methodArgs);
            IMetadataImport rawImport     = this.m_resolver.RawImport;
            StringBuilder   stringBuilder = new StringBuilder(256);

            rawImport.GetPropertyProps(this.m_PropertyToken, out this.m_declaringClassToken, null, 0, out num, out propertyAttribute, out embeddedBlobPointer, out num1, out num2, out unusedIntPtr, out num3, out token, out token1, out token2, 1, out num4);
            this.m_attrib          = propertyAttribute;
            stringBuilder.Capacity = num;
            rawImport.GetPropertyProps(this.m_PropertyToken, out this.m_declaringClassToken, stringBuilder, num, out num, out propertyAttribute, out embeddedBlobPointer, out num1, out num2, out unusedIntPtr, out num3, out token, out token1, out token2, 1, out num4);
            this.m_name = stringBuilder.ToString();
            byte[] numArray = this.m_resolver.ReadEmbeddedBlob(embeddedBlobPointer, num1);
            int    num5     = 0;

            SignatureUtil.ExtractCallingConvention(numArray, ref num5);
            SignatureUtil.ExtractInt(numArray, ref num5);
            this.m_propertyType = SignatureUtil.ExtractType(numArray, ref num5, this.m_resolver, this.m_context);
            this.m_setterToken  = token;
            this.m_getterToken  = token1;
        }
Esempio n. 4
0
        protected override Type GetResolvedTypeWorker()
        {
            byte[] blob = this.Blob;
            int    num  = 0;
            Type   type = SignatureUtil.ExtractType(blob, ref num, this.Resolver, this.m_context);

            return(type);
        }
Esempio n. 5
0
 internal static Token ExtractToken(byte[] sig, ref int index)
 {
     unsafe
     {
         uint num = (uint)SignatureUtil.ExtractInt(sig, ref index);
         uint sTkCorEncodeToken = SignatureUtil.s_tkCorEncodeToken[num & 3];
         return(new Token(SignatureUtil.TokenFromRid(num >> 2, sTkCorEncodeToken)));
     }
 }
Esempio n. 6
0
        internal static IList <CustomAttributeTypedArgument> ExtractListOfValues(Type elementType, ITypeUniverse universe, Module module, uint size, byte[] blob, ref int index)
        {
            System.Reflection.Adds.CorElementType typeId = SignatureUtil.GetTypeId(elementType);
            List <CustomAttributeTypedArgument>   customAttributeTypedArguments = new List <CustomAttributeTypedArgument>((int)size);

            if (typeId == System.Reflection.Adds.CorElementType.Object)
            {
                for (int i = 0; (long)i < (ulong)size; i++)
                {
                    System.Reflection.Adds.CorElementType corElementType = SignatureUtil.ExtractElementType(blob, ref index);
                    SignatureUtil.VerifyElementType(corElementType);
                    Type   builtInType = null;
                    object obj         = null;
                    if (corElementType == System.Reflection.Adds.CorElementType.SzArray)
                    {
                        throw new NotImplementedException(MetadataStringTable.ArrayInsideArrayInAttributeNotSupported);
                    }
                    if (corElementType != System.Reflection.Adds.CorElementType.Enum)
                    {
                        builtInType = universe.GetBuiltInType(corElementType);
                        obj         = SignatureUtil.ExtractValue(corElementType, blob, ref index);
                    }
                    else
                    {
                        builtInType = SignatureUtil.ExtractTypeValue(universe, module, blob, ref index);
                        if (builtInType == null)
                        {
                            throw new ArgumentException(MetadataStringTable.InvalidCustomAttributeFormatForEnum);
                        }
                        System.Reflection.Adds.CorElementType typeId1 = SignatureUtil.GetTypeId(MetadataOnlyModule.GetUnderlyingType(builtInType));
                        obj = SignatureUtil.ExtractValue(typeId1, blob, ref index);
                    }
                    customAttributeTypedArguments.Add(new CustomAttributeTypedArgument(builtInType, obj));
                }
            }
            else if (typeId != System.Reflection.Adds.CorElementType.Type)
            {
                if (typeId == System.Reflection.Adds.CorElementType.SzArray)
                {
                    throw new ArgumentException(MetadataStringTable.JaggedArrayInAttributeNotSupported);
                }
                for (int j = 0; (long)j < (ulong)size; j++)
                {
                    object obj1 = SignatureUtil.ExtractValue(typeId, blob, ref index);
                    customAttributeTypedArguments.Add(new CustomAttributeTypedArgument(elementType, obj1));
                }
            }
            else
            {
                for (int k = 0; (long)k < (ulong)size; k++)
                {
                    object obj2 = SignatureUtil.ExtractTypeValue(universe, module, blob, ref index);
                    customAttributeTypedArguments.Add(new CustomAttributeTypedArgument(elementType, obj2));
                }
            }
            return(customAttributeTypedArguments.AsReadOnly());
        }
Esempio n. 7
0
        internal static MethodSignatureDescriptor ExtractMethodSignature(SignatureBlob methodSignatureBlob, MetadataOnlyModule resolver, GenericContext context)
        {
            byte[] signatureAsByteArray = methodSignatureBlob.GetSignatureAsByteArray();
            int    num = 0;
            MethodSignatureDescriptor methodSignatureDescriptor = new MethodSignatureDescriptor()
            {
                ReturnParameter       = new TypeSignatureDescriptor(),
                GenericParameterCount = 0,
                CallingConvention     = SignatureUtil.ExtractCallingConvention(signatureAsByteArray, ref num)
            };
            bool callingConvention = (methodSignatureDescriptor.CallingConvention & Microsoft.MetadataReader.CorCallingConvention.ExplicitThis) != Microsoft.MetadataReader.CorCallingConvention.Default;

            if ((methodSignatureDescriptor.CallingConvention & Microsoft.MetadataReader.CorCallingConvention.Generic) != Microsoft.MetadataReader.CorCallingConvention.Default)
            {
                int num1 = SignatureUtil.ExtractInt(signatureAsByteArray, ref num);
                if (num1 <= 0)
                {
                    CultureInfo invariantCulture         = CultureInfo.InvariantCulture;
                    object[]    invalidMetadataSignature = new object[] { MetadataStringTable.InvalidMetadataSignature, MetadataStringTable.ExpectedPositiveNumberOfGenericParameters };
                    throw new ArgumentException(string.Format(invariantCulture, "{0} {1}", invalidMetadataSignature));
                }
                context = context.VerifyAndUpdateMethodArguments(num1);
                methodSignatureDescriptor.GenericParameterCount = num1;
            }
            int             num2           = SignatureUtil.ExtractInt(signatureAsByteArray, ref num);
            bool            flag           = false;
            CustomModifiers customModifier = SignatureUtil.ExtractCustomModifiers(signatureAsByteArray, ref num, resolver, context);

            methodSignatureDescriptor.ReturnParameter = SignatureUtil.ExtractType(signatureAsByteArray, ref num, resolver, context, flag);
            methodSignatureDescriptor.ReturnParameter.CustomModifiers = customModifier;
            if (callingConvention)
            {
                SignatureUtil.ExtractType(signatureAsByteArray, ref num, resolver, context);
                num2--;
            }
            methodSignatureDescriptor.Parameters = new TypeSignatureDescriptor[num2];
            for (int i = 0; i < num2; i++)
            {
                customModifier = SignatureUtil.ExtractCustomModifiers(signatureAsByteArray, ref num, resolver, context);
                methodSignatureDescriptor.Parameters[i] = SignatureUtil.ExtractType(signatureAsByteArray, ref num, resolver, context, flag);
                methodSignatureDescriptor.Parameters[i].CustomModifiers = customModifier;
            }
            if (num != (int)signatureAsByteArray.Length)
            {
                CultureInfo cultureInfo = CultureInfo.InvariantCulture;
                object[]    objArray    = new object[] { MetadataStringTable.InvalidMetadataSignature, MetadataStringTable.ExtraInformationAfterLastParameter };
                throw new ArgumentException(string.Format(cultureInfo, "{0} {1}", objArray));
            }
            return(methodSignatureDescriptor);
        }
Esempio n. 8
0
        internal static CallingConventions GetReflectionCallingConvention(Microsoft.MetadataReader.CorCallingConvention callConvention)
        {
            CallingConventions callingConvention = (CallingConventions)0;

            if ((callConvention & Microsoft.MetadataReader.CorCallingConvention.Mask) == Microsoft.MetadataReader.CorCallingConvention.HasThis)
            {
                callingConvention = callingConvention | CallingConventions.HasThis;
            }
            else if ((callConvention & Microsoft.MetadataReader.CorCallingConvention.Mask) == Microsoft.MetadataReader.CorCallingConvention.ExplicitThis)
            {
                callingConvention = callingConvention | CallingConventions.ExplicitThis;
            }
            callingConvention = (!SignatureUtil.IsVarArg(callConvention) ? callingConvention | CallingConventions.Standard : callingConvention | CallingConventions.VarArgs);
            return(callingConvention);
        }
Esempio n. 9
0
        internal static NamedArgumentType ExtractNamedArgumentType(byte[] customAttributeBlob, ref int index)
        {
            byte num = (byte)SignatureUtil.ExtractValue(System.Reflection.Adds.CorElementType.Byte, customAttributeBlob, ref index);

            if (num == 84)
            {
                return(NamedArgumentType.Property);
            }
            if (num != 83)
            {
                CultureInfo invariantCulture             = CultureInfo.InvariantCulture;
                object[]    invalidCustomAttributeFormat = new object[] { MetadataStringTable.InvalidCustomAttributeFormat, MetadataStringTable.ExpectedPropertyOrFieldId };
                throw new ArgumentException(string.Format(invariantCulture, "{0} {1}", invalidCustomAttributeFormat));
            }
            return(NamedArgumentType.Field);
        }
Esempio n. 10
0
        public static IEnumerable <MethodBase> FilterConstructors(MethodFilter filter, ConstructorInfo[] allConstructors)
        {
            List <MethodBase>  methodBases = new List <MethodBase>();
            CallingConventions reflectionCallingConvention = SignatureUtil.GetReflectionCallingConvention(filter.CallingConvention);

            ConstructorInfo[] constructorInfoArray = allConstructors;
            for (int i = 0; i < (int)constructorInfoArray.Length; i++)
            {
                ConstructorInfo constructorInfo = constructorInfoArray[i];
                if (constructorInfo.Name.Equals(filter.Name, StringComparison.Ordinal) && SignatureUtil.IsCallingConventionMatch(constructorInfo, reflectionCallingConvention) && (int)constructorInfo.GetParameters().Length == filter.ParameterCount)
                {
                    methodBases.Add(constructorInfo);
                }
            }
            return(methodBases);
        }
Esempio n. 11
0
        public static IEnumerable <MethodBase> FilterMethods(MethodFilter filter, MethodInfo[] allMethods)
        {
            List <MethodBase>  methodBases = new List <MethodBase>();
            CallingConventions reflectionCallingConvention = SignatureUtil.GetReflectionCallingConvention(filter.CallingConvention);

            MethodInfo[] methodInfoArray = allMethods;
            for (int i = 0; i < (int)methodInfoArray.Length; i++)
            {
                MethodInfo methodInfo = methodInfoArray[i];
                if (methodInfo.Name.Equals(filter.Name, StringComparison.Ordinal) && SignatureUtil.IsCallingConventionMatch(methodInfo, reflectionCallingConvention) && SignatureUtil.IsGenericParametersCountMatch(methodInfo, filter.GenericParameterCount) && (int)methodInfo.GetParameters().Length == filter.ParameterCount)
                {
                    methodBases.Add(methodInfo);
                }
            }
            return(methodBases);
        }
Esempio n. 12
0
        internal static Type ExtractTypeValue(ITypeUniverse universe, Module module, byte[] blob, ref int index)
        {
            Type   type = null;
            string str  = SignatureUtil.ExtractStringValue(blob, ref index);

            if (!string.IsNullOrEmpty(str))
            {
                type = System.Reflection.Adds.TypeNameParser.ParseTypeName(universe, module, str, false);
                if (type == null)
                {
                    module = universe.GetSystemAssembly().ManifestModule;
                    type   = System.Reflection.Adds.TypeNameParser.ParseTypeName(universe, module, str);
                }
            }
            return(type);
        }
Esempio n. 13
0
        public MetadataOnlyFieldInfo(MetadataOnlyModule resolver, Token fieldDefToken, Type[] typeArgs, Type[] methodArgs)
        {
            int num;
            EmbeddedBlobPointer embeddedBlobPointer;
            int             num1;
            int             num2;
            IntPtr          intPtr;
            int             num3;
            FieldAttributes fieldAttribute;

            this.m_resolver      = resolver;
            this.m_fieldDefToken = fieldDefToken;
            if (typeArgs != null || methodArgs != null)
            {
                this.m_context = new GenericContext(typeArgs, methodArgs);
            }
            IMetadataImport rawImport     = this.m_resolver.RawImport;
            StringBuilder   stringBuilder = new StringBuilder(256);

            rawImport.GetFieldProps(this.m_fieldDefToken, out this.m_declaringClassToken, null, 0, out num, out fieldAttribute, out embeddedBlobPointer, out num1, out num2, out intPtr, out num3);
            this.m_attrib          = fieldAttribute;
            stringBuilder.Capacity = num;
            rawImport.GetFieldProps(this.m_fieldDefToken, out this.m_declaringClassToken, stringBuilder, num, out num, out fieldAttribute, out embeddedBlobPointer, out num1, out num2, out intPtr, out num3);
            this.m_attrib = fieldAttribute;
            this.m_name   = stringBuilder.ToString();
            byte[] numArray = this.m_resolver.ReadEmbeddedBlob(embeddedBlobPointer, num1);
            int    num4     = 0;

            SignatureUtil.ExtractCallingConvention(numArray, ref num4);
            this.m_customModifiers = SignatureUtil.ExtractCustomModifiers(numArray, ref num4, this.m_resolver, this.m_context);
            if (this.m_resolver.RawImport.IsValidToken((uint)this.m_declaringClassToken))
            {
                Type type = this.m_resolver.ResolveType(this.m_declaringClassToken);
                if (type.IsGenericType && (this.m_context == null || this.m_context.TypeArgs == null || (int)this.m_context.TypeArgs.Length == 0))
                {
                    if (this.m_context != null)
                    {
                        this.m_context = new GenericContext(type.GetGenericArguments(), this.m_context.MethodArgs);
                    }
                    else
                    {
                        this.m_context = new GenericContext(type.GetGenericArguments(), null);
                    }
                }
            }
            this.m_fieldType = SignatureUtil.ExtractType(numArray, ref num4, this.m_resolver, this.m_context);
        }
Esempio n. 14
0
 internal static System.Reflection.Adds.CorElementType GetTypeId(Type type)
 {
     System.Reflection.Adds.CorElementType corElementType;
     if (type.IsEnum)
     {
         return(SignatureUtil.GetTypeId(MetadataOnlyModule.GetUnderlyingType(type)));
     }
     if (type.IsArray)
     {
         return(System.Reflection.Adds.CorElementType.SzArray);
     }
     if (!SignatureUtil.TypeMapForAttributes.LookupPrimitive(type, out corElementType))
     {
         throw new ArgumentException(MetadataStringTable.UnsupportedTypeInAttributeSignature);
     }
     return(corElementType);
 }
Esempio n. 15
0
        public override MemberInfo[] GetMember(string name, MemberTypes type, BindingFlags bindingAttr)
        {
            MemberInfo[]      members          = this.GetMembers(bindingAttr);
            List <MemberInfo> memberInfos      = new List <MemberInfo>();
            StringComparison  stringComparison = SignatureUtil.GetStringComparison(bindingAttr);

            MemberInfo[] memberInfoArray = members;
            for (int i = 0; i < (int)memberInfoArray.Length; i++)
            {
                MemberInfo memberInfo = memberInfoArray[i];
                if (name.Equals(memberInfo.Name, stringComparison) && (type == memberInfo.MemberType || type == MemberTypes.All))
                {
                    memberInfos.Add(memberInfo);
                }
            }
            return(memberInfos.ToArray());
        }
Esempio n. 16
0
        public override EventInfo GetEvent(string name, BindingFlags flags)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            StringComparison stringComparison = SignatureUtil.GetStringComparison(flags);

            EventInfo[] events = this.GetEvents(flags);
            for (int i = 0; i < (int)events.Length; i++)
            {
                EventInfo eventInfo = events[i];
                if (eventInfo.Name.Equals(name, stringComparison))
                {
                    return(eventInfo);
                }
            }
            return(null);
        }
Esempio n. 17
0
        public override Type GetNestedType(string name, BindingFlags bindingAttr)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            StringComparison stringComparison = SignatureUtil.GetStringComparison(bindingAttr);

            Type[] nestedTypes = this.GetNestedTypes(bindingAttr);
            for (int i = 0; i < (int)nestedTypes.Length; i++)
            {
                Type type = nestedTypes[i];
                if (type.Name.Equals(name, stringComparison))
                {
                    return(type);
                }
            }
            return(null);
        }
Esempio n. 18
0
        public override FieldInfo GetField(string name, BindingFlags bindingAttr)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            StringComparison stringComparison = SignatureUtil.GetStringComparison(bindingAttr);

            FieldInfo[] fields = this.GetFields(bindingAttr);
            for (int i = 0; i < (int)fields.Length; i++)
            {
                FieldInfo fieldInfo = fields[i];
                if (fieldInfo.Name.Equals(name, stringComparison))
                {
                    return(fieldInfo);
                }
            }
            return(null);
        }
Esempio n. 19
0
        private void Initialize()
        {
            Type type = null;

            Type[] mTypeArgs = null;
            if (this.m_declaringTypeDef.IsNil)
            {
                mTypeArgs = this.m_typeArgs;
            }
            else
            {
                this.GetOwnerTypeAndTypeArgs(out type, out mTypeArgs);
            }
            GenericContext            genericContext            = new GenericContext(mTypeArgs, this.GetGenericMethodArgs());
            MethodSignatureDescriptor methodSignatureDescriptor = SignatureUtil.ExtractMethodSignature(this.m_sigBlob, this.m_resolver, genericContext);

            this.m_tOwner           = type;
            this.m_context          = genericContext;
            this.m_descriptor       = methodSignatureDescriptor;
            this.m_fullyInitialized = true;
        }
Esempio n. 20
0
        internal static PropertyInfo GetPropertyImplHelper(MetadataOnlyCommonType type, string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
        {
            if (binder != null)
            {
                throw new NotSupportedException();
            }
            if (modifiers != null && (int)modifiers.Length != 0)
            {
                throw new NotSupportedException();
            }
            StringComparison stringComparison = SignatureUtil.GetStringComparison(bindingAttr);

            PropertyInfo[] properties = type.GetProperties(bindingAttr);
            for (int i = 0; i < (int)properties.Length; i++)
            {
                PropertyInfo propertyInfo = properties[i];
                if (propertyInfo.Name.Equals(name, stringComparison) && (!(returnType != null) || propertyInfo.PropertyType.Equals(returnType)) && MetadataOnlyTypeDef.PropertyParamTypesMatch(propertyInfo, types))
                {
                    return(propertyInfo);
                }
            }
            return(null);
        }
Esempio n. 21
0
        internal static object ExtractValue(System.Reflection.Adds.CorElementType typeId, byte[] blob, ref int index)
        {
            object flag;

            switch (typeId)
            {
            case System.Reflection.Adds.CorElementType.Bool:
            {
                flag  = BitConverter.ToBoolean(blob, index);
                index = index + 1;
                return(flag);
            }

            case System.Reflection.Adds.CorElementType.Char:
            {
                flag  = BitConverter.ToChar(blob, index);
                index = index + 2;
                return(flag);
            }

            case System.Reflection.Adds.CorElementType.SByte:
            {
                flag  = (sbyte)blob[index];
                index = index + 1;
                return(flag);
            }

            case System.Reflection.Adds.CorElementType.Byte:
            {
                flag  = blob[index];
                index = index + 1;
                return(flag);
            }

            case System.Reflection.Adds.CorElementType.Short:
            {
                flag  = BitConverter.ToInt16(blob, index);
                index = index + 2;
                return(flag);
            }

            case System.Reflection.Adds.CorElementType.UShort:
            {
                flag  = BitConverter.ToUInt16(blob, index);
                index = index + 2;
                return(flag);
            }

            case System.Reflection.Adds.CorElementType.Int:
            {
                flag  = BitConverter.ToInt32(blob, index);
                index = index + 4;
                return(flag);
            }

            case System.Reflection.Adds.CorElementType.UInt:
            {
                flag  = BitConverter.ToUInt32(blob, index);
                index = index + 4;
                return(flag);
            }

            case System.Reflection.Adds.CorElementType.Long:
            {
                flag  = BitConverter.ToInt64(blob, index);
                index = index + 8;
                return(flag);
            }

            case System.Reflection.Adds.CorElementType.ULong:
            {
                flag  = BitConverter.ToUInt64(blob, index);
                index = index + 8;
                return(flag);
            }

            case System.Reflection.Adds.CorElementType.Float:
            {
                flag  = BitConverter.ToSingle(blob, index);
                index = index + 4;
                return(flag);
            }

            case System.Reflection.Adds.CorElementType.Double:
            {
                flag  = BitConverter.ToDouble(blob, index);
                index = index + 8;
                return(flag);
            }

            case System.Reflection.Adds.CorElementType.String:
            {
                if (blob[index] != 255)
                {
                    int num = SignatureUtil.ExtractInt(blob, ref index);
                    flag  = Encoding.UTF8.GetString(blob, index, num);
                    index = index + num;
                }
                else
                {
                    index = index + 1;
                    flag  = null;
                }
                return(flag);
            }
            }
            throw new InvalidOperationException(MetadataStringTable.IncorrectElementTypeValue);
        }
Esempio n. 22
0
 internal static Microsoft.MetadataReader.CorCallingConvention ExtractCallingConvention(byte[] sig, ref int index)
 {
     return((Microsoft.MetadataReader.CorCallingConvention)SignatureUtil.ExtractInt(sig, ref index));
 }
Esempio n. 23
0
        private object ParseDefaultValue()
        {
            int num;
            EmbeddedBlobPointer embeddedBlobPointer;
            int             num1;
            int             num2;
            IntPtr          intPtr;
            int             num3;
            FieldAttributes fieldAttribute;
            int             num4;
            IMetadataImport rawImport = this.m_resolver.RawImport;

            rawImport.GetFieldProps(this.m_fieldDefToken, out num4, null, 0, out num, out fieldAttribute, out embeddedBlobPointer, out num1, out num2, out intPtr, out num3);
            byte[] numArray = this.m_resolver.ReadEmbeddedBlob(embeddedBlobPointer, num1);
            int    num5     = 0;

            SignatureUtil.ExtractCallingConvention(numArray, ref num5);
            System.Reflection.Adds.CorElementType corElementType = SignatureUtil.ExtractElementType(numArray, ref num5);
            if (corElementType == System.Reflection.Adds.CorElementType.ValueType)
            {
                SignatureUtil.ExtractToken(numArray, ref num5);
                corElementType = (System.Reflection.Adds.CorElementType)num2;
            }
            else if (corElementType == System.Reflection.Adds.CorElementType.GenericInstantiation)
            {
                SignatureUtil.ExtractType(numArray, ref num5, this.m_resolver, this.m_context);
                corElementType = (System.Reflection.Adds.CorElementType)num2;
            }
            switch (corElementType)
            {
            case System.Reflection.Adds.CorElementType.Bool:
            {
                if (Marshal.ReadByte(intPtr) == 0)
                {
                    return(false);
                }
                return(true);
            }

            case System.Reflection.Adds.CorElementType.Char:
            {
                return((char)Marshal.ReadInt16(intPtr));
            }

            case System.Reflection.Adds.CorElementType.SByte:
            {
                return((sbyte)Marshal.ReadByte(intPtr));
            }

            case System.Reflection.Adds.CorElementType.Byte:
            {
                return(Marshal.ReadByte(intPtr));
            }

            case System.Reflection.Adds.CorElementType.Short:
            {
                return(Marshal.ReadInt16(intPtr));
            }

            case System.Reflection.Adds.CorElementType.UShort:
            {
                return((ushort)Marshal.ReadInt16(intPtr));
            }

            case System.Reflection.Adds.CorElementType.Int:
            {
                return(Marshal.ReadInt32(intPtr));
            }

            case System.Reflection.Adds.CorElementType.UInt:
            {
                return((uint)Marshal.ReadInt32(intPtr));
            }

            case System.Reflection.Adds.CorElementType.Long:
            {
                return(Marshal.ReadInt64(intPtr));
            }

            case System.Reflection.Adds.CorElementType.ULong:
            {
                return((ulong)Marshal.ReadInt64(intPtr));
            }

            case System.Reflection.Adds.CorElementType.Float:
            {
                float[] singleArray = new float[1];
                Marshal.Copy(intPtr, singleArray, 0, 1);
                return(singleArray[0]);
            }

            case System.Reflection.Adds.CorElementType.Double:
            {
                double[] numArray1 = new double[1];
                Marshal.Copy(intPtr, numArray1, 0, 1);
                return(numArray1[0]);
            }

            case System.Reflection.Adds.CorElementType.String:
            {
                return(Marshal.PtrToStringAuto(intPtr, num3));
            }

            case System.Reflection.Adds.CorElementType.Pointer:
            case System.Reflection.Adds.CorElementType.Byref:
            case System.Reflection.Adds.CorElementType.ValueType:
            case System.Reflection.Adds.CorElementType.TypeVar:
            case System.Reflection.Adds.CorElementType.Array:
            case System.Reflection.Adds.CorElementType.GenericInstantiation:
            case System.Reflection.Adds.CorElementType.TypedByRef:
            case System.Reflection.Adds.CorElementType.Array | System.Reflection.Adds.CorElementType.Bool | System.Reflection.Adds.CorElementType.Byref | System.Reflection.Adds.CorElementType.Char | System.Reflection.Adds.CorElementType.Class | System.Reflection.Adds.CorElementType.SByte | System.Reflection.Adds.CorElementType.Short | System.Reflection.Adds.CorElementType.TypedByRef | System.Reflection.Adds.CorElementType.Byte | System.Reflection.Adds.CorElementType.UShort | System.Reflection.Adds.CorElementType.ValueType | System.Reflection.Adds.CorElementType.Void | System.Reflection.Adds.CorElementType.TypeVar | System.Reflection.Adds.CorElementType.GenericInstantiation:
            case System.Reflection.Adds.CorElementType.UIntPtr:
            {
                throw new InvalidOperationException(MetadataStringTable.IncorrectElementTypeValue);
            }

            case System.Reflection.Adds.CorElementType.Class:
            {
                return(null);
            }

            case System.Reflection.Adds.CorElementType.IntPtr:
            {
                return(Marshal.ReadIntPtr(intPtr));
            }

            default:
            {
                throw new InvalidOperationException(MetadataStringTable.IncorrectElementTypeValue);
            }
            }
        }
Esempio n. 24
0
 internal static string ExtractStringValue(byte[] blob, ref int index)
 {
     return((string)SignatureUtil.ExtractValue(System.Reflection.Adds.CorElementType.String, blob, ref index));
 }
Esempio n. 25
0
        internal static Type ExtractType(byte[] sig, ref int index, MetadataOnlyModule resolver, GenericContext context)
        {
            TypeSignatureDescriptor typeSignatureDescriptor = SignatureUtil.ExtractType(sig, ref index, resolver, context, false);

            return(typeSignatureDescriptor.Type);
        }
Esempio n. 26
0
        internal static TypeSignatureDescriptor ExtractType(byte[] sig, ref int index, MetadataOnlyModule resolver, GenericContext context, bool fAllowPinned)
        {
            TypeSignatureDescriptor typeSignatureDescriptor = new TypeSignatureDescriptor()
            {
                IsPinned = false
            };

            System.Reflection.Adds.CorElementType corElementType = SignatureUtil.ExtractElementType(sig, ref index);
            switch (corElementType)
            {
            case System.Reflection.Adds.CorElementType.End:
            case System.Reflection.Adds.CorElementType.Array | System.Reflection.Adds.CorElementType.Bool | System.Reflection.Adds.CorElementType.Byref | System.Reflection.Adds.CorElementType.Char | System.Reflection.Adds.CorElementType.Class | System.Reflection.Adds.CorElementType.SByte | System.Reflection.Adds.CorElementType.Short | System.Reflection.Adds.CorElementType.TypedByRef | System.Reflection.Adds.CorElementType.Byte | System.Reflection.Adds.CorElementType.UShort | System.Reflection.Adds.CorElementType.ValueType | System.Reflection.Adds.CorElementType.Void | System.Reflection.Adds.CorElementType.TypeVar | System.Reflection.Adds.CorElementType.GenericInstantiation:
            case System.Reflection.Adds.CorElementType.Bool | System.Reflection.Adds.CorElementType.Byref | System.Reflection.Adds.CorElementType.Class | System.Reflection.Adds.CorElementType.IntPtr | System.Reflection.Adds.CorElementType.Int | System.Reflection.Adds.CorElementType.Long:
            case System.Reflection.Adds.CorElementType.Internal:
            case System.Reflection.Adds.CorElementType.Max:
            case System.Reflection.Adds.CorElementType.Bool | System.Reflection.Adds.CorElementType.Char | System.Reflection.Adds.CorElementType.CModOpt | System.Reflection.Adds.CorElementType.Internal | System.Reflection.Adds.CorElementType.Max | System.Reflection.Adds.CorElementType.Void:
            case System.Reflection.Adds.CorElementType.CModOpt | System.Reflection.Adds.CorElementType.SByte:
            case System.Reflection.Adds.CorElementType.CModOpt | System.Reflection.Adds.CorElementType.SByte | System.Reflection.Adds.CorElementType.Internal | System.Reflection.Adds.CorElementType.Byte | System.Reflection.Adds.CorElementType.Void:
            case System.Reflection.Adds.CorElementType.Bool | System.Reflection.Adds.CorElementType.CModOpt | System.Reflection.Adds.CorElementType.SByte | System.Reflection.Adds.CorElementType.Short | System.Reflection.Adds.CorElementType.Max:
            case System.Reflection.Adds.CorElementType.Bool | System.Reflection.Adds.CorElementType.Char | System.Reflection.Adds.CorElementType.CModOpt | System.Reflection.Adds.CorElementType.SByte | System.Reflection.Adds.CorElementType.Short | System.Reflection.Adds.CorElementType.Internal | System.Reflection.Adds.CorElementType.Max | System.Reflection.Adds.CorElementType.Byte | System.Reflection.Adds.CorElementType.UShort | System.Reflection.Adds.CorElementType.Void:
            case System.Reflection.Adds.CorElementType.CModOpt | System.Reflection.Adds.CorElementType.Int:
            case System.Reflection.Adds.CorElementType.CModOpt | System.Reflection.Adds.CorElementType.Int | System.Reflection.Adds.CorElementType.Internal | System.Reflection.Adds.CorElementType.UInt | System.Reflection.Adds.CorElementType.Void:
            case System.Reflection.Adds.CorElementType.Bool | System.Reflection.Adds.CorElementType.CModOpt | System.Reflection.Adds.CorElementType.Int | System.Reflection.Adds.CorElementType.Long | System.Reflection.Adds.CorElementType.Max:
            case System.Reflection.Adds.CorElementType.Bool | System.Reflection.Adds.CorElementType.Char | System.Reflection.Adds.CorElementType.CModOpt | System.Reflection.Adds.CorElementType.Int | System.Reflection.Adds.CorElementType.Long | System.Reflection.Adds.CorElementType.Internal | System.Reflection.Adds.CorElementType.Max | System.Reflection.Adds.CorElementType.UInt | System.Reflection.Adds.CorElementType.ULong | System.Reflection.Adds.CorElementType.Void:
            case System.Reflection.Adds.CorElementType.CModOpt | System.Reflection.Adds.CorElementType.SByte | System.Reflection.Adds.CorElementType.Int | System.Reflection.Adds.CorElementType.Float:
            case System.Reflection.Adds.CorElementType.CModOpt | System.Reflection.Adds.CorElementType.SByte | System.Reflection.Adds.CorElementType.Int | System.Reflection.Adds.CorElementType.Internal | System.Reflection.Adds.CorElementType.Float | System.Reflection.Adds.CorElementType.Double | System.Reflection.Adds.CorElementType.Byte | System.Reflection.Adds.CorElementType.UInt | System.Reflection.Adds.CorElementType.Void:
            case System.Reflection.Adds.CorElementType.Bool | System.Reflection.Adds.CorElementType.CModOpt | System.Reflection.Adds.CorElementType.SByte | System.Reflection.Adds.CorElementType.Short | System.Reflection.Adds.CorElementType.Int | System.Reflection.Adds.CorElementType.Long | System.Reflection.Adds.CorElementType.Max | System.Reflection.Adds.CorElementType.Float | System.Reflection.Adds.CorElementType.String:
            case System.Reflection.Adds.CorElementType.Bool | System.Reflection.Adds.CorElementType.Char | System.Reflection.Adds.CorElementType.CModOpt | System.Reflection.Adds.CorElementType.SByte | System.Reflection.Adds.CorElementType.Short | System.Reflection.Adds.CorElementType.Int | System.Reflection.Adds.CorElementType.Long | System.Reflection.Adds.CorElementType.Internal | System.Reflection.Adds.CorElementType.Max | System.Reflection.Adds.CorElementType.Pointer | System.Reflection.Adds.CorElementType.Float | System.Reflection.Adds.CorElementType.Double | System.Reflection.Adds.CorElementType.String | System.Reflection.Adds.CorElementType.Byte | System.Reflection.Adds.CorElementType.UShort | System.Reflection.Adds.CorElementType.UInt | System.Reflection.Adds.CorElementType.ULong | System.Reflection.Adds.CorElementType.Void:
            case System.Reflection.Adds.CorElementType.Byref | System.Reflection.Adds.CorElementType.CModOpt:
            case System.Reflection.Adds.CorElementType.Byref | System.Reflection.Adds.CorElementType.CModOpt | System.Reflection.Adds.CorElementType.Internal | System.Reflection.Adds.CorElementType.ValueType | System.Reflection.Adds.CorElementType.Void:
            case System.Reflection.Adds.CorElementType.Bool | System.Reflection.Adds.CorElementType.Byref | System.Reflection.Adds.CorElementType.Class | System.Reflection.Adds.CorElementType.CModOpt | System.Reflection.Adds.CorElementType.Max:
            case System.Reflection.Adds.CorElementType.Bool | System.Reflection.Adds.CorElementType.Byref | System.Reflection.Adds.CorElementType.Char | System.Reflection.Adds.CorElementType.Class | System.Reflection.Adds.CorElementType.CModOpt | System.Reflection.Adds.CorElementType.Internal | System.Reflection.Adds.CorElementType.Max | System.Reflection.Adds.CorElementType.ValueType | System.Reflection.Adds.CorElementType.Void | System.Reflection.Adds.CorElementType.TypeVar:
            case System.Reflection.Adds.CorElementType.Array | System.Reflection.Adds.CorElementType.Byref | System.Reflection.Adds.CorElementType.CModOpt | System.Reflection.Adds.CorElementType.SByte:
            case System.Reflection.Adds.CorElementType.Array | System.Reflection.Adds.CorElementType.Byref | System.Reflection.Adds.CorElementType.CModOpt | System.Reflection.Adds.CorElementType.SByte | System.Reflection.Adds.CorElementType.Internal | System.Reflection.Adds.CorElementType.Byte | System.Reflection.Adds.CorElementType.ValueType | System.Reflection.Adds.CorElementType.Void | System.Reflection.Adds.CorElementType.GenericInstantiation:
            case System.Reflection.Adds.CorElementType.Array | System.Reflection.Adds.CorElementType.Bool | System.Reflection.Adds.CorElementType.Byref | System.Reflection.Adds.CorElementType.Class | System.Reflection.Adds.CorElementType.CModOpt | System.Reflection.Adds.CorElementType.SByte | System.Reflection.Adds.CorElementType.Short | System.Reflection.Adds.CorElementType.Max | System.Reflection.Adds.CorElementType.TypedByRef:
            case System.Reflection.Adds.CorElementType.Array | System.Reflection.Adds.CorElementType.Bool | System.Reflection.Adds.CorElementType.Byref | System.Reflection.Adds.CorElementType.Char | System.Reflection.Adds.CorElementType.Class | System.Reflection.Adds.CorElementType.CModOpt | System.Reflection.Adds.CorElementType.SByte | System.Reflection.Adds.CorElementType.Short | System.Reflection.Adds.CorElementType.Internal | System.Reflection.Adds.CorElementType.Max | System.Reflection.Adds.CorElementType.TypedByRef | System.Reflection.Adds.CorElementType.Byte | System.Reflection.Adds.CorElementType.UShort | System.Reflection.Adds.CorElementType.ValueType | System.Reflection.Adds.CorElementType.Void | System.Reflection.Adds.CorElementType.TypeVar | System.Reflection.Adds.CorElementType.GenericInstantiation:
            case System.Reflection.Adds.CorElementType.Byref | System.Reflection.Adds.CorElementType.CModOpt | System.Reflection.Adds.CorElementType.IntPtr | System.Reflection.Adds.CorElementType.Int:
            case System.Reflection.Adds.CorElementType.Byref | System.Reflection.Adds.CorElementType.CModOpt | System.Reflection.Adds.CorElementType.IntPtr | System.Reflection.Adds.CorElementType.Int | System.Reflection.Adds.CorElementType.Internal | System.Reflection.Adds.CorElementType.UIntPtr | System.Reflection.Adds.CorElementType.UInt | System.Reflection.Adds.CorElementType.ValueType | System.Reflection.Adds.CorElementType.Void:
            case System.Reflection.Adds.CorElementType.Bool | System.Reflection.Adds.CorElementType.Byref | System.Reflection.Adds.CorElementType.Class | System.Reflection.Adds.CorElementType.CModOpt | System.Reflection.Adds.CorElementType.IntPtr | System.Reflection.Adds.CorElementType.Int | System.Reflection.Adds.CorElementType.Long | System.Reflection.Adds.CorElementType.Max:
            case System.Reflection.Adds.CorElementType.Bool | System.Reflection.Adds.CorElementType.Byref | System.Reflection.Adds.CorElementType.Char | System.Reflection.Adds.CorElementType.Class | System.Reflection.Adds.CorElementType.CModOpt | System.Reflection.Adds.CorElementType.FnPtr | System.Reflection.Adds.CorElementType.IntPtr | System.Reflection.Adds.CorElementType.Int | System.Reflection.Adds.CorElementType.Long | System.Reflection.Adds.CorElementType.Internal | System.Reflection.Adds.CorElementType.Max | System.Reflection.Adds.CorElementType.UIntPtr | System.Reflection.Adds.CorElementType.UInt | System.Reflection.Adds.CorElementType.ULong | System.Reflection.Adds.CorElementType.ValueType | System.Reflection.Adds.CorElementType.Void | System.Reflection.Adds.CorElementType.TypeVar:
            case System.Reflection.Adds.CorElementType.Array | System.Reflection.Adds.CorElementType.Byref | System.Reflection.Adds.CorElementType.CModOpt | System.Reflection.Adds.CorElementType.IntPtr | System.Reflection.Adds.CorElementType.SByte | System.Reflection.Adds.CorElementType.Int | System.Reflection.Adds.CorElementType.Object | System.Reflection.Adds.CorElementType.Float:
            case System.Reflection.Adds.CorElementType.Array | System.Reflection.Adds.CorElementType.Byref | System.Reflection.Adds.CorElementType.CModOpt | System.Reflection.Adds.CorElementType.IntPtr | System.Reflection.Adds.CorElementType.SByte | System.Reflection.Adds.CorElementType.Int | System.Reflection.Adds.CorElementType.Internal | System.Reflection.Adds.CorElementType.Object | System.Reflection.Adds.CorElementType.Float | System.Reflection.Adds.CorElementType.Double | System.Reflection.Adds.CorElementType.SzArray | System.Reflection.Adds.CorElementType.UIntPtr | System.Reflection.Adds.CorElementType.Byte | System.Reflection.Adds.CorElementType.UInt | System.Reflection.Adds.CorElementType.ValueType | System.Reflection.Adds.CorElementType.Void | System.Reflection.Adds.CorElementType.GenericInstantiation:
            case System.Reflection.Adds.CorElementType.Array | System.Reflection.Adds.CorElementType.Bool | System.Reflection.Adds.CorElementType.Byref | System.Reflection.Adds.CorElementType.Class | System.Reflection.Adds.CorElementType.CModOpt | System.Reflection.Adds.CorElementType.IntPtr | System.Reflection.Adds.CorElementType.SByte | System.Reflection.Adds.CorElementType.Short | System.Reflection.Adds.CorElementType.Int | System.Reflection.Adds.CorElementType.Long | System.Reflection.Adds.CorElementType.Max | System.Reflection.Adds.CorElementType.Object | System.Reflection.Adds.CorElementType.Float | System.Reflection.Adds.CorElementType.String | System.Reflection.Adds.CorElementType.TypedByRef | System.Reflection.Adds.CorElementType.MethodVar:
            case System.Reflection.Adds.CorElementType.Array | System.Reflection.Adds.CorElementType.Bool | System.Reflection.Adds.CorElementType.Byref | System.Reflection.Adds.CorElementType.Char | System.Reflection.Adds.CorElementType.Class | System.Reflection.Adds.CorElementType.CModOpt | System.Reflection.Adds.CorElementType.CModReqd | System.Reflection.Adds.CorElementType.FnPtr | System.Reflection.Adds.CorElementType.IntPtr | System.Reflection.Adds.CorElementType.SByte | System.Reflection.Adds.CorElementType.Short | System.Reflection.Adds.CorElementType.Int | System.Reflection.Adds.CorElementType.Long | System.Reflection.Adds.CorElementType.Internal | System.Reflection.Adds.CorElementType.Max | System.Reflection.Adds.CorElementType.Object | System.Reflection.Adds.CorElementType.Pointer | System.Reflection.Adds.CorElementType.Float | System.Reflection.Adds.CorElementType.Double | System.Reflection.Adds.CorElementType.String | System.Reflection.Adds.CorElementType.SzArray | System.Reflection.Adds.CorElementType.TypedByRef | System.Reflection.Adds.CorElementType.UIntPtr | System.Reflection.Adds.CorElementType.Byte | System.Reflection.Adds.CorElementType.UShort | System.Reflection.Adds.CorElementType.UInt | System.Reflection.Adds.CorElementType.ULong | System.Reflection.Adds.CorElementType.ValueType | System.Reflection.Adds.CorElementType.Void | System.Reflection.Adds.CorElementType.TypeVar | System.Reflection.Adds.CorElementType.MethodVar | System.Reflection.Adds.CorElementType.GenericInstantiation:
            case System.Reflection.Adds.CorElementType.Modifier:
            case System.Reflection.Adds.CorElementType.Sentinel:
            case System.Reflection.Adds.CorElementType.Bool | System.Reflection.Adds.CorElementType.Modifier:
            case System.Reflection.Adds.CorElementType.Bool | System.Reflection.Adds.CorElementType.Char | System.Reflection.Adds.CorElementType.Modifier | System.Reflection.Adds.CorElementType.Sentinel | System.Reflection.Adds.CorElementType.Void:
            case System.Reflection.Adds.CorElementType.SByte | System.Reflection.Adds.CorElementType.Modifier:
            {
                throw new ArgumentException(MetadataStringTable.IncorrectElementTypeValue);
            }

            case System.Reflection.Adds.CorElementType.Void:
            case System.Reflection.Adds.CorElementType.Bool:
            case System.Reflection.Adds.CorElementType.Char:
            case System.Reflection.Adds.CorElementType.SByte:
            case System.Reflection.Adds.CorElementType.Byte:
            case System.Reflection.Adds.CorElementType.Short:
            case System.Reflection.Adds.CorElementType.UShort:
            case System.Reflection.Adds.CorElementType.Int:
            case System.Reflection.Adds.CorElementType.UInt:
            case System.Reflection.Adds.CorElementType.Long:
            case System.Reflection.Adds.CorElementType.ULong:
            case System.Reflection.Adds.CorElementType.Float:
            case System.Reflection.Adds.CorElementType.Double:
            case System.Reflection.Adds.CorElementType.String:
            case System.Reflection.Adds.CorElementType.IntPtr:
            case System.Reflection.Adds.CorElementType.UIntPtr:
            case System.Reflection.Adds.CorElementType.Object:
            {
                typeSignatureDescriptor.Type = resolver.AssemblyResolver.GetBuiltInType(corElementType);
                break;
            }

            case System.Reflection.Adds.CorElementType.Pointer:
            {
                typeSignatureDescriptor.Type = SignatureUtil.ExtractType(sig, ref index, resolver, context).MakePointerType();
                break;
            }

            case System.Reflection.Adds.CorElementType.Byref:
            {
                typeSignatureDescriptor.Type = SignatureUtil.ExtractType(sig, ref index, resolver, context).MakeByRefType();
                break;
            }

            case System.Reflection.Adds.CorElementType.ValueType:
            case System.Reflection.Adds.CorElementType.Class:
            {
                Token token = SignatureUtil.ExtractToken(sig, ref index);
                typeSignatureDescriptor.Type = resolver.ResolveTypeTokenInternal(token, context);
                break;
            }

            case System.Reflection.Adds.CorElementType.TypeVar:
            {
                int num = SignatureUtil.ExtractInt(sig, ref index);
                if (GenericContext.IsNullOrEmptyTypeArgs(context))
                {
                    throw new ArgumentException(MetadataStringTable.TypeArgumentCannotBeResolved);
                }
                typeSignatureDescriptor.Type = context.TypeArgs[num];
                break;
            }

            case System.Reflection.Adds.CorElementType.Array:
            {
                Type type = SignatureUtil.ExtractType(sig, ref index, resolver, context);
                int  num1 = SignatureUtil.ExtractInt(sig, ref index);
                int  num2 = SignatureUtil.ExtractInt(sig, ref index);
                for (int i = 0; i < num2; i++)
                {
                    SignatureUtil.ExtractInt(sig, ref index);
                }
                int num3 = SignatureUtil.ExtractInt(sig, ref index);
                for (int j = 0; j < num3; j++)
                {
                    SignatureUtil.ExtractInt(sig, ref index);
                }
                typeSignatureDescriptor.Type = type.MakeArrayType(num1);
                break;
            }

            case System.Reflection.Adds.CorElementType.GenericInstantiation:
            {
                Type   type1     = SignatureUtil.ExtractType(sig, ref index, resolver, null);
                Type[] typeArray = new Type[SignatureUtil.ExtractInt(sig, ref index)];
                for (int k = 0; k < (int)typeArray.Length; k++)
                {
                    typeArray[k] = SignatureUtil.ExtractType(sig, ref index, resolver, context);
                }
                typeSignatureDescriptor.Type = type1.MakeGenericType(typeArray);
                break;
            }

            case System.Reflection.Adds.CorElementType.TypedByRef:
            {
                typeSignatureDescriptor.Type = resolver.AssemblyResolver.GetTypeXFromName("System.TypedReference");
                break;
            }

            case System.Reflection.Adds.CorElementType.FnPtr:
            {
                SignatureUtil.ExtractCallingConvention(sig, ref index);
                int num4 = SignatureUtil.ExtractInt(sig, ref index);
                SignatureUtil.ExtractType(sig, ref index, resolver, context);
                for (int l = 0; l < num4; l++)
                {
                    SignatureUtil.ExtractType(sig, ref index, resolver, context);
                }
                typeSignatureDescriptor.Type = resolver.AssemblyResolver.GetBuiltInType(System.Reflection.Adds.CorElementType.IntPtr);
                break;
            }

            case System.Reflection.Adds.CorElementType.SzArray:
            {
                typeSignatureDescriptor.Type = SignatureUtil.ExtractType(sig, ref index, resolver, context).MakeArrayType();
                break;
            }

            case System.Reflection.Adds.CorElementType.MethodVar:
            {
                int num5 = SignatureUtil.ExtractInt(sig, ref index);
                if (GenericContext.IsNullOrEmptyMethodArgs(context))
                {
                    throw new ArgumentException(MetadataStringTable.TypeArgumentCannotBeResolved);
                }
                typeSignatureDescriptor.Type = context.MethodArgs[num5];
                break;
            }

            case System.Reflection.Adds.CorElementType.CModReqd:
            {
                Token token1 = SignatureUtil.ExtractToken(sig, ref index);
                resolver.ResolveTypeTokenInternal(token1, context);
                typeSignatureDescriptor.Type = SignatureUtil.ExtractType(sig, ref index, resolver, context);
                break;
            }

            case System.Reflection.Adds.CorElementType.CModOpt:
            {
                Token token2 = SignatureUtil.ExtractToken(sig, ref index);
                resolver.ResolveTypeTokenInternal(token2, context);
                typeSignatureDescriptor.Type = SignatureUtil.ExtractType(sig, ref index, resolver, context);
                break;
            }

            case System.Reflection.Adds.CorElementType.Pinned:
            {
                typeSignatureDescriptor.IsPinned = true;
                typeSignatureDescriptor.Type     = SignatureUtil.ExtractType(sig, ref index, resolver, context);
                break;
            }

            default:
            {
                throw new ArgumentException(MetadataStringTable.IncorrectElementTypeValue);
            }
            }
            return(typeSignatureDescriptor);
        }
Esempio n. 27
0
 internal static uint ExtractUIntValue(byte[] blob, ref int index)
 {
     return((uint)SignatureUtil.ExtractValue(System.Reflection.Adds.CorElementType.UInt, blob, ref index));
 }
Esempio n. 28
0
 internal static System.Reflection.Adds.CorElementType ExtractElementType(byte[] sig, ref int index)
 {
     return((System.Reflection.Adds.CorElementType)SignatureUtil.ExtractInt(sig, ref index));
 }