Exemple #1
0
        private static StringBuilder AppendPrettyNameCore(this StringBuilder name, Type type, PrettyNameContext context)
        {
            // Suffixes (array, ref, pointer)
            if (type.IsArray)
                return name
                    .AppendPrettyName(type.GetElementType(), context)
                    .Append('[')
                    .Append(',', type.GetArrayRank() - 1)
                    .Append(']');
            else if (type.IsByRef)
                return name
                    .AppendPrettyName(type.GetElementType(), context)
                    .Append('&');
            else if (type.IsPointer)
                return name
                    .AppendPrettyName(type.GetElementType(), context)
                    .Append('*');

            // Prefixes (nesting, namespace)
            if (type.IsNested)
                name.AppendPrettyNameCore(type.DeclaringType, context)
                    .Append('.');
            else if (context.IsQualified)
                name.Append(type.Namespace)
                    .Append('.');

            // Name and arguments
            if (type.IsGenericType)
                return name
                    .Append(type.Name.WithoutGenericSuffix())
                    .AppendPrettyArguments(type, context);
            else
                return name
                    .Append(type.Name);
        }
Exemple #2
0
 private static StringBuilder AppendPrettyName(this StringBuilder name, Type type, PrettyNameContext context)
 {
     return name.AppendPrettyNameCore(type, new PrettyNameContext(type, context.IsQualified));
 }