예제 #1
0
        protected override void CreateText(Dictionary <uint, NuGenTokenBase> allTokens)
        {
            base.CreateText(allTokens);
            StringBuilder nameBuilder = null;

            if (Name == null || Name.Length == 0)
            {
                nameBuilder = new StringBuilder();
                nameBuilder.Append("<");
                ReadSignature();

                if (signatureReader.Arguments != null)
                {
                    for (int index = 0; index < signatureReader.Arguments.Count; index++)
                    {
                        NuGenBaseSignatureItem argument = signatureReader.Arguments[index];
                        NuGenHelperFunctions.SetSignatureItemToken(allTokens, argument);
                        nameBuilder.Append(argument);

                        if (index < signatureReader.Arguments.Count - 1)
                        {
                            nameBuilder.Append(", ");
                        }
                    }
                }

                nameBuilder.Append(">(");

                string parentAsString = Parent.ToString();

                Name = parentAsString.Replace("(", nameBuilder.ToString());
            }
        }
 public override void SetGenericParametersOfMethod(List <NuGenGenericParameter> genericParameters)
 {
     if (HasGenericMethodParameter)
     {
         NuGenHelperFunctions.SetSignatureItemToken(AllTokens, MarshalAsType, genericParameters);
     }
 }
예제 #3
0
        protected override void CreateText(Dictionary <uint, NuGenTokenBase> allTokens)
        {
            base.CreateText(allTokens);
            ReadSignature();
            NuGenBaseSignatureItem signatureItem = signatureReader.Type;

            NuGenHelperFunctions.SetSignatureItemToken(allTokens, signatureItem);

            if (((Flags & CorFieldAttr.fdReservedMask) & CorFieldAttr.fdHasFieldRVA) == CorFieldAttr.fdHasFieldRVA)
            {
                NuGenAssembly assembly = BaseTypeDefinition.ModuleScope.Assembly;

                try
                {
                    assembly.OpenMetadataInterfaces();
                    uint rva;
                    uint implFlags;

                    assembly.Import.GetRVA(Token, out rva, out implFlags);

                    Rva = rva;
                    ImplementationFlags = (CorMethodImpl)implFlags;
                }
                finally
                {
                    assembly.CloseMetadataInterfaces();
                }
            }
        }
예제 #4
0
        protected override void CreateText(Dictionary <uint, NuGenTokenBase> allTokens)
        {
            base.CreateText(allTokens);
            ReadSignature();
            NuGenHelperFunctions.SetSignatureItemToken(allTokens, signatureReader.Type);
            Name = signatureReader.Type.ToString();

            if (signatureReader.GenericParameters != null)
            {
                StringBuilder nameBuilder = new StringBuilder(Name);
                nameBuilder.Append("<");

                for (int index = 0; index < signatureReader.GenericParameters.Count; index++)
                {
                    NuGenBaseSignatureItem genericParameter = signatureReader.GenericParameters[index];

                    NuGenHelperFunctions.SetSignatureItemToken(allTokens, genericParameter);
                    nameBuilder.Append(genericParameter);

                    if (index < signatureReader.GenericParameters.Count - 1)
                    {
                        nameBuilder.Append(", ");
                    }
                }

                nameBuilder.Append(">");
                Name = nameBuilder.ToString();
            }
        }
예제 #5
0
 public override void SetGenericParametersOfMethod(List <NuGenGenericParameter> genericParameters)
 {
     if (Arguments != null && HasGenericMethodParameter)
     {
         foreach (NuGenBaseSignatureItem signatureItem in Arguments)
         {
             NuGenHelperFunctions.SetSignatureItemToken(AllTokens, signatureItem, genericParameters);
         }
     }
 }
예제 #6
0
        protected override void CreateText(Dictionary <uint, NuGenTokenBase> allTokens)
        {
            base.CreateText(allTokens);
            ReadSignature();
            NuGenHelperFunctions.SetSignatureItemToken(allTokens, signatureReader.ReturnType);

            NuGenAssembly assembly = BaseTypeDefinition.ModuleScope.Assembly;

            DefinitionBuilder.Length = 0;

            if ((Flags & CorPropertyAttr.prSpecialName) == CorPropertyAttr.prSpecialName)
            {
                DefinitionBuilder.Append("specialname ");
            }

            CorPropertyAttr reservedFlags = Flags & CorPropertyAttr.prReservedMask;

            if ((reservedFlags & CorPropertyAttr.prRTSpecialName) == CorPropertyAttr.prRTSpecialName)
            {
                DefinitionBuilder.Append("rtsspecialname ");
            }

            if ((signatureReader.CallingConvention & CorCallingConvention.IMAGE_CEE_CS_CALLCONV_HASTHIS) == CorCallingConvention.IMAGE_CEE_CS_CALLCONV_HASTHIS)
            {
                DefinitionBuilder.Append("instance ");
            }

            DefinitionBuilder.Append(signatureReader.ReturnType);
            DefinitionBuilder.Append(" ");
            DefinitionBuilder.Append(Name);
            DefinitionBuilder.Append("(");

            if (signatureReader.Parameters != null)
            {
                for (int parametersIndex = 0; parametersIndex < signatureReader.Parameters.Count; parametersIndex++)
                {
                    NuGenBaseSignatureItem parameter = signatureReader.Parameters[parametersIndex];
                    NuGenHelperFunctions.SetSignatureItemToken(allTokens, parameter);
                    DefinitionBuilder.Append(parameter);

                    if (parametersIndex < signatureReader.Parameters.Count - 1)
                    {
                        DefinitionBuilder.Append(", ");
                    }
                }
            }

            DefinitionBuilder.Append(")");
            Definition = DefinitionBuilder.ToString();
        }
예제 #7
0
        public override void SetGenericParametersOfMethod(List <NuGenGenericParameter> genericParameters)
        {
            if (HasGenericMethodParameter)
            {
                NuGenHelperFunctions.SetSignatureItemToken(AllTokens, Type, genericParameters);

                if (GenericParameters != null)
                {
                    foreach (NuGenBaseSignatureItem genericParameter in GenericParameters)
                    {
                        NuGenHelperFunctions.SetSignatureItemToken(AllTokens, genericParameter, genericParameters);
                    }
                }
            }
        }
예제 #8
0
        protected override void CreateText(Dictionary <uint, NuGenTokenBase> allTokens)
        {
            base.CreateText(allTokens);
            TextBuilder.Length = 0;
            ReadSignature();

            if (signatureReader.CallingConvention == CorCallingConvention.IMAGE_CEE_CS_CALLCONV_FIELD)
            {
                NuGenHelperFunctions.SetSignatureItemToken(allTokens, signatureReader.FieldSignatureItem);
                TextBuilder.Append(signatureReader.FieldSignatureItem);
            }
            else
            {
                string formatString1;
                string formatString2;

                TextBuilder.Append("(");

                if (signatureReader.Parameters != null)
                {
                    if (signatureReader.CallingConvention == CorCallingConvention.IMAGE_CEE_CS_CALLCONV_LOCAL_SIG)
                    {
                        formatString1 = "{0} V_{1},\n";
                        formatString2 = "{0} V_{1}";
                    }
                    else
                    {
                        formatString1 = "{0}, ";
                        formatString2 = "{0}";

                        NuGenHelperFunctions.SetSignatureItemToken(allTokens, signatureReader.ReturnType);
                        TextBuilder.Insert(0, " ");
                        TextBuilder.Insert(0, signatureReader.ReturnType);
                        TextBuilder.Insert(0, " ");
                        TextBuilder.Insert(0, NuGenHelperFunctions.GetCallingConventionName(signatureReader.CallingConvention));
                    }

                    for (int index = 0; index < signatureReader.Parameters.Count; index++)
                    {
                        NuGenBaseSignatureItem signatureItem = signatureReader.Parameters[index];
                        NuGenHelperFunctions.SetSignatureItemToken(allTokens, signatureItem);

                        if (signatureReader.CallingConvention == CorCallingConvention.IMAGE_CEE_CS_CALLCONV_LOCAL_SIG && index > 0)
                        {
                            TextBuilder.Append("      ");
                        }

                        if (signatureReader.Parameters.Count > 1 && index < signatureReader.Parameters.Count - 1)
                        {
                            TextBuilder.AppendFormat(formatString1, signatureItem, index);
                        }
                        else
                        {
                            TextBuilder.AppendFormat(formatString2, signatureItem, index);
                        }
                    }
                }

                TextBuilder.Append(")");
            }

            Text = TextBuilder.ToString();
        }
예제 #9
0
        public string GetDefinition(string className, string methodName, bool functionPointer)
        {
            string methodDescription = string.Empty;
            string returnTypeText    = string.Empty;
            string callingConvention = NuGenHelperFunctions.GetCallingConventionName(CallingConvention);

            NuGenHelperFunctions.SetSignatureItemToken(AllTokens, ReturnType);
            returnTypeText = ReturnType.ToString();

            StringBuilder parameterList = new StringBuilder();

            if (functionPointer)
            {
                parameterList.Append("*");
            }

            parameterList.Append("(");

            if (Parameters != null)
            {
                for (int parametersIndex = 0; parametersIndex < Parameters.Count; parametersIndex++)
                {
                    NuGenBaseSignatureItem parameter = Parameters[parametersIndex];
                    NuGenHelperFunctions.SetSignatureItemToken(AllTokens, parameter);

                    if (parametersIndex == Parameters.Count - 1)
                    {
                        parameterList.Append(parameter);
                    }
                    else
                    {
                        parameterList.AppendFormat("{0}, ", parameter);
                    }
                }
            }

            if (SentinelFound)
            {
                if (Parameters != null)
                {
                    parameterList.Append(", ");
                }

                parameterList.Append("...");

                if (VarargParameters != null)
                {
                    parameterList.Append(", ");

                    for (int index = 0; index < VarargParameters.Count; index++)
                    {
                        NuGenBaseSignatureItem varargParameter = VarargParameters[index];
                        NuGenHelperFunctions.SetSignatureItemToken(AllTokens, varargParameter);

                        if (index == VarargParameters.Count - 1)
                        {
                            parameterList.Append(varargParameter);
                        }
                        else
                        {
                            parameterList.AppendFormat("{0}, ", varargParameter);
                        }
                    }
                }
            }
            parameterList.Append(")");

            StringBuilder textBuilder = new StringBuilder();

            if (callingConvention.Length > 0)
            {
                textBuilder.AppendFormat("{0} ", callingConvention);
            }

            textBuilder.AppendFormat("{0} ", returnTypeText);

            textBuilder.AppendFormat("{0}{1}{2}{3}", className, (className == null ? string.Empty : "::"), methodName, parameterList.ToString());

            return(textBuilder.ToString());
        }