It is quite common that you will find some issues during updating development environment to a newer version – in this case to Visual Studio 2015. In projects that use StyleCop for code analysis you can get SA0120 CSharp.CsParser error.

It seems that it is internal StyleCop error. You are not able to find information about SA0102 error in StyleCop warning messages’ documentation. It is good that this error will not occur after opening project in Visual Studio 2015. It will occur after your will use some features introduced in C# 6.0. I think that most of us should be aware of this situation. You should remember that StyleCop has not been updated since April 2014 (last version is StyleCop


SA0120 Error

You have three options to solve this issue:

  1. Do not use new features that have been introduced in C# 6.0 – but probably this is not an option for anybody.
  2. You could try to suppress rule related to this error message. But unfortunate you are not able to do that. You can only exclude whole file with that issue for StyleCop check. To do that you need to add following lines to project configuration file (.csproj):
    <Compile Include="filename.cs">

    I think that you will agree with me that it is not a good solution. We are disabling all rules for selected files and we will not be able to check correctness of code from this file against other StyleCop rules.

  3. And the last one. You can use extended version of StyleCop – Visual StyleCop. This is copy of official StyleCop that has been adjusted to work with Visual Studio 2015 and C# 6.0. You can install it from NuGet:
    Nuget: Visual-StyleCop

    Nuget: Visual-StyleCop

    You should remember to delete all entries from project configuration file (.csproj) related to official StyleCop.

I would advise to use 3rd method for all already existing projects. For new ones I would use StyleCopAnalyzers.