-
-
Notifications
You must be signed in to change notification settings - Fork 813
IDE0008 Use explicit type instead of 'var' #971
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
That's a rather questionable recommendation, IMHO. I think it's fine to decide between |
The var-declaration only occurs in 23 rows in one file only in the entire Mock-project. It is of cource much clearer to use explicit typing. Microsft recommends explicit typing "when the type matters", wich I suppose it always does in this type of framework/library. Maybe when you write a short program.cs with one Main-metod and maximum 20 rows of code you might say clear typing don't matter, but in most other cases type do matter , a lot. I don't like sloppy typing, it becomes a mess when an application grows in size. |
I remain unconvinced that Microsoft's recommendation is sound in each and every circumstance. Simple appeal to authority isn't a sufficient argument, and if they really wanted to categorically avoid If Microsoft's goal were to nudge us into explicitly specifying types, we'd also have to do that in many different places, e.g. for lambda parameter lists: In all honesty, I don't see a problem here. Let's leave However, thank you for caring about code quality, and for contributing to this project! |
(Btw. |
Well, this is not my decisiton, I just reported something that anoys me in code. I follow the VisualStudio recommendations as far it's possible in my code. My life gets somewhat easier then. |
Should it be better to always use specific typing and avoid the var-type at all. That is what is recomended by Microsoft itself.
I only found this issue 23 times in one file of the entire Mock-library, and that is only in the file MatchExpressionFixture.cs in the Mock.Tests(netcoreapp2.2).
This is found in Moq4 version 4.13.1.
The text was updated successfully, but these errors were encountered: