WiseTechGlobal / WTG.Analyzers

Analyzers from WiseTech Global to enforce our styles, behaviours, and prevent common mistakes.
Other
16 stars 3 forks source link

Add Analyzer to forbid MSBuildLocator.RegisterDefaults() #187

Closed yaakov-h closed 2 years ago

yaakov-h commented 2 years ago

I haven't done a code-fix here, but I don't think it's strictly necessary.

Closes #186. Tracked by WI00546062.

brian-reichle commented 2 years ago

I haven't done a code-fix here, but I don't think it's strictly necessary.

I'm not sure it would be practical anyway. We can't direct people to use our internal api's because this is a public analyzer. I can see a few different strategies to selecting the version and no clear path to selecting which one to use.

Actually, if we were to have a code fix, the most sensible would probably be "Earliest version greater than or equal to the version being referenced at build time.

yaakov-h commented 2 years ago

Actually, if we were to have a code fix, the most sensible would probably be "Earliest version greater than or equal to the version being referenced at build time.

That wouldn't exactly work either due to interactions between MSBuild and global.json, we would generally just pick up VS2019 on machines that still have it when we really want to use VS2022. The whole thing is a mess tbh but I've found that blindly taking latest version is the best solution when the user can't choose something themselves and the most stable in the long run as we find any problems and fix them as we adopt new minor releases.