예제 #1
0
        private static string Show(this ParameterDefinition p, FormatDetail detail)
        {
            var sb = new StringBuilder();

            sb.Append(p.IsIn && p.IsOut ? "ref " : p.IsIn ? "in " : p.IsOut ? "out " : "");
            sb.Append(Show(p.ParameterType, detail));
            sb.Append(' ');
            sb.Append(p.Name);
            if (p.IsOptional)
            {
                sb.Append(" = ");
                sb.Append(p.Constant ?? "null"); // TODO: I suspect `Constant` is not the right way to do this.
            }
            return(sb.ToString());
        }
예제 #2
0
        public static string Show(this TypeReference type, FormatDetail detail)
        {
            if (type.FullName == "System.Void")
            {
                return("void");
            }
            var prefix = type.DeclaringType != null
                ? Show(type.DeclaringType, detail) + "."
                : detail == FormatDetail.Full ? type.Namespace + "." : "";

            switch (type)
            {
            case GenericInstanceType generic:
                return($"{prefix}{type.Name.Split('`')[0]}{generic.GenericArguments.ShowGenArgs(detail)}");

            default:
                return($"{prefix}{type.Name}");
            }
        }
예제 #3
0
 public static string Show(this PropertyDefinition property, FormatDetail detail) =>
 $"{property.PropertyType.Show(detail)} {property.Name}{property.Parameters.Show('[', ']', false, detail)} " +
 $"{{ {(property.GetMethod != null ? "get; " : "")}{(property.SetMethod != null ? "set; " : "")}}}";
예제 #4
0
 public static string Show(this MethodDefinition method, FormatDetail detail) =>
 $"{method.ReturnType.Show(detail)} {method.Name}{method.GenericParameters.Show(detail)}{method.Parameters.Show('(', ')', true, detail)}";
예제 #5
0
 private static string Show(this IList <ParameterDefinition> ps, char open, char close, bool openCloseIfEmpty, FormatDetail detail) =>
 ps.Any() ? $"{open}{string.Join(", ", ps.Select(p => p.Show(detail)))}{close}" : openCloseIfEmpty ? $"{open}{close}" : "";
예제 #6
0
 private static string ShowGenArgs(this IList <TypeReference> types, FormatDetail detail) =>
 types.Any() ? $"<{string.Join(", ", types.Select(type => type.Show(detail)))}>" : "";
예제 #7
0
 private static string Show(this IList <GenericParameter> ps, FormatDetail detail) =>
 ps.Any() ? $"<{string.Join(", ", ps.Select(p => p.Show(detail)))}>" : "";