From my testing in .NET 9, this IsAssignableTo call in the TryConvertFromChecked function will never return true:
|
else if (typeof(TOther).IsAssignableTo(typeof(IBinaryInteger<>))) |
|
{ |
|
if (TOther.TryConvertToChecked<BigInteger>(value, out var intValue)) |
|
{ |
|
result = (BigDecimal)intValue; |
|
return true; |
|
} |
|
} |
It doesn't work with any of the built-in types, including BigInteger. I believe this has something to do with parameterless generic types being considered a completely different type under the hood than one with a defined parameter.
I don't think there's a solution that would be better than just removing that check completely and simply attempting to convert to BigInteger right off the bat.