Esempio n. 1
0
        public ImmutableArray <TType> DecodeLocalSignature <TType>(ISignatureTypeProvider <TType> provider)
        {
            var decoder    = new SignatureDecoder <TType>(provider, _reader);
            var blobReader = _reader.GetBlobReader(Signature);

            return(decoder.DecodeLocalSignature(ref blobReader));
        }
        ImmutableArray <TType> DecodeLocalSignature <TType>(ISignatureTypeProvider <TType> provider, SignatureDecoderOptions options = SignatureDecoderOptions.None)
        {
            var decoder    = new SignatureDecoder <TType>(provider, _reader, options);
            var blobReader = _reader.GetBlobReader(Signature);

            return(decoder.DecodeLocalSignature(ref blobReader));
        }
Esempio n. 3
0
        internal static CilLocal[] DecodeLocalSignature(MethodBodyBlock methodBody, MetadataReader metadataReader, CilTypeProvider provider)
        {
            if (methodBody.LocalSignature.IsNil)
            {
                return(new CilLocal[0]);
            }
            ImmutableArray <CilType> localTypes = SignatureDecoder.DecodeLocalSignature(methodBody.LocalSignature, provider);

            CilLocal[] locals = new CilLocal[localTypes.Length];
            for (int i = 0; i < localTypes.Length; i++)
            {
                string name = "V_" + i;
                locals[i] = new CilLocal(name, localTypes[i].ToString());
            }
            return(locals);
        }
        public void WrongSignatureType()
        {
            using (FileStream stream = File.OpenRead(AssemblyPathHelper.GetAssemblyLocation(typeof(VarArgsToDecode).GetTypeInfo().Assembly)))
                using (var peReader = new PEReader(stream))
                {
                    MetadataReader reader   = peReader.GetMetadataReader();
                    var            provider = new DisassemblingTypeProvider();
                    var            decoder  = new SignatureDecoder <string, DisassemblingGenericContext>(provider, reader, genericContext: null);

                    BlobReader fieldSignature    = reader.GetBlobReader(reader.GetFieldDefinition(MetadataTokens.FieldDefinitionHandle(1)).Signature);
                    BlobReader methodSignature   = reader.GetBlobReader(reader.GetMethodDefinition(MetadataTokens.MethodDefinitionHandle(1)).Signature);
                    BlobReader propertySignature = reader.GetBlobReader(reader.GetPropertyDefinition(MetadataTokens.PropertyDefinitionHandle(1)).Signature);

                    Assert.Throws <BadImageFormatException>(() => decoder.DecodeMethodSignature(ref fieldSignature));
                    Assert.Throws <BadImageFormatException>(() => decoder.DecodeFieldSignature(ref methodSignature));
                    Assert.Throws <BadImageFormatException>(() => decoder.DecodeLocalSignature(ref propertySignature));
                }
        }
        /// <summary>
        /// Get the types of the local variables given the metadata token for the local variable
        /// signature.  This method is used for debugging support.
        /// </summary>
        /// <param name="mdToken">Local variable signature metadata token</param>
        /// <returns>Immutable array of local variable types.  The types are ordered by the local slot number</returns>
        public ImmutableArray <IrisType> DecodeLocalVariableTypes(int mdToken)
        {
            StandaloneSignatureHandle localVarSigHandle = (StandaloneSignatureHandle)MetadataTokens.EntityHandle(mdToken);

            return(SignatureDecoder.DecodeLocalSignature(localVarSigHandle, IrisTypeProvider));
        }