<PackageReference Include="NUnit" Version="3.0.0-alpha-4" />

MethodHelper

public class MethodHelper
MethodHelper provides static methods for working with methods.
using System; using System.Globalization; using System.Reflection; using System.Text; namespace NUnit.Framework.Internal { public class MethodHelper { public static string GetDisplayName(MethodInfo method, object[] arglist) { StringBuilder stringBuilder = new StringBuilder(method.Name); if (method.IsGenericMethod) { stringBuilder.Append("<"); int num = 0; Type[] genericArguments = method.GetGenericArguments(); foreach (Type type in genericArguments) { if (num++ > 0) stringBuilder.Append(","); stringBuilder.Append(type.Name); } stringBuilder.Append(">"); } if (arglist != null) { stringBuilder.Append("("); for (int j = 0; j < arglist.Length; j++) { if (j > 0) stringBuilder.Append(","); stringBuilder.Append(GetDisplayString(arglist[j])); } stringBuilder.Append(")"); } return stringBuilder.ToString(); } private static string GetDisplayString(object arg) { string text = (arg == null) ? "null" : Convert.ToString(arg, CultureInfo.InvariantCulture); if (arg is double) { double num = (double)arg; if (double.IsNaN(num)) text = "double.NaN"; else if (double.IsPositiveInfinity(num)) { text = "double.PositiveInfinity"; } else if (double.IsNegativeInfinity(num)) { text = "double.NegativeInfinity"; } else if (num == 1.7976931348623157E+308) { text = "double.MaxValue"; } else if (num == -1.7976931348623157E+308) { text = "double.MinValue"; } else { if (text.IndexOf('.') == -1) text += ".0"; text += "d"; } } else if (arg is float) { float num2 = (float)arg; if (float.IsNaN(num2)) text = "float.NaN"; else if (float.IsPositiveInfinity(num2)) { text = "float.PositiveInfinity"; } else if (float.IsNegativeInfinity(num2)) { text = "float.NegativeInfinity"; } else if (num2 == 3.4028235E+38) { text = "float.MaxValue"; } else if (num2 == -3.4028235E+38) { text = "float.MinValue"; } else { if (text.IndexOf('.') == -1) text += ".0"; text += "f"; } } else if (arg is decimal) { decimal d = (decimal)arg; text = ((d == decimal.MinValue) ? "decimal.MinValue" : ((!(d == decimal.MaxValue)) ? (text + "m") : "decimal.MaxValue")); } else if (arg is long) { switch ((long)arg) { case long.MinValue: text = "long.MinValue"; break; default: text += "L"; break; } } else if (arg is ulong) { switch ((ulong)arg) { case 0: text = "ulong.MinValue"; break; default: text += "UL"; break; } } else if (arg is string) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("\""); string text2 = (string)arg; foreach (char c in text2) { stringBuilder.Append(EscapeControlChar(c)); } stringBuilder.Append("\""); text = stringBuilder.ToString(); } else if (arg is char) { text = "'" + EscapeControlChar((char)arg) + "'"; } else if (arg is int) { switch ((int)arg) { case int.MaxValue: text = "int.MaxValue"; break; case int.MinValue: text = "int.MinValue"; break; } } goto IL_0302; IL_01e3: text = "long.MaxValue"; goto IL_0302; IL_0226: text = "ulong.MaxValue"; goto IL_0302; IL_0302: return text; } private static string EscapeControlChar(char c) { switch (c) { case '\'': return "\\'"; case '"': return "\\\""; case '\\': return "\\\\"; case '': return "\\0"; case '': return "\\a"; case '\b': return "\\b"; case ' ': return "\\f"; case '\n': return "\\n"; case '\r': return "\\r"; case '\t': return "\\t"; case ' ': return "\\v"; case '…': case '
': case '
': return $"""{(int)c:""}"; default: return c.ToString(); } } } }