Skip to content

Commit 4cb8ca3

Browse files
committed
Merge remote-tracking branch 'DotNetAnalyzers/stabilization'
2 parents 2a502fd + 2fcf04f commit 4cb8ca3

9 files changed

Lines changed: 37 additions & 21 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/StyleCop.Analyzers.CodeFixes.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,9 @@
214214
<Analyzer Include="..\..\packages\AsyncUsageAnalyzers.1.0.0-alpha003\analyzers\dotnet\AsyncUsageAnalyzers.dll" />
215215
<Analyzer Include="..\..\packages\Microsoft.CodeAnalysis.Analyzers.1.0.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.Analyzers.dll" />
216216
<Analyzer Include="..\..\packages\Microsoft.CodeAnalysis.Analyzers.1.0.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll" />
217-
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-rc1\analyzers\dotnet\cs\Newtonsoft.Json.dll" />
218-
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-rc1\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll" />
219-
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-rc1\analyzers\dotnet\cs\StyleCop.Analyzers.dll" />
217+
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-rc2\analyzers\dotnet\cs\Newtonsoft.Json.dll" />
218+
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-rc2\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll" />
219+
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-rc2\analyzers\dotnet\cs\StyleCop.Analyzers.dll" />
220220
</ItemGroup>
221221
<ItemGroup>
222222
<ProjectReference Include="..\StyleCop.Analyzers\StyleCop.Analyzers.csproj">

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<package id="Microsoft.Composition" version="1.0.27" targetFramework="portable-net45+win8" />
1010
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="portable45-net45+win8" />
1111
<package id="NuGet.CommandLine" version="2.8.3" targetFramework="portable45-net45+win8" />
12-
<package id="StyleCop.Analyzers" version="1.0.0-rc1" targetFramework="portable45-net45+win8" developmentDependency="true" />
12+
<package id="StyleCop.Analyzers" version="1.0.0-rc2" targetFramework="portable45-net45+win8" developmentDependency="true" />
1313
<package id="System.Collections.Immutable" version="1.1.36" targetFramework="portable45-net45+win8" />
1414
<package id="System.Reflection.Metadata" version="1.0.21" targetFramework="portable45-net45+win8" />
1515
<package id="Tvl.NuGet.BuildTasks" version="1.0.0-alpha002" targetFramework="portable45-net45+win8" />

StyleCop.Analyzers/StyleCop.Analyzers.Test/StyleCop.Analyzers.Test.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,9 @@
394394
<Analyzer Include="..\..\packages\AsyncUsageAnalyzers.1.0.0-alpha003\analyzers\dotnet\AsyncUsageAnalyzers.dll" />
395395
<Analyzer Include="..\..\packages\Microsoft.CodeAnalysis.Analyzers.1.0.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.Analyzers.dll" />
396396
<Analyzer Include="..\..\packages\Microsoft.CodeAnalysis.Analyzers.1.0.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll" />
397-
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-rc1\analyzers\dotnet\cs\Newtonsoft.Json.dll" />
398-
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-rc1\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll" />
399-
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-rc1\analyzers\dotnet\cs\StyleCop.Analyzers.dll" />
397+
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-rc2\analyzers\dotnet\cs\Newtonsoft.Json.dll" />
398+
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-rc2\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll" />
399+
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-rc2\analyzers\dotnet\cs\StyleCop.Analyzers.dll" />
400400
</ItemGroup>
401401
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
402402
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

StyleCop.Analyzers/StyleCop.Analyzers.Test/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<package id="Microsoft.CodeAnalysis.Workspaces.Common" version="1.0.0" targetFramework="net452" />
99
<package id="Microsoft.Composition" version="1.0.27" targetFramework="net452" />
1010
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
11-
<package id="StyleCop.Analyzers" version="1.0.0-rc1" targetFramework="net452" developmentDependency="true" />
11+
<package id="StyleCop.Analyzers" version="1.0.0-rc2" targetFramework="net452" developmentDependency="true" />
1212
<package id="System.Collections.Immutable" version="1.1.36" targetFramework="net452" />
1313
<package id="System.Reflection.Metadata" version="1.0.21" targetFramework="net452" />
1414
<package id="xunit" version="2.1.0-beta4-build3109" targetFramework="net452" />

StyleCop.Analyzers/StyleCop.Analyzers/StyleCop.Analyzers.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,9 @@
382382
<Analyzer Include="..\..\packages\AsyncUsageAnalyzers.1.0.0-alpha003\analyzers\dotnet\AsyncUsageAnalyzers.dll" />
383383
<Analyzer Include="..\..\packages\Microsoft.CodeAnalysis.Analyzers.1.0.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.Analyzers.dll" />
384384
<Analyzer Include="..\..\packages\Microsoft.CodeAnalysis.Analyzers.1.0.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll" />
385-
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-rc1\analyzers\dotnet\cs\Newtonsoft.Json.dll" />
386-
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-rc1\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll" />
387-
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-rc1\analyzers\dotnet\cs\StyleCop.Analyzers.dll" />
385+
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-rc2\analyzers\dotnet\cs\Newtonsoft.Json.dll" />
386+
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-rc2\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll" />
387+
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-rc2\analyzers\dotnet\cs\StyleCop.Analyzers.dll" />
388388
</ItemGroup>
389389
<ItemGroup>
390390
<EmbeddedResource Include="DocumentationRules\DocumentationResources.resx">

StyleCop.Analyzers/StyleCop.Analyzers/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<package id="Microsoft.Composition" version="1.0.27" targetFramework="portable-net45+win8" />
88
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="portable45-net45+win8" />
99
<package id="NuGet.CommandLine" version="2.8.3" targetFramework="portable45-net45+win8" />
10-
<package id="StyleCop.Analyzers" version="1.0.0-rc1" targetFramework="portable45-net45+win8" developmentDependency="true" />
10+
<package id="StyleCop.Analyzers" version="1.0.0-rc2" targetFramework="portable45-net45+win8" developmentDependency="true" />
1111
<package id="System.Collections.Immutable" version="1.1.36" targetFramework="portable45-net45+win8" />
1212
<package id="System.Reflection.Metadata" version="1.0.21" targetFramework="portable45-net45+win8" />
1313
<package id="Tvl.NuGet.BuildTasks" version="1.0.0-alpha002" targetFramework="portable45-net45+win8" />

StyleCop.Analyzers/StyleCopTester/Program.cs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private static async Task MainAsync(string[] args, CancellationToken cancellatio
7777

7878
MSBuildWorkspace workspace = MSBuildWorkspace.Create();
7979
string solutionPath = args.SingleOrDefault(i => !i.StartsWith("/", StringComparison.Ordinal));
80-
Solution solution = workspace.OpenSolutionAsync(solutionPath, cancellationToken).Result;
80+
Solution solution = await workspace.OpenSolutionAsync(solutionPath, cancellationToken).ConfigureAwait(false);
8181

8282
Console.WriteLine($"Loaded solution in {stopwatch.ElapsedMilliseconds}ms");
8383

@@ -373,13 +373,29 @@ private static async Task<ImmutableDictionary<ProjectId, ImmutableArray<Diagnost
373373
/// <returns>A list of diagnostics inside the project</returns>
374374
private static async Task<ImmutableArray<Diagnostic>> GetProjectAnalyzerDiagnosticsAsync(ImmutableArray<DiagnosticAnalyzer> analyzers, Project project, CancellationToken cancellationToken)
375375
{
376-
Compilation compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
376+
var supportedDiagnosticsSpecificOptions = new Dictionary<string, ReportDiagnostic>();
377+
foreach (var analyzer in analyzers)
378+
{
379+
foreach (var diagnostic in analyzer.SupportedDiagnostics)
380+
{
381+
// make sure the analyzers we are testing are enabled
382+
supportedDiagnosticsSpecificOptions[diagnostic.Id] = ReportDiagnostic.Default;
383+
}
384+
}
385+
386+
// Report exceptions during the analysis process as errors
387+
supportedDiagnosticsSpecificOptions.Add("AD0001", ReportDiagnostic.Error);
388+
389+
// update the project compilation options
390+
var modifiedSpecificDiagnosticOptions = supportedDiagnosticsSpecificOptions.ToImmutableDictionary().SetItems(project.CompilationOptions.SpecificDiagnosticOptions);
391+
var modifiedCompilationOptions = project.CompilationOptions.WithSpecificDiagnosticOptions(modifiedSpecificDiagnosticOptions);
392+
var processedProject = project.WithCompilationOptions(modifiedCompilationOptions);
393+
394+
Compilation compilation = await processedProject.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
377395
CompilationWithAnalyzers compilationWithAnalyzers = compilation.WithAnalyzers(analyzers, cancellationToken: cancellationToken);
378396

379397
var allDiagnostics = await compilationWithAnalyzers.GetAllDiagnosticsAsync().ConfigureAwait(false);
380-
381-
// We want analyzer diagnostics and analyzer exceptions
382-
return allDiagnostics.RemoveRange(compilation.GetDiagnostics());
398+
return allDiagnostics;
383399
}
384400

385401
private static void PrintHelp()

StyleCop.Analyzers/StyleCopTester/StyleCopTester.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@
145145
<Analyzer Include="..\..\packages\AsyncUsageAnalyzers.1.0.0-alpha003\analyzers\dotnet\AsyncUsageAnalyzers.dll" />
146146
<Analyzer Include="..\..\packages\Microsoft.CodeAnalysis.Analyzers.1.0.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.Analyzers.dll" />
147147
<Analyzer Include="..\..\packages\Microsoft.CodeAnalysis.Analyzers.1.0.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll" />
148-
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-rc1\analyzers\dotnet\cs\Newtonsoft.Json.dll" />
149-
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-rc1\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll" />
150-
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-rc1\analyzers\dotnet\cs\StyleCop.Analyzers.dll" />
148+
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-rc2\analyzers\dotnet\cs\Newtonsoft.Json.dll" />
149+
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-rc2\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll" />
150+
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-rc2\analyzers\dotnet\cs\StyleCop.Analyzers.dll" />
151151
</ItemGroup>
152152
<ItemGroup>
153153
<ProjectReference Include="..\StyleCop.Analyzers.CodeFixes\StyleCop.Analyzers.CodeFixes.csproj">

StyleCop.Analyzers/StyleCopTester/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<package id="Microsoft.CodeAnalysis.VisualBasic.Workspaces" version="1.0.0" targetFramework="net45" />
1010
<package id="Microsoft.CodeAnalysis.Workspaces.Common" version="1.0.0" targetFramework="net45" />
1111
<package id="Microsoft.Composition" version="1.0.27" targetFramework="net45" />
12-
<package id="StyleCop.Analyzers" version="1.0.0-rc1" targetFramework="net452" developmentDependency="true" />
12+
<package id="StyleCop.Analyzers" version="1.0.0-rc2" targetFramework="net452" developmentDependency="true" />
1313
<package id="System.Collections.Immutable" version="1.1.36" targetFramework="net45" />
1414
<package id="System.Reflection.Metadata" version="1.0.21" targetFramework="net45" />
1515
</packages>

0 commit comments

Comments
 (0)