-
Notifications
You must be signed in to change notification settings - Fork 746
Add type constraint for Throws and any method requiring Exception #2281
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
Comments
This is interesting.
So I'm for this. 👍 |
I think the absence of a where clause is due to the fact that the original implementation was non-generic, taking a Type as an argument. We just translated what was already there to generic form. |
@NN--- are you interested in submitting a PR for this? |
@jnm2 Thanks. I didn't think about this. I don't think anyone throws object not subtype of Exception. I can submit PR when I have time for this. |
Picked this up (First issue / pr, experienced developer but new in contributing) |
@WdeBruin We're glad to have you! I removed the up-for-grabs label to signal that the work is yours and as soon as we can we'll assign you too. |
I did delve into this a bit deeper. Apparently the CLI wraps throws of other types than exception in a runtimewrappedexception, which actually does derive from Exception. |
I did not know this (https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.runtimewrappedexception?view=netframework-4.5#Remarks, emphasis mine):
|
By virtue of being compiled by the C# compiler, NUnit does already catch non-exceptions as We should still go ahead with the original change to document the fact that NUnit represents caught non-exception objects as NUnit could also unwrap the original object, which would be a breaking change and require us to reverse this PR. But I don't think we'd ever want to do that. |
Instead of code:
The code should be:
The text was updated successfully, but these errors were encountered: