private static void AppendType(TypeReference type, StringBuilder name, bool fq_name, bool top_level)
        {
            TypeReference declaringType = type.DeclaringType;

            if (declaringType != null)
            {
                TypeParser.AppendType(declaringType, name, false, top_level);
                name.Append('+');
            }
            string @namespace = type.Namespace;

            if (!string.IsNullOrEmpty(@namespace))
            {
                TypeParser.AppendNamePart(@namespace, name);
                name.Append('.');
            }
            TypeParser.AppendNamePart(type.GetElementType().Name, name);
            if (!fq_name)
            {
                return;
            }
            if (type.IsTypeSpecification())
            {
                TypeParser.AppendTypeSpecification((TypeSpecification)type, name);
            }
            if (TypeParser.RequiresFullyQualifiedName(type, top_level))
            {
                name.Append(", ");
                name.Append(TypeParser.GetScopeFullName(type));
            }
        }
        private static void AppendTypeSpecification(TypeSpecification type, StringBuilder name)
        {
            ArrayType     arrayType;
            int           i;
            StringBuilder stringBuilder;
            StringBuilder stringBuilder1;
            StringBuilder stringBuilder2;
            StringBuilder stringBuilder3;

            if (type.ElementType.IsTypeSpecification())
            {
                TypeParser.AppendTypeSpecification((TypeSpecification)type.ElementType, name);
            }
            ElementType elementType = type.etype;

            switch (elementType)
            {
            case ElementType.Ptr:
            {
                name.Append('*');
                return;
            }

            case ElementType.ByRef:
            {
                name.Append('&');
                return;
            }

            case ElementType.ValueType:
            case ElementType.Class:
            case ElementType.Var:
            {
                return;
            }

            case ElementType.Array:
            {
                arrayType = (ArrayType)type;
                if (arrayType.IsVector)
                {
                    stringBuilder = name.Append("[]");
                    return;
                }
                stringBuilder1 = name.Append('[');
                for (i = 1; i < arrayType.Rank; i++)
                {
                    stringBuilder2 = name.Append(',');
                }
                stringBuilder3 = name.Append(']');
                return;
            }

            case ElementType.GenericInst:
            {
                Collection <TypeReference> genericArguments = ((GenericInstanceType)type).GenericArguments;
                name.Append('[');
                for (int j = 0; j < genericArguments.Count; j++)
                {
                    if (j > 0)
                    {
                        name.Append(',');
                    }
                    TypeReference item  = genericArguments[j];
                    bool          scope = item.Scope != item.Module;
                    if (scope)
                    {
                        name.Append('[');
                    }
                    TypeParser.AppendType(item, name, true, false);
                    if (scope)
                    {
                        name.Append(']');
                    }
                }
                name.Append(']');
                return;
            }

            default:
            {
                if (elementType == ElementType.SzArray)
                {
                    arrayType = (ArrayType)type;
                    if (arrayType.IsVector)
                    {
                        stringBuilder = name.Append("[]");
                        return;
                    }
                    stringBuilder1 = name.Append('[');
                    for (i = 1; i < arrayType.Rank; i++)
                    {
                        stringBuilder2 = name.Append(',');
                    }
                    stringBuilder3 = name.Append(']');
                    return;
                }
                return;
            }
            }
        }