Ejemplo n.º 1
0
        private static string GetMemberRef(MetadataReader metadataReader, int token, CilTypeProvider provider, string genericParameterSignature = "")
        {
            var    refHandle   = MetadataTokens.MemberReferenceHandle(token);
            var    reference   = metadataReader.GetMemberReference(refHandle);
            var    parentToken = MetadataTokens.GetToken(reference.Parent);
            string type;

            if (IsTypeSpecification(parentToken))
            {
                var typeSpecificationHandle = MetadataTokens.TypeSpecificationHandle(parentToken);
                type = SignatureDecoder.DecodeType(typeSpecificationHandle, provider, null).ToString();
            }
            else
            {
                var parentHandle = MetadataTokens.TypeReferenceHandle(parentToken);
                type = SignatureDecoder.DecodeType(parentHandle, provider, null).ToString(false);
            }
            string signatureValue;
            string parameters = string.Empty;

            if (reference.GetKind() == MemberReferenceKind.Method)
            {
                MethodSignature <CilType> signature = SignatureDecoder.DecodeMethodSignature(reference.Signature, provider);
                signatureValue = GetMethodReturnType(signature);
                parameters     = provider.GetParameterList(signature);
                return(String.Format("{0} {1}::{2}{3}{4}", signatureValue, type, GetString(metadataReader, reference.Name), genericParameterSignature, parameters));
            }
            signatureValue = SignatureDecoder.DecodeFieldSignature(reference.Signature, provider).ToString();
            return(String.Format("{0} {1}::{2}{3}", signatureValue, type, GetString(metadataReader, reference.Name), parameters));
        }
Ejemplo n.º 2
0
        internal static string SolveMethodName(MetadataReader metadataReader, int token, CilTypeProvider provider)
        {
            string genericParameters = string.Empty;

            if (IsMethodSpecification(token))
            {
                var methodHandle = MetadataTokens.MethodSpecificationHandle(token);
                var methodSpec   = metadataReader.GetMethodSpecification(methodHandle);
                token             = MetadataTokens.GetToken(methodSpec.Method);
                genericParameters = GetGenericParametersSignature(methodSpec, provider);
            }
            if (IsMemberReference(token))
            {
                return(GetMemberRef(metadataReader, token, provider, genericParameters));
            }
            var handle     = MetadataTokens.MethodDefinitionHandle(token);
            var definition = metadataReader.GetMethodDefinition(handle);
            var parent     = definition.GetDeclaringType();
            MethodSignature <CilType> signature = SignatureDecoder.DecodeMethodSignature(definition.Signature, provider);
            var returnType = GetMethodReturnType(signature);
            var parameters = provider.GetParameterList(signature);
            var parentType = SignatureDecoder.DecodeType(parent, provider, null);

            return(string.Format("{0} {1}::{2}{3}{4}", returnType, parentType.ToString(false), GetString(metadataReader, definition.Name), genericParameters, parameters));
        }
Ejemplo n.º 3
0
 private static string GetSignature(MetadataReader metadataReader, int intOperand, CilTypeProvider provider)
 {
     if (IsStandaloneSignature(intOperand))
     {
         var handle = MetadataTokens.StandaloneSignatureHandle(intOperand);
         var standaloneSignature = metadataReader.GetStandaloneSignature(handle);
         var signature           = SignatureDecoder.DecodeMethodSignature(standaloneSignature.Signature, provider);
         return(string.Format("{0}{1}", GetMethodReturnType(signature), provider.GetParameterList(signature)));
     }
     throw new ArgumentException("Get signature invalid token");
 }