Skip to content

TryConvertFromChecked check will never pass #37

@pipman3000-rettata

Description

@pipman3000-rettata

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions