Skip to content

Commit aaa25cc

Browse files
committed
Add status generator to solution and clean up style warnings
1 parent 9911565 commit aaa25cc

8 files changed

Lines changed: 58 additions & 56 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/CodeFixStatus.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Dennis Fischer. All Rights Reserved.
1+
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

44
namespace StyleCop.Analyzers.Status.Generator
@@ -25,6 +25,6 @@ public enum CodeFixStatus
2525
/// no one implemented it yet, or it is not yet decided if a code fix
2626
/// is going to be implemented in the future.
2727
/// </summary>
28-
NotYetImplemented
28+
NotYetImplemented,
2929
}
3030
}

StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/CompilationFailedException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Dennis Fischer. All Rights Reserved.
1+
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

44
namespace StyleCop.Analyzers.Status.Generator

StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/Program.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Dennis Fischer. All Rights Reserved.
1+
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

44
namespace StyleCop.Analyzers.Status.Generator
@@ -58,8 +58,8 @@ internal static int Main(string[] args)
5858
commit.Message,
5959
commit.Author,
6060
commit.Committer,
61-
Parents = commit.Parents.Select(x => x.Sha)
62-
}
61+
Parents = commit.Parents.Select(x => x.Sha),
62+
},
6363
};
6464

6565
Console.WriteLine(JsonConvert.SerializeObject(output, Formatting.Indented));

StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/ResourceReader.cs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Dennis Fischer. All Rights Reserved.
1+
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

44
namespace StyleCop.Analyzers.Status.Generator
@@ -26,22 +26,23 @@ internal static ResourceDescription ReadResource(string name, string path)
2626
return new ResourceDescription(
2727
name,
2828
() =>
29-
{
30-
using (ResXResourceReader reader = new ResXResourceReader(path))
3129
{
32-
IDictionaryEnumerator enumerator = reader.GetEnumerator();
33-
MemoryStream memStream = new MemoryStream();
34-
using (IResourceWriter writer = new ResourceWriter(memStream))
30+
using (ResXResourceReader reader = new ResXResourceReader(path))
3531
{
36-
while (enumerator.MoveNext())
32+
IDictionaryEnumerator enumerator = reader.GetEnumerator();
33+
MemoryStream memStream = new MemoryStream();
34+
using (IResourceWriter writer = new ResourceWriter(memStream))
3735
{
38-
writer.AddResource(enumerator.Key.ToString(), enumerator.Value);
36+
while (enumerator.MoveNext())
37+
{
38+
writer.AddResource(enumerator.Key.ToString(), enumerator.Value);
39+
}
3940
}
41+
42+
return new MemoryStream(memStream.ToArray());
4043
}
41-
return new MemoryStream(memStream.ToArray());
42-
}
43-
},
44-
false);
44+
},
45+
false);
4546
}
4647

4748
/// <summary>

StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/SolutionReader.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Dennis Fischer. All Rights Reserved.
1+
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

44
namespace StyleCop.Analyzers.Status.Generator
@@ -75,7 +75,7 @@ public static async Task<SolutionReader> CreateAsync(string pathToSln, string an
7575
reader.CodeFixProjectName = codeFixProjectName;
7676
reader.workspace = MSBuildWorkspace.Create(properties: new Dictionary<string, string> { { "Configuration", "Release" } });
7777

78-
await reader.InitializeAsync();
78+
await reader.InitializeAsync().ConfigureAwait(false);
7979

8080
return reader;
8181
}
@@ -103,7 +103,7 @@ public async Task<ImmutableList<StyleCopDiagnostic>> GetDiagnosticsAsync()
103103
string noCodeFixReason = null;
104104

105105
// Check if this syntax tree represents a diagnostic
106-
SyntaxNode syntaxRoot = await syntaxTree.GetRootAsync();
106+
SyntaxNode syntaxRoot = await syntaxTree.GetRootAsync().ConfigureAwait(false);
107107
SemanticModel semanticModel = this.analyzerCompilation.GetSemanticModel(syntaxTree);
108108
SyntaxNode classSyntaxNode = syntaxRoot.DescendantNodes().FirstOrDefault(x => x.IsKind(SyntaxKind.ClassDeclaration));
109109

@@ -147,7 +147,7 @@ public async Task<ImmutableList<StyleCopDiagnostic>> GetDiagnosticsAsync()
147147
Title = descriptorInfo.Title.ToString(),
148148
HelpLink = descriptorInfo.HelpLinkUri,
149149
CodeFixStatus = codeFixStatus,
150-
NoCodeFixReason = noCodeFixReason
150+
NoCodeFixReason = noCodeFixReason,
151151
};
152152
diagnostics.Add(diagnostic);
153153
}
@@ -175,14 +175,14 @@ private static bool HasImplementation(SyntaxNode syntaxRoot)
175175

176176
private async Task InitializeAsync()
177177
{
178-
this.solution = await this.workspace.OpenSolutionAsync(this.SlnPath);
178+
this.solution = await this.workspace.OpenSolutionAsync(this.SlnPath).ConfigureAwait(false);
179179

180180
this.analyzerProject = this.solution.Projects.First(x => x.Name == this.AnalyzerProjectName || x.AssemblyName == this.AnalyzerProjectName);
181-
this.analyzerCompilation = await this.analyzerProject.GetCompilationAsync();
181+
this.analyzerCompilation = await this.analyzerProject.GetCompilationAsync().ConfigureAwait(false);
182182
this.analyzerCompilation = this.analyzerCompilation.WithOptions(this.analyzerCompilation.Options.WithOutputKind(OutputKind.DynamicallyLinkedLibrary));
183183

184184
this.codeFixProject = this.solution.Projects.First(x => x.Name == this.CodeFixProjectName || x.AssemblyName == this.CodeFixProjectName);
185-
this.codeFixCompilation = await this.codeFixProject.GetCompilationAsync();
185+
this.codeFixCompilation = await this.codeFixProject.GetCompilationAsync().ConfigureAwait(false);
186186
this.codeFixCompilation = this.codeFixCompilation.WithOptions(this.codeFixCompilation.Options.WithOutputKind(OutputKind.DynamicallyLinkedLibrary));
187187

188188
this.booleanType = this.analyzerCompilation.GetSpecialType(SpecialType.System_Boolean);
@@ -338,4 +338,4 @@ private bool InheritsFrom(INamedTypeSymbol declaration, INamedTypeSymbol possibl
338338
return false;
339339
}
340340
}
341-
}
341+
}

StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/StyleCop.Analyzers.Status.Generator.csproj

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
</PropertyGroup>
1111

1212
<PropertyGroup>
13-
<CodeAnalysisRuleSet>Rules.ruleset</CodeAnalysisRuleSet>
14-
<GenerateDocumentationFile>true</GenerateDocumentationFile>
13+
<CodeAnalysisRuleSet>..\StyleCop.Analyzers.Internal.ruleset</CodeAnalysisRuleSet>
1514
</PropertyGroup>
1615

1716
<ItemGroup>
@@ -25,11 +24,6 @@
2524
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="2.9.0-beta4-62830-01" />
2625
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="2.9.0-beta4-62830-01" />
2726
<PackageReference Include="Newtonsoft.Json" Version="7.0.1-beta3" />
28-
<PackageReference Include="StyleCop.Analyzers" Version="1.0.0-beta015" PrivateAssets="all" />
29-
</ItemGroup>
30-
31-
<ItemGroup>
32-
<None Include="..\stylecop.json" />
3327
</ItemGroup>
3428

3529
</Project>

StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/StyleCopDiagnostic.cs

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Dennis Fischer. All Rights Reserved.
1+
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

44
namespace StyleCop.Analyzers.Status.Generator
@@ -12,83 +12,84 @@ namespace StyleCop.Analyzers.Status.Generator
1212
public class StyleCopDiagnostic
1313
{
1414
/// <summary>
15-
/// The Id of the diagnostic including the prefix 'SA' or 'SX'
15+
/// Gets or sets the ID of the diagnostic, including the prefix 'SA' or 'SX'.
1616
/// </summary>
1717
/// <value>
18-
/// The Id of the diagnostic including the prefix 'SA' or 'SX'
18+
/// The ID of the diagnostic including, the prefix 'SA' or 'SX'.
1919
/// </value>
2020
public string Id { get; set; }
2121

2222
/// <summary>
23-
/// The short name if the diagnostic that is used in the class name.
23+
/// Gets or sets the short name if the diagnostic that is used in the class name.
2424
/// </summary>
2525
/// <value>
2626
/// The short name if the diagnostic that is used in the class name.
2727
/// </value>
2828
public string Name { get; set; }
2929

3030
/// <summary>
31-
/// Whether or not the diagnostic is implemented.
31+
/// Gets or sets a value indicating whether the diagnostic is implemented.
3232
/// </summary>
3333
/// <value>
34-
/// Whether or not the diagnostic is implemented.
34+
/// <see langword="true"/> if the diagnostic is implemented; otherwise <see langword="false"/>.
3535
/// </value>
3636
public bool HasImplementation { get; set; }
3737

3838
/// <summary>
39-
/// Represents if the diagnostic is enabled or not. This can indicate if the
40-
/// diagnostic is enabled by default or not, or if it is disabled because
39+
/// Gets or sets a value indicating whether the diagnostic is enabled. This can indicate if the
40+
/// diagnostic is enabled by default, and if not, whether it is disabled because
4141
/// there are no tests for the diagnostic.
4242
/// </summary>
4343
/// <value>
44-
/// Represents if the diagnostic is enabled or not. This can indicate if the
45-
/// diagnostic is enabled by default or not, or if it is disabled because
46-
/// there are no tests for the diagnostic.
44+
/// <list type="bullet">
45+
/// <item>DisabledNoTests</item>
46+
/// <item>DisabledAlternative</item>
47+
/// <item>EnabledByDefault</item>
48+
/// <item>DisabledByDefault</item>
49+
/// </list>
4750
/// </value>
4851
public string Status { get; set; }
4952

5053
/// <summary>
51-
/// Represents whether or not there is a code fix for the diagnostic.
54+
/// Gets or sets a value indicating the code fix status for the diagnostic.
5255
/// </summary>
5356
/// <value>
54-
/// Represents whether or not there is a code fix for the diagnostic.
57+
/// A value indicating the code fix status for the diagnostic.
5558
/// </value>
5659
[JsonConverter(typeof(StringEnumConverter))]
5760
public CodeFixStatus CodeFixStatus { get; set; }
5861

5962
/// <summary>
60-
/// Returns the reason why a code fix is not implemented, or null if there is
63+
/// Gets or sets the reason why a code fix is not implemented, or <see langword="null"/> if there is
6164
/// no reason.
6265
/// </summary>
6366
/// <value>
64-
/// Returns the reason why a code fix is not implemented, or null if there is
67+
/// The reason why a code fix is not implemented, or <see langword="null"/> if there is
6568
/// no reason.
6669
/// </value>
6770
public string NoCodeFixReason { get; set; }
6871

6972
/// <summary>
70-
/// Returns the title of this diagnostic
71-
/// no reason.
73+
/// Gets or sets the title of this diagnostic.
7274
/// </summary>
7375
/// <value>
74-
/// Returns the title of this diagnostic
76+
/// The title of this diagnostic.
7577
/// </value>
7678
public string Title { get; set; }
7779

7880
/// <summary>
79-
/// Returns the category of this diagnostic
80-
/// no reason.
81+
/// Gets or sets the category of this diagnostic.
8182
/// </summary>
8283
/// <value>
83-
/// Returns the category of this diagnostic
84+
/// The category of this diagnostic.
8485
/// </value>
8586
public string Category { get; set; }
8687

8788
/// <summary>
88-
/// Returns help link for this diagnostic
89+
/// Gets or sets the help link for this diagnostic.
8990
/// </summary>
9091
/// <value>
91-
/// Returns help link for this diagnostic
92+
/// The help link for this diagnostic.
9293
/// </value>
9394
public string HelpLink { get; set; }
9495

StyleCopAnalyzers.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StyleCop.Analyzers.CodeFixe
253253
EndProject
254254
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StyleCop.Analyzers.Test.CSharp7", "StyleCop.Analyzers\StyleCop.Analyzers.Test.CSharp7\StyleCop.Analyzers.Test.CSharp7.csproj", "{F10E4AEF-86A2-4394-8B6F-1A3468B72F1D}"
255255
EndProject
256+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StyleCop.Analyzers.Status.Generator", "StyleCop.Analyzers\StyleCop.Analyzers.Status.Generator\StyleCop.Analyzers.Status.Generator.csproj", "{80EA831D-D993-44A8-BB77-33D84BACE711}"
257+
EndProject
256258
Global
257259
GlobalSection(SolutionConfigurationPlatforms) = preSolution
258260
Debug|Any CPU = Debug|Any CPU
@@ -283,6 +285,10 @@ Global
283285
{F10E4AEF-86A2-4394-8B6F-1A3468B72F1D}.Debug|Any CPU.Build.0 = Debug|Any CPU
284286
{F10E4AEF-86A2-4394-8B6F-1A3468B72F1D}.Release|Any CPU.ActiveCfg = Release|Any CPU
285287
{F10E4AEF-86A2-4394-8B6F-1A3468B72F1D}.Release|Any CPU.Build.0 = Release|Any CPU
288+
{80EA831D-D993-44A8-BB77-33D84BACE711}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
289+
{80EA831D-D993-44A8-BB77-33D84BACE711}.Debug|Any CPU.Build.0 = Debug|Any CPU
290+
{80EA831D-D993-44A8-BB77-33D84BACE711}.Release|Any CPU.ActiveCfg = Release|Any CPU
291+
{80EA831D-D993-44A8-BB77-33D84BACE711}.Release|Any CPU.Build.0 = Release|Any CPU
286292
EndGlobalSection
287293
GlobalSection(SolutionProperties) = preSolution
288294
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)