Best practice analyzers #34
Replies: 8 comments 13 replies
-
Love it! Here's a few I can think of:
|
Beta Was this translation helpful? Give feedback.
-
Huh?? Don't use |
Beta Was this translation helpful? Give feedback.
-
Yeah this would be great! Coincidentally I've actually been working on some VSIX threading analyzers. Despite its name, the Microsoft.VisualStudio.Threading library is general-purpose and used by a variety of applications, not just Visual Studio. So its analyzers (as awesome as they are) are also quite general in nature and don't include all specific requirements for Visual Studio extensions. My repo is still private at the moment but I was intending to make it public. @madskristensen I've just sent you a link to it if you'd like to take a look. I'd be happy to merge my analyzers into a new project, or you're welcome to take my project and rename it as a starting point. |
Beta Was this translation helpful? Give feedback.
-
Some suggestions:
|
Beta Was this translation helpful? Give feedback.
-
This does not require its own analyzer. Your analyzer package can depend on https://www.nuget.org/packages/Microsoft.CodeAnalysis.BannedApiAnalyzers/ and then add the method to avoid to the AdditionalFiles. |
Beta Was this translation helpful? Give feedback.
-
Regarding where this analyzer project lives, from past experience, having the analyzers project in the same repository as the toolkit would be much easier to manage. If you make changes to the toolkit that requires changes to an analyzer, it can all be done in one pull request. Plus the version of the toolkit and analyzer can stay in sync. |
Beta Was this translation helpful? Give feedback.
-
I've just created #172 which adds a code analysis project and an initial code analyzer. The code analyzer is one that wasn't mentioned here, but I thought it would be really useful and a nice simple one to start things off. It detects calls to any |
Beta Was this translation helpful? Give feedback.
-
I think it might be helpful to create an analyzer package that checks for best practices and other patterns that make it easier to write extensions. Here are some ideas:
Task.Forget()
andTask.FileAndForget()
to use the Toolkit'sTask.ForgetAndLogOnFailure()
insteadIVsOutputWindowPane.OutputStringThreadSafe()
but useOutputString()
insteadWhat other analyzers would be helpful?
Beta Was this translation helpful? Give feedback.
All reactions