Fluentassertions: InvalidCastException when using NotBeOfType<T>

Created on 13 Jul 2016  路  5Comments  路  Source: fluentassertions/fluentassertions

There is a copy/paste bug in the implementation of the generic NotBeOfType assertion in ReferenceTypeAssertions: when the method attempts to create the return value, it casts Subject to the type we have just asserted it NOT to be.
Instead the method signature should be changed, so the return type is AndConstraint and then no casts are needed.
See my code comment in PR #413 for details.

bug

All 5 comments

Great catch, @snboisen. This should have a test too just to make sure it doesn't get reintroduced. Thanks!

Released through 4.13

Looks like this has been reintroduced. I'm using 4.7.0 and I have the same issue. The decompiler tells me that NotBeOfType is casting the type to T that it should not be again.

4.7?

Haha, apologies. I thought 4.7.0 was the latest. Just updated to 5.6.0 and it's fine!

Was this page helpful?
0 / 5 - 0 ratings