1

I have recently downloaded R# 9.1 in order to integrate StyleCop into it. Everything passed well when I was installing both R# and its extension for StyleCop. However, when I go to my solution folder (in Visual Studio 2015) and right-click on one of my projects and click on "Run StyleCop" it displays this error:

Error message: Method not found

Initially I installed R# 9.2 and the result was the same, so I decided to go to 9.1 version. I reinstalled R# and StyleCop both once and multiple times the R#'s extension for integrating StyleCop.

Community
  • 1
  • 1
Georgi Stoimenov
  • 912
  • 1
  • 9
  • 16
  • Can you link to the exact R# extension you installed? – NikolaiDante Jan 07 '16 at 18:52
  • Here is the github reference which seem to be... empty: . And this ReSharper.StyleCop is only one extension that I can get from ReSharper's extension manager. – Georgi Stoimenov Jan 08 '16 at 07:03
  • I found a partial solution for the problem. I installed R#10 and used StyleCop by JetBrains extension which lead to having StyleCop's rules integrated into the R#'s(if I can express it that way) but if I try to use some of the StyleCop functionality explicitly("Run StyleCop" etc.) this error was showed:. It is not a clean solution but kinda will help a lot even so. – Georgi Stoimenov Jan 08 '16 at 09:37

1 Answers1

2

My current set up for R# and StyleCop is:

  • Resharper 10.0.1
  • StyleCop by JetBrains 4.8

enter image description here

Which gives this in R# options: enter image description here

This gives me R# validation of rules.

However, this doesn't give me right click run functionality.

So I had a click look around and found that StyleCop doesn't have an install for VS 2015, so I installed Visual StyleCop and have recreated your issue. If you are using Visual StyleCop it may be worth while adding an issue on their github.

enter image description here

Personally, I don't use the right click functionality, instead I get the warnings from a build via the StyleCop.MSBuild nuget package for each project I want to monitor:

enter image description here

Once I have no errors, I use StyleCop.Error.MSBuild to keep it that way, again from nuget:

enter image description here

The more modern way of doing this is to make use of the Analyzers feature of Visual Studio 2015, with StyleCop.Analyzers.

enter image description here

Even the Stylecop by Jet brains one treats this as the preferred implementation.. From the R# gallery

Automatically disable analysis if StyleCop.Analyzers is referenced in VS2015 (#20)

Moving to Stylecop.Analyzers, this would add them into the rules in the relevant *.ruleset file (same place as CodeAnalysis rules)

enter image description here

and you can run them via

enter image description here

Which has the same effect as right click Run StyleCop which you are trying to get working.

I.e. giving:

enter image description here

Any clarifications or further detail, please let me know.

NikolaiDante
  • 18,469
  • 14
  • 77
  • 117
  • Fantastic answer! The ReSharper extension uses StyleCop's own C# parser, rather than ReSharper's, which doesn't help with perf, and doesn't support C# 6. The ideal choice would be to rewrite the ReSharper extension on top of ReSharper's C# AST, but that's quite a Big Deal, and the StyleCopAnalyzers team have already done that on top of Roslyn. – citizenmatt Jan 08 '16 at 15:42
  • @citizenmatt thanks :-) That's interesting actually, I do struggle with perf on occasion, perhaps I should move to Analyzers sooner rather than later! – NikolaiDante Jan 08 '16 at 15:51
  • I really appreciate your fast and descriptive response. Actually what I wanted to do is to have the StyleCop functionality while working with both ReSharper and VS 2015. I will stick with StyleCop by Jetbrains only because the "StyleCop.MSBuild" and other extensions situation is a little cloudy for me. I get the main point(the last picture of your answer) but I don't know any of those extensions how work and I am afraid of using them because I can mess something up. – Georgi Stoimenov Jan 08 '16 at 19:03
  • If you want it in VS2015, for C# 6, try the [StyleCopAnalyzers](https://github.com/DotNetAnalyzers/StyleCopAnalyzers) project. It's a reimplementation of StyleCop as Roslyn based analysers. This understands C#6, and works nicely with 2015. If also this and also the "StyleCop by JetBrains" extension, the ReSharper extension will not do any analysis, but will set up ReSharper's settings to match what StyleCop expects. – citizenmatt Jan 11 '16 at 16:52