-
-
Notifications
You must be signed in to change notification settings - Fork 798
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
Throwing an exception nulls any out parameters #342
Comments
Hi @JefWight, thanks for the report. Could you please post a brief but complete code example that reproduces this issue? (Please try to avoid doing reflection over Moq internals in the repro code. Try to show what you're attempting to do using the public API.) Thanks! |
Sorry, it looks like this was just a bug in the version our test tools was using (4.0.10827), but when I create a test project and use the latest version, it works correctly. For reference, here's the code that doesn't work in 4.0.10827:
Feel free to close this out. |
Thanks for replying. Since we're not fixing old versions :) I'll close this. |
I'm trying to abstract making web requests. I've written an interface to replace both the Request and Response portions. To enable the most complete support for mocking, the design is such that
void GetResponse(out IResponse response);
is expected to set the response value even on WebException (if the exception has a Response property that's an HttpWebResponse). This allows me to to use the interface to extract info about the response even in a WebException.In my test code, I've tried:
I've also tried approximately what I found on stack overflow by attempting to set a "callback" that would explicitly set the out parameter then throw:
While both approaches throw an exception as expected, neither of these approaches result in the out parameter being set in the calling code.
I suspect this has something to do with the way the reflection code is executing.
The text was updated successfully, but these errors were encountered: