mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
Don't write default value in help text for types that don't override ToString()
This commit is contained in:
@@ -321,6 +321,8 @@ namespace CliFx.Formatting
|
|||||||
Write(element.ToString(CultureInfo.InvariantCulture));
|
Write(element.ToString(CultureInfo.InvariantCulture));
|
||||||
Write(ConsoleColor.DarkGray, '"');
|
Write(ConsoleColor.DarkGray, '"');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Write('.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -332,10 +334,9 @@ namespace CliFx.Formatting
|
|||||||
Write(ConsoleColor.DarkGray, '"');
|
Write(ConsoleColor.DarkGray, '"');
|
||||||
Write(defaultValue.ToString(CultureInfo.InvariantCulture));
|
Write(defaultValue.ToString(CultureInfo.InvariantCulture));
|
||||||
Write(ConsoleColor.DarkGray, '"');
|
Write(ConsoleColor.DarkGray, '"');
|
||||||
|
Write('.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Write('.');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,9 +54,11 @@ namespace CliFx.Utils.Extensions
|
|||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsToStringOverriden(this Type type) =>
|
public static bool IsToStringOverriden(this Type type)
|
||||||
type.GetMethod(nameof(ToString), Type.EmptyTypes) !=
|
{
|
||||||
typeof(object).GetMethod(nameof(ToString), Type.EmptyTypes);
|
var toStringMethod = type.GetMethod(nameof(ToString), Type.EmptyTypes);
|
||||||
|
return toStringMethod?.GetBaseDefinition()?.DeclaringType != toStringMethod?.DeclaringType;
|
||||||
|
}
|
||||||
|
|
||||||
// Types supported by `Convert.ChangeType(...)`
|
// Types supported by `Convert.ChangeType(...)`
|
||||||
private static readonly HashSet<Type> ConvertibleTypes = new()
|
private static readonly HashSet<Type> ConvertibleTypes = new()
|
||||||
|
|||||||
Reference in New Issue
Block a user