Skip to content

Commit ebf6c5b

Browse files
authored
Merge pull request #2497 from sharwell/new-projects
Convert solution to the new project system
2 parents 4cda401 + d26b9a8 commit ebf6c5b

30 files changed

Lines changed: 293 additions & 2230 deletions

.nuget/packages.config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="Codecov" version="1.0.1" />
4-
<package id="NuGet.CommandLine" version="2.8.3" />
54
<package id="OpenCover" version="4.6.247-rc" />
65
<package id="ReportGenerator" version="2.3.5.0" targetFramework="net452" />
76
<package id="xunit.runner.console" version="2.1.0" targetFramework="net452" />
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project>
3+
4+
<PropertyGroup>
5+
<Description>An implementation of StyleCop rules using the .NET Compiler Platform</Description>
6+
<Product>StyleCop.Analyzers</Product>
7+
<Company>Tunnel Vision Laboratories, LLC</Company>
8+
<Copyright>Copyright © Tunnel Vision Laboratories, LLC 2015</Copyright>
9+
10+
<Version>1.1.0.35</Version>
11+
<FileVersion>1.1.0.35</FileVersion>
12+
<InformationalVersion>1.1.0-dev</InformationalVersion>
13+
</PropertyGroup>
14+
15+
<PropertyGroup>
16+
<EnableDefaultNoneItems>False</EnableDefaultNoneItems>
17+
</PropertyGroup>
18+
19+
<PropertyGroup>
20+
<LangVersion>6</LangVersion>
21+
<Features>strict</Features>
22+
</PropertyGroup>
23+
24+
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' != 'true'">
25+
<!-- Ideally this is always enabled, but that tends to hurt developer productivity -->
26+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
27+
</PropertyGroup>
28+
29+
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
30+
<DebugType>full</DebugType>
31+
<DebugSymbols>true</DebugSymbols>
32+
</PropertyGroup>
33+
34+
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
35+
<DebugType>pdbonly</DebugType>
36+
<DebugSymbols>true</DebugSymbols>
37+
</PropertyGroup>
38+
39+
<PropertyGroup>
40+
<!--
41+
Make sure any documentation comments which are included in code get checked for syntax during the build, but do
42+
not report warnings for missing comments.
43+
44+
CS1573: Parameter 'parameter' has no matching param tag in the XML comment for 'parameter' (but other parameters do)
45+
CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
46+
-->
47+
<GenerateDocumentationFile>True</GenerateDocumentationFile>
48+
<NoWarn>$(NoWarn),1573,1591</NoWarn>
49+
</PropertyGroup>
50+
51+
<ItemGroup>
52+
<PackageReference Include="AsyncUsageAnalyzers" Version="1.0.0-alpha003" PrivateAssets="all" />
53+
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta004" PrivateAssets="all" />
54+
</ItemGroup>
55+
56+
<ItemGroup>
57+
<None Include="$(MSBuildThisFileDirectory)*.ruleset" Link="%(Filename)%(Extension)" />
58+
59+
<!-- Show launchSettings.json in the project if it exists. -->
60+
<None Include="$(AppDesignerFolder)\launchSettings.json" Condition="Exists('$(AppDesignerFolder)\launchSettings.json')" />
61+
</ItemGroup>
62+
63+
<ItemGroup>
64+
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json">
65+
<Link>stylecop.json</Link>
66+
</AdditionalFiles>
67+
</ItemGroup>
68+
69+
</Project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project>
3+
4+
<!-- Special handling for embedded resources and generated files to show as nested in Solution Explorer -->
5+
<ItemGroup>
6+
<Compile Update="**\*.Designer.cs" DependentUpon="$([System.IO.Path]::ChangeExtension($([System.IO.Path]::GetFileNameWithoutExtension(%(Identity))), '.resx'))" />
7+
<EmbeddedResource Update="**\*.??-??.resx" DependentUpon="$([System.IO.Path]::ChangeExtension($([System.IO.Path]::GetFileNameWithoutExtension(%(Identity))), '.resx'))" />
8+
</ItemGroup>
9+
10+
<ItemGroup>
11+
<None Include="$(MSBuildProjectFileDirectory)$(AssemblyOriginatorKeyFile)" Link="%(Filename)%(Extension)" />
12+
</ItemGroup>
13+
14+
</Project>

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/CustomBatchFixAllProvider.cs

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,20 @@ public virtual async Task<CodeAction> GetFixAsync(
5151

5252
var documents = documentsAndDiagnosticsToFixMap.Keys.ToImmutableArray();
5353
var fixesBag = new List<CodeAction>[documents.Length];
54-
var options = new ParallelOptions() { CancellationToken = fixAllContext.CancellationToken };
55-
Parallel.ForEach(documents, options, (document, state, index) =>
54+
var fixOperations = new List<Task>(documents.Length);
55+
for (int index = 0; index < documents.Length; index++)
5656
{
57-
fixAllContext.CancellationToken.ThrowIfCancellationRequested();
57+
if (fixAllContext.CancellationToken.IsCancellationRequested)
58+
{
59+
break;
60+
}
61+
62+
var document = documents[index];
5863
fixesBag[index] = new List<CodeAction>();
59-
this.AddDocumentFixesAsync(document, documentsAndDiagnosticsToFixMap[document], fixesBag[index].Add, fixAllContext).Wait(fixAllContext.CancellationToken);
60-
});
64+
fixOperations.Add(this.AddDocumentFixesAsync(document, documentsAndDiagnosticsToFixMap[document], fixesBag[index].Add, fixAllContext));
65+
}
66+
67+
await Task.WhenAll(fixOperations).ConfigureAwait(false);
6168

6269
if (fixesBag.Any(fixes => fixes.Count > 0))
6370
{
@@ -129,15 +136,23 @@ public virtual async Task<CodeAction> GetFixAsync(
129136
{
130137
if (projectsAndDiagnosticsToFixMap != null && projectsAndDiagnosticsToFixMap.Any())
131138
{
132-
var options = new ParallelOptions() { CancellationToken = fixAllContext.CancellationToken };
133139
var fixesBag = new List<CodeAction>[projectsAndDiagnosticsToFixMap.Count];
134-
Parallel.ForEach(projectsAndDiagnosticsToFixMap.Keys, options, (project, state, index) =>
140+
var fixOperations = new List<Task>(projectsAndDiagnosticsToFixMap.Count);
141+
int index = -1;
142+
foreach (var project in projectsAndDiagnosticsToFixMap.Keys)
135143
{
136-
fixAllContext.CancellationToken.ThrowIfCancellationRequested();
144+
if (fixAllContext.CancellationToken.IsCancellationRequested)
145+
{
146+
break;
147+
}
148+
149+
index++;
137150
var diagnostics = projectsAndDiagnosticsToFixMap[project];
138151
fixesBag[index] = new List<CodeAction>();
139-
this.AddProjectFixesAsync(project, diagnostics, fixesBag[index].Add, fixAllContext).Wait(fixAllContext.CancellationToken);
140-
});
152+
fixOperations.Add(this.AddProjectFixesAsync(project, diagnostics, fixesBag[index].Add, fixAllContext));
153+
}
154+
155+
await Task.WhenAll(fixOperations).ConfigureAwait(false);
141156

142157
if (fixesBag.Any(fixes => fixes.Count > 0))
143158
{

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/FixAllContextHelper.cs

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace StyleCop.Analyzers.Helpers
55
{
6+
using System;
67
using System.Collections.Concurrent;
78
using System.Collections.Generic;
89
using System.Collections.Immutable;
@@ -84,19 +85,33 @@ public static async Task<ImmutableDictionary<Project, ImmutableArray<Diagnostic>
8485

8586
case FixAllScope.Solution:
8687
var projectsAndDiagnostics = new ConcurrentDictionary<Project, ImmutableArray<Diagnostic>>();
87-
var options = new ParallelOptions() { CancellationToken = fixAllContext.CancellationToken };
88-
Parallel.ForEach(project.Solution.Projects, options, proj =>
88+
var tasks = new List<Task>(project.Solution.ProjectIds.Count);
89+
Func<Project, Task> projectAction =
90+
async proj =>
91+
{
92+
if (fixAllContext.CancellationToken.IsCancellationRequested)
93+
{
94+
return;
95+
}
96+
97+
var projectDiagnostics = await fixAllContext.GetProjectDiagnosticsAsync(proj).ConfigureAwait(false);
98+
if (projectDiagnostics.Any())
99+
{
100+
projectsAndDiagnostics.TryAdd(proj, projectDiagnostics);
101+
}
102+
};
103+
104+
foreach (var proj in project.Solution.Projects)
89105
{
90-
fixAllContext.CancellationToken.ThrowIfCancellationRequested();
91-
var projectDiagnosticsTask = fixAllContext.GetProjectDiagnosticsAsync(proj);
92-
projectDiagnosticsTask.Wait(fixAllContext.CancellationToken);
93-
var projectDiagnostics = projectDiagnosticsTask.Result;
94-
if (projectDiagnostics.Any())
106+
if (fixAllContext.CancellationToken.IsCancellationRequested)
95107
{
96-
projectsAndDiagnostics.TryAdd(proj, projectDiagnostics);
108+
break;
97109
}
98-
});
99110

111+
tasks.Add(projectAction(proj));
112+
}
113+
114+
await Task.WhenAll(tasks).ConfigureAwait(false);
100115
return projectsAndDiagnostics.ToImmutableDictionary();
101116
}
102117
}

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,16 @@
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

44
using System;
5-
using System.Reflection;
6-
using System.Resources;
75
using System.Runtime.CompilerServices;
86
using System.Runtime.InteropServices;
97

10-
// General Information about an assembly is controlled through the following
11-
// set of attributes. Change these attribute values to modify the information
12-
// associated with an assembly.
13-
[assembly: AssemblyTitle("StyleCop.Analyzers.CodeFixes")]
14-
[assembly: AssemblyDescription("")]
15-
[assembly: AssemblyConfiguration("")]
16-
[assembly: AssemblyCompany("Tunnel Vision Laboratories, LLC")]
17-
[assembly: AssemblyProduct("StyleCop.Analyzers")]
18-
[assembly: AssemblyCopyright("Copyright © Sam Harwell 2015")]
19-
[assembly: AssemblyTrademark("")]
20-
[assembly: AssemblyCulture("")]
218
[assembly: CLSCompliant(false)]
22-
[assembly: NeutralResourcesLanguage("en-US")]
239

2410
// Setting ComVisible to false makes the types in this assembly not visible
2511
// to COM components. If you need to access a type in this assembly from
2612
// COM, set the ComVisible attribute to true on that type.
2713
[assembly: ComVisible(false)]
2814

29-
// Version information for an assembly consists of the following four values:
30-
//
31-
// Major Version
32-
// Minor Version
33-
// Build Number
34-
// Revision
35-
//
36-
// You can specify all the values or you can default the Build and Revision Numbers
37-
// by using the '*' as shown below:
38-
[assembly: AssemblyVersion("1.1.0.35")]
39-
[assembly: AssemblyFileVersion("1.1.0.35")]
40-
[assembly: AssemblyInformationalVersion("1.1.0-dev")]
41-
4215
[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")]
4316
[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp7, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")]
4417
[assembly: InternalsVisibleTo("StyleCopTester, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")]

0 commit comments

Comments
 (0)