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(ConsoleColor.DarkGray, '"');
|
||||
}
|
||||
|
||||
Write('.');
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -332,12 +334,11 @@ namespace CliFx.Formatting
|
||||
Write(ConsoleColor.DarkGray, '"');
|
||||
Write(defaultValue.ToString(CultureInfo.InvariantCulture));
|
||||
Write(ConsoleColor.DarkGray, '"');
|
||||
}
|
||||
}
|
||||
|
||||
Write('.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WriteLine();
|
||||
}
|
||||
|
||||
@@ -54,9 +54,11 @@ namespace CliFx.Utils.Extensions
|
||||
return array;
|
||||
}
|
||||
|
||||
public static bool IsToStringOverriden(this Type type) =>
|
||||
type.GetMethod(nameof(ToString), Type.EmptyTypes) !=
|
||||
typeof(object).GetMethod(nameof(ToString), Type.EmptyTypes);
|
||||
public static bool IsToStringOverriden(this Type type)
|
||||
{
|
||||
var toStringMethod = type.GetMethod(nameof(ToString), Type.EmptyTypes);
|
||||
return toStringMethod?.GetBaseDefinition()?.DeclaringType != toStringMethod?.DeclaringType;
|
||||
}
|
||||
|
||||
// Types supported by `Convert.ChangeType(...)`
|
||||
private static readonly HashSet<Type> ConvertibleTypes = new()
|
||||
|
||||
Reference in New Issue
Block a user