mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-14 16:02:50 +08:00
Fallback to using GetConverter if GetIntrinsicConverter doesn't find one.
This commit is contained in:
parent
2be8e8da4e
commit
8f2a859087
@ -82,12 +82,17 @@ internal static class TypeConverterHelper
|
|||||||
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026", Justification = "Feature switches are not currently supported in the analyzer")]
|
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026", Justification = "Feature switches are not currently supported in the analyzer")]
|
||||||
static TypeConverter? GetConverter()
|
static TypeConverter? GetConverter()
|
||||||
{
|
{
|
||||||
if (!IsGetConverterSupported)
|
if (IsGetConverterSupported)
|
||||||
{
|
{
|
||||||
return GetIntrinsicConverter(typeof(T));
|
// Spectre.Console.TypeConverterHelper.IsGetConverterSupported has been set so
|
||||||
|
// fallback to original behavior
|
||||||
|
return TypeDescriptor.GetConverter(typeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
return TypeDescriptor.GetConverter(typeof(T));
|
// otherwise try and use the intrinsic converter. if we can't find one, then
|
||||||
|
// try and use GetConverter.
|
||||||
|
var intrinsicConverter = GetIntrinsicConverter(typeof(T));
|
||||||
|
return intrinsicConverter ?? TypeDescriptor.GetConverter(typeof(T));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user