-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
IsInstanceOf<T>() is not consistent accross types #68
Comments
Now I understand where it comes from. IsInstanceOf has no interest for actual value type. |
Ultimately, I re implemented IsInstanceOf with the same contract, but it is now made available to all types |
Since:
I finally changes the implementation so that a nullable type without a value may succeed if it is the same nullable type. |
Ok, as I usually say for such edge cases: let's see the feedback we get, if |
I think that there is indeed no real use case for such edge case checks (on T |
I fully agree with your statement, but I lack the energy for longer |
While working on #66 I realized that
IsInstanceOf<Person>()
fails for null values (NullRefExceprion), but it works there:Check.That( (int?) null).IsInstanceOf<int?>()
.It raises multiple questions:
1. is this ok?
I do not think so.
2. What should be the behaviour?
Based on the check name, I propose that null always fail
3. What should we do for Nullables?
Reminder: Nullable types cannot be identified as such at compilation time. At run time, they are either null or a value of the underlying type. As such, GetType() behaves as expected, either throwing a NullRefExc or the appropriate struct type. Furthermore Nullable cannot be inherited from.
It implies that the nullableness can only be checked at compilation time, Therefore IsInstanceOf<int ?> does not bring any value. By the same token,
Check.That((int?) 4).IsInstanceOf<T>()
can only succeed for T= int?The text was updated successfully, but these errors were encountered: