-
-
Notifications
You must be signed in to change notification settings - Fork 794
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
Mocking derived classes of Exception results in .Object being null #1337
Comments
I cannot reproduce this problem. using System;
using Moq;
Console.WriteLine(new Mock<myClass>().Object is Exception); // outputs "True"
public class myClass : Exception { } Everything works as it should, at least with the current version of Moq (4.18.4). Btw. do you even need to mock |
What happens if you remove "is Exception" btw I'm using windows apps SDK and .net 6 |
You can try that yourself. But I guess the problem doesn't lie with the code itself, but with the targeted platform. I don't know Windows App SDK (Microsoft keeps releasing a new app platform SDK once every two years or so, I've given up trying to keep up), any chance your code gets compiled ahead-of-time (AOT) / compiled to native code / Ready-to-Run (R2R) / whatever else it's called these days? If so, you're out of luck as Moq v4 & DynamicProxy, the library it's based on, heavily relies on Reflection, which may not be fully supported when compiling to native code. |
@KWodarczyk, I am going to close this issue due to missing repro code. If you want this to be looked into any further, please provide instructions how to reliably repro this issue and we can reopen. |
The text was updated successfully, but these errors were encountered: