So, I've been thinking about the future of StyleCop while updating the ReSharper plugin.
There are two big problems with the project, that I can see. Firstly, it's stagnated, with no new rules, etc. It's ripe for a shakeup. Secondly, and more importantly, the code is based on a custom C# parser that only supports up to C#5, and doesn't know anything about C#6.
The DotNetAnalyzers/StyleCopAnalyzers project is a port of StyleCop to Visual Studio 2015's Roslyn analyzers. This gives it a lot of benefits:
- C#6 support
- Let someone else (Microsoft!) worry about maintaining the C# parser
- Since it reuses the Roslyn syntax tree, there is less overhead from the custom parser
- Rules run as you type, and as you build (no more need for the msbuild task, or the VS extension)
Furthermore, they've already added a couple of new rules to work with C#6. Whatever happens to StyleCop "Classic", we need to involve and play nice with this project.
The downside is that it's VS2015 only, so that leaves out current users of the msbuild task, VS support + ReSharper for earlier versions. I think we can unify things, to an extent.
Here's my half thought out plan:
- Deprecate this repo, splitting the projects up into their own repos.
- Create a new
stylecop-msbuild
repo that is a task that wraps the Roslyn analysers. You don't need VS2015 installed, you don't need to be using the Roslyn toolchain, you just need .net 4.5 installed. I think this is reasonable. Now the msbuild project would simply rely on the Roslyn analyzers to do the work.
- Create a new
stylecop-visualstudio
repo, to create a simple Visual Studio extension to add Tools menu items to run the Roslyn analysers in an external process, and display the results in the Error list window.
- Create a new
stylecop-resharper
repo. This would contain the existing ReSharper plugin that I'm working on. It would use the existing C# parser (annoyingly, as ReSharper has already parsed the file, but that would mean a complete rewrite otherwise). This would work for VS2013 and below. VS2015 and above would be encouraged to install the Roslyn analysers, as ReSharper plays nicely there. For VS2015, the extension would automatically configure the users settings + provide code cleanup, etc.
This, to an extent, sunsets StyleCop "Classic" as such. The responsibility for creating new rules, and parsing rules, would move over to DotNetAnalyzers/StyleCopAnalyzers (which you can argue has already happened, thanks to the stagnation of the project), but provides a way for users of the other tools to stay up to date, even if they don't use VS2015.
Thoughts?