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 220.127.116.11).
You have three options to solve this issue:
- Do not use new features that have been introduced in C# 6.0 – but probably this is not an option for anybody.
- 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"> <ExcludeFromStyleCop>True</ExcludeFromStyleCop> </Compile>
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.
- 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:
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.