8000 PH2048: False negative for inferred-type constructor new() · Issue #798 · philips-software/roslyn-analyzers · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

PH2048: False negative for inferred-type constructor new() #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

Open
gmdunlop opened this issue Apr 10, 2025 · 0 comments
Open

PH2048: False negative for inferred-type constructor new() #798

gmdunlop opened this issue Apr 10, 2025 · 0 comments

Comments

@gmdunlop
Copy link
Contributor

Currently, the analyzer will fire only for constructors which explicitly declare a type:

Mock<DependencyType> dependencyMock = new Mock<DependencyType>();

But will not fire when the type is inferred:

Mock<DependencyType> dependencyMock = new();

Ideally, we should be flagging this at compile time to avoid runtime exceptions (e.g., System.ArgumentException: Can not instantiate proxy of class ... Could not find a constructor that would match given arguments).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0