-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exclude lines & branches that come after calls to methods with [DoesNotReturn] #898
Comments
Thank's for reporting this, we have to understand if makes sense from coverage perspective, I mean that IL is emitted and not covered. |
I think of it as analogous to I'm tempted to take a swing at PR'ing it, even if all I get out of it is my own edification. |
I think you're right and I agree, actually that members are inside |
If it's just to add special handling of the |
Agreed, anyone using the throw helper pattern should just use the attribute explicitly. I took a whack at an implementation in #904, though there are a fair number of open questions. I haven't yet run it on my original project due to lack of time (I'm hoping to do that in the near future), but there are some simple test methods. |
Closed in #904 |
It'd be nice to be able to exclude lines, like
return;
, that follow methods that contractually never return from coverage. The BCL already ships with theDoesNotReturnAttribute
that could be used to indicate this.I stumble across this a lot when using the "throw helper"-pattern. An example from one my GitHub repos.
PoisonableBase<T>
has a method like so:Each method on
Throw
never returns.Even though I do have tests for each
PoisonType
, my reports will always include eachreturn
statement as uncovered:For non-void methods I can hack around this restriction by pretending these methods return an object, but for void returning methods you're out of luck.
I suspect this could be hacked into
Instrumentor.InstrumentIL
, but maybe there's a pass elsewhere that would be a better place.I think the logic to support this is something like:
a. Break the IL into runs based on branch targets
b. In each run, any instructions following a
call
orcallvirt
to a method with[DoesNotReturn]
is unreachablec. Record unreachable instructions somewhere
I considered just looking for
ret
andthrow
and so on, but I've convinced myself fall-through will break that.The text was updated successfully, but these errors were encountered: