-
Notifications
You must be signed in to change notification settings - Fork 2
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
Moq1100 incorrectly firing on nullable parameters #172
Comments
@marcovr Thank you for reporting this issue. Would you be able to try a private to ensure this issue is corrected? Moq.Analyzers.0.2.0-g7dd22517f7.nupkg |
Thanks @rjmurillo! However, I noticed that it introduced another (possibly unintended?) change in behaviour. Consider the following example: var mock = new Mock<IFoo>();
mock.Setup(m => m.DoSomething(42)).Returns((long bar) => true);
public interface IFoo
{
bool DoSomething(long bar);
} In this case, the analyzer now reports mock.Setup(m => m.DoSomething((long)42)).Returns((long bar) => true); or change the signature of the return lambda: mock.Setup(m => m.DoSomething(42)).Returns((int bar) => true); I don't really like the variant with a cast as it causes other analyzers to report an unnecessary cast. Edit: The second variant causes an Exception to be thrown:
|
Thanks @marcovr for your patience and the additional test cases; I've added them to the suite. You're right, the updated type conversion detection method caused a regression. In the case there was an var mock = new Mock<IFoo>();
mock.Setup(m => m.DoSomething(42)).Returns((long bar) => true);
mock.Setup(m => m.DoSomethingElse(42)).Returns((long var) => true);
public interface IFoo
{
bool DoSomething(long bar);
bool DoSomethingElse(object bar);
} In the I have another private for you to try: Moq.Analyzers.0.2.0-gf735a830fe.nupkg |
Thanks for the quick fix @rjmurillo! |
@marcovr Thank you for your help and patience. I've published a new version of the package with this bug fix: https://www.nuget.org/packages/Moq.Analyzers/0.1.2 |
Analyzer Moq1100 is incorrectly firing in the following case:
The analyzer reports:
Note: this not only happens with
object
but also other typesThe text was updated successfully, but these errors were encountered: