Пример #1
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);
        }
Пример #2
0
 public MetadataOnlyMethodInfo(MetadataOnlyMethodInfo method)
 {
     this.m_resolver         = method.m_resolver;
     this.m_methodDef        = method.m_methodDef;
     this.m_tOwner           = method.m_tOwner;
     this.m_descriptor       = method.m_descriptor;
     this.m_name             = method.m_name;
     this.m_attrs            = method.m_attrs;
     this.m_returnParameter  = method.m_returnParameter;
     this.m_methodBody       = method.m_methodBody;
     this.m_declaringTypeDef = method.m_declaringTypeDef;
     this.m_sigBlob          = method.m_sigBlob;
     this.m_typeArgs         = method.m_typeArgs;
     this.m_methodArgs       = method.m_methodArgs;
     this.m_context          = method.m_context;
     this.m_fullyInitialized = method.m_fullyInitialized;
 }