Esempio n. 1
0
        public string GetSignature(MethodInfo method)
        {
            if (method == null)
            {
                throw new ArgumentNullException("method");
            }

            var typeReferencer = new CSharpTypeReferenceProvider(method.ReflectedType);
            var sb             = new StringBuilder();

            if (method.Name == "Finalize")
            {
                sb.Append("~");
                sb.Append(CSharpTypeReferenceProvider.GetBaseName(method.ReflectedType));
                sb.Append("()");
                return(sb.ToString());
            }

            if (!method.ReflectedType.IsInterface)
            {
                AppendNonAccessModifiers(method, sb);
            }

            var operatorNameBeforeType = false;

            if (method.IsSpecialName &&
                (method.Name.Equals("op_Explicit") || method.Name.Equals("op_Implicit")))
            {
                sb.Append(Operators[method.Name]);
                sb.Append(" ");
                operatorNameBeforeType = true;
            }

            sb.Append(typeReferencer.GetTypeReference(method.ReturnType));

            if (!operatorNameBeforeType)
            {
                sb.Append(" ");
                if (method.IsSpecialName && Operators.ContainsKey(method.Name))
                {
                    sb.Append(Operators[method.Name]);
                }
                else
                {
                    sb.Append(method.Name);
                }
            }

            AppendGenericDeclaration(method, sb, typeReferencer);
            AppendMethodParameters(method, sb, typeReferencer);

            return(sb.ToString());
        }
Esempio n. 2
0
        public string GetSignature(ConstructorInfo constructor)
        {
            if (constructor == null)
            {
                throw new ArgumentNullException("constructor");
            }

            var typeReferencer = new CSharpTypeReferenceProvider(constructor.ReflectedType);
            var sb             = new StringBuilder();

            AppendNonAccessModifiers(constructor, sb);
            sb.Append(CSharpTypeReferenceProvider.GetBaseName(constructor.ReflectedType));
            AppendMethodParameters(constructor, sb, typeReferencer);

            return(sb.ToString());
        }