NuGet / Home

Repo for NuGet Client issues
Other
1.5k stars 253 forks source link

Investigate using Analyzer for the explicit/implicit type Coding Guideline #12574

Open donnie-msft opened 1 year ago

donnie-msft commented 1 year ago

Ideally, we wouldn't need a coding guideline if we have analyzers which enforce a standard for using implicit/explicit types. Besides consistency, the goal is reducing PR Review time identifying and responding to feedback on this guideline.

Investigate IDE0007 and IDE0008: 'var' preferences - .NET | Microsoft Learn and see the impact on our codebase.

If this works for the team, come up with a plan to implement it at once, or over time using suppressions.

donnie-msft commented 1 year ago

Was planning to look in learning week, but since zivkan is already jumped in on investigating, I'll assign to him for now.

zivkan commented 10 months ago

This never fits into my sprint, so I'm removing my assignment.

From memory, when I did very preliminary investigations, it's possible to tell the IDE (and dotnet format) to either "never use var", or "always use var (exception when it's impossible, like anonymous types)". Both of these rules results in thousands of violations that would need to be fixed in order to start enforcing the rule, so that no new violations are added. But there isn't an option for what this team wants "don't use var when the assignment is "obvious", otherwise always use var".

I still find this coding guideline incredibly frustrating, especially since if you look at other reps under github.com/dotnet/, or other popular repos on github that use .NET, nobody else seems to be doing the same as us. NuGet.Client wants to enforce something that appears to be relatively unique.

nkolev92 commented 4 days ago

This issue is missing a priority, so I'm gonna P3 this since I don't think there's any analyzers available that can do what we want it do.

Feel free to just change it to a different priority if you disagree, or bring it to triage by adding a NeedsTriageDiscussion label