Detect invalid access to IsFailure
on ServiceResult<T>
objects.
#43
Labels
new analyzer
Suggestion for a new analyzer to add
IsFailure
on ServiceResult<T>
objects.
#43
Calling
.Value
on aServiceResult<T>
will callVerify()
, which will throw if the result is a failure.However, this semantic might not be obvious, so a developer might think this is perfectly fine error checking code:
Instead, this code would throw.
It seems like accessing to the
.Value
property before accessing the.IsFailure
is always a bug, and also detectable.A common case that is not a bug would be using the
Verify()
semantic of.Value
to throw on failure. In this case, explicitly accessing.IsFailure
would not be needed.The text was updated successfully, but these errors were encountered: