Ashthos / Cake.StyleCop

Stylecop implementation for the CakeBuild build system.
MIT License
5 stars 14 forks source link

c#6 features cause: SA0102: A syntax error has been discovered in file #8

Open miketonguk opened 7 years ago

miketonguk commented 7 years ago

String interpolation and null propagation usage in code results in errors reporting from StyleCop.

I pulled the source and got the same error generated when trying to build Cake.StyleCop with the Target "Code-Quality"

Stylecop: Starting analysis Pass 1: C:/code/GitHub/Cake.StyleCop/Cake.Stylecop - /Namespaces.cs Pass 1: C:/code/GitHub/Cake.StyleCop/Cake.Stylecop - /StylecopAlias.cs Pass 1: C:/code/GitHub/Cake.StyleCop/Cake.Stylecop - /StyleCopHandlers.cs Pass 1: C:/code/GitHub/Cake.StyleCop/Cake.Stylecop - /StyleCopReportSettings.cs Pass 1: C:/code/GitHub/Cake.StyleCop/Cake.Stylecop - /StylecopRunner.cs SA0102: A syntax error has been discovered in file C:/code/GitHub/Cake.StyleCop/Cake.Stylecop/StylecopRunner.cs on line 53. @ Line 53 Pass 1: C:/code/GitHub/Cake.StyleCop/Cake.Stylecop - /Properties/AssemblyInfo.cs Pass 1: C:/code/GitHub/Cake.StyleCop/Cake.Stylecop - /StyleCopSettings.cs SA0102: A syntax error has been discovered in file C:/code/GitHub/Cake.StyleCop/Cake.Stylecop/StyleCopSettings.cs on line 32. @ Line 32 Pass 1: C:/code/GitHub/Cake.StyleCop/Cake.Stylecop - /StyleCopSettingsExtensions.cs 2 violations encountered. Stylecop: Finished analysis

Ashthos commented 7 years ago

This is a known issue with the version 4.7.49 of stylecop we are using. I'll investigate the upgrade path to the new 4.7.55 which supports c#6 syntax.

miketonguk commented 7 years ago

I rebuilt the addin using the latest assemblies and it seems to work fine just looks like an easy fix. Want me to do a pull request?

miketonguk commented 7 years ago

Ah, I see the dependent package Stylecop.Rules hasn't been update to 4.7.49 yet, hence the problem. The styleCop nuget package which is 4.7.55 doesn't include the StyleCop.CSharp.Rules.dll assembly so that won't work either.

miketonguk commented 7 years ago

If you remove the existing nuget package (which hasn't had an update since 2015) and replace it with the StyleCop.MSBuild one you'll get all the required assemblies at the correct version and this will fix the issue.

REMOVE: <package id="StyleCop.Rules" version="4.7.49" targetFramework="net45" /> ADD: <package id="StyleCop.MSBuild" version="4.7.55.0" targetFramework="net45" developmentDependency="true" />