Exemplo n.º 1
0
        private string DoGetDisplayText(MethodDefinition method)
        {
            var text = new StringBuilder();

            // return-type
            text.Append(DoGetDisplayType(method.ReturnType.FullName));
            text.Append(':');

            // declaring-type
            string name = method.DeclaringType.FullName;
            Debug.Assert(!name.Contains(":"), name + " should not have a ':'");
            text.Append(name);
            text.Append(':');

            // name
            text.Append(DoGetDisplayName(method));
            text.Append(':');

            // generic-args
            if (method.HasGenericParameters && !DoCanDeduceGenerics(method))
                text.Append(DoGetDisplayGargs(method.GenericParameters));
            else if (method.IsConstructor && method.DeclaringType.HasGenericParameters)
                text.Append(DoGetDisplayGargs(method.DeclaringType.GenericParameters));
            text.Append(':');

            // arg-types
            if (method.HasParameters)
            {
                for (int i = 0; i < method.Parameters.Count; ++i)
                {
                    text.Append(method.GetParameterModifier(i));

                    ParameterDefinition p = method.Parameters[i];
                    string typeName = p.ParameterType.FullName;
                    if (typeName.EndsWith("&"))
                        typeName = typeName.Remove(typeName.Length - 1);
                    text.Append(DoGetDisplayType(typeName));

                    if (i + 1 < method.Parameters.Count)
                        text.Append(";");
                }
            }
            text.Append(':');

            // arg-names
            if (method.HasParameters)
            {
                for (int i = 0; i < method.Parameters.Count; ++i)
                {
                    ParameterDefinition p = method.Parameters[i];

                    Debug.Assert(!p.Name.Contains(":"), p.Name + " should not have a ':'");
                    Debug.Assert(!p.Name.Contains(";"), p.Name + " should not have a ';'");
                    text.Append(p.Name);

                    if (i + 1 < method.Parameters.Count)
                        text.Append(";");
                }
            }

            return text.ToString();
        }
Exemplo n.º 2
0
        private void DoGetParams(StringBuilder builder, MethodDefinition method)
        {
            if (m_addSpace)
                builder.Append(" (");
            else
                builder.Append("(");
            for (int i = 0; i < method.Parameters.Count; ++i)
            {
                builder.Append(method.GetParameterModifier(i));

                ParameterDefinition param = method.Parameters[i];
                string tname = DoGetQualifiedTypeName(param.ParameterType, true);
                if (tname.EndsWith("&"))
                    tname = tname.Remove(tname.Length - 1);

                builder.Append(tname);
                builder.Append(" ");
                builder.Append(param.Name);

                if (i + 1 < method.Parameters.Count)
                    builder.Append(", ");
            }
            builder.Append(");");
        }