Skip to content

Commit b8d9f89

Browse files
committed
Merge pull request #1555 from sharwell/update-beta13
Update to StyleCop.Analyzers 1.0.0-beta013
2 parents dcf9b30 + 4a7f79d commit b8d9f89

22 files changed

Lines changed: 126 additions & 59 deletions

StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1642UnitTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -542,9 +542,7 @@ private async Task TestConstructorMissingDocumentationAsync(string typeKind, str
542542

543543
DiagnosticResult expected = this.CSharpDiagnostic().WithLocation(5, 13);
544544

545-
await this.VerifyCSharpDiagnosticAsync(
546-
testCode,
547-
expected, CancellationToken.None).ConfigureAwait(false);
545+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
548546

549547
var fixedCode = @"namespace FooNamespace
550548
{{

StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1643UnitTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,7 @@ public class Foo{0}
182182

183183
DiagnosticResult expected = this.CSharpDiagnostic().WithLocation(5, 13);
184184

185-
await this.VerifyCSharpDiagnosticAsync(
186-
testCode,
187-
expected, CancellationToken.None).ConfigureAwait(false);
185+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
188186

189187
var fixedCode = @"namespace FooNamespace
190188
{{

StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1412UnitTests.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,17 @@ public async Task TestCodeFixAsync(int codepage)
8686
Location.Create(await document.GetSyntaxTreeAsync().ConfigureAwait(false), TextSpan.FromBounds(0, 0)),
8787
properties);
8888

89-
await codeFixer.RegisterCodeFixesAsync(new CodeFixContext(document, diagnostic, (ca, d) =>
90-
{
91-
var operation = ca.GetOperationsAsync(CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult()[0];
92-
93-
operation.Apply(workspace, CancellationToken.None);
94-
}, CancellationToken.None)).ConfigureAwait(false);
89+
await codeFixer.RegisterCodeFixesAsync(
90+
new CodeFixContext(
91+
document,
92+
diagnostic,
93+
(ca, d) =>
94+
{
95+
var operation = ca.GetOperationsAsync(CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult()[0];
96+
97+
operation.Apply(workspace, CancellationToken.None);
98+
},
99+
CancellationToken.None)).ConfigureAwait(false);
95100

96101
// project should now have the "fixed document" in it.
97102
// Because of limitations in Roslyn the fixed document should

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,8 @@
371371
<Analyzer Include="..\..\packages\AsyncUsageAnalyzers.1.0.0-alpha003\analyzers\dotnet\AsyncUsageAnalyzers.dll" />
372372
<Analyzer Include="..\..\packages\Microsoft.CodeAnalysis.Analyzers.1.0.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.Analyzers.dll" />
373373
<Analyzer Include="..\..\packages\Microsoft.CodeAnalysis.Analyzers.1.0.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll" />
374-
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-beta012\analyzers\dotnet\cs\Newtonsoft.Json.dll" />
375-
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-beta012\analyzers\dotnet\cs\StyleCop.Analyzers.dll" />
374+
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-beta013\analyzers\dotnet\cs\Newtonsoft.Json.dll" />
375+
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-beta013\analyzers\dotnet\cs\StyleCop.Analyzers.dll" />
376376
</ItemGroup>
377377
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
378378
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/CodeFixVerifier.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,17 @@ private static bool AreDiagnosticsDifferent(ImmutableArray<Diagnostic> analyzerD
293293
return false;
294294
}
295295

296-
private async Task VerifyFixInternalAsync(string language, ImmutableArray<DiagnosticAnalyzer> analyzers, CodeFixProvider codeFixProvider, string oldSource, string newSource, int? codeFixIndex,
297-
bool allowNewCompilerDiagnostics, int maxNumberOfIterations, Func<ImmutableArray<DiagnosticAnalyzer>, CodeFixProvider, int?, Document, int, CancellationToken, Task<Document>> getFixedDocument, CancellationToken cancellationToken)
296+
private async Task VerifyFixInternalAsync(
297+
string language,
298+
ImmutableArray<DiagnosticAnalyzer> analyzers,
299+
CodeFixProvider codeFixProvider,
300+
string oldSource,
301+
string newSource,
302+
int? codeFixIndex,
303+
bool allowNewCompilerDiagnostics,
304+
int maxNumberOfIterations,
305+
Func<ImmutableArray<DiagnosticAnalyzer>, CodeFixProvider, int?, Document, int, CancellationToken, Task<Document>> getFixedDocument,
306+
CancellationToken cancellationToken)
298307
{
299308
var document = this.CreateDocument(oldSource, language);
300309
var compilerDiagnostics = await GetCompilerDiagnosticsAsync(document, cancellationToken).ConfigureAwait(false);

StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/DiagnosticVerifier.cs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ private static void VerifyDiagnosticResults(IEnumerable<Diagnostic> actualResult
167167
string message =
168168
string.Format(
169169
"Expected {0} additional locations but got {1} for Diagnostic:\r\n {2}\r\n",
170-
expected.Locations.Length - 1, additionalLocations.Length,
170+
expected.Locations.Length - 1,
171+
additionalLocations.Length,
171172
FormatDiagnostics(analyzers, actual));
172173
Assert.True(false, message);
173174
}
@@ -183,7 +184,9 @@ private static void VerifyDiagnosticResults(IEnumerable<Diagnostic> actualResult
183184
string message =
184185
string.Format(
185186
"Expected diagnostic id to be \"{0}\" was \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n",
186-
expected.Id, actual.Id, FormatDiagnostics(analyzers, actual));
187+
expected.Id,
188+
actual.Id,
189+
FormatDiagnostics(analyzers, actual));
187190
Assert.True(false, message);
188191
}
189192

@@ -192,7 +195,9 @@ private static void VerifyDiagnosticResults(IEnumerable<Diagnostic> actualResult
192195
string message =
193196
string.Format(
194197
"Expected diagnostic severity to be \"{0}\" was \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n",
195-
expected.Severity, actual.Severity, FormatDiagnostics(analyzers, actual));
198+
expected.Severity,
199+
actual.Severity,
200+
FormatDiagnostics(analyzers, actual));
196201
Assert.True(false, message);
197202
}
198203

@@ -201,7 +206,9 @@ private static void VerifyDiagnosticResults(IEnumerable<Diagnostic> actualResult
201206
string message =
202207
string.Format(
203208
"Expected diagnostic message to be \"{0}\" was \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n",
204-
expected.Message, actual.GetMessage(), FormatDiagnostics(analyzers, actual));
209+
expected.Message,
210+
actual.GetMessage(),
211+
FormatDiagnostics(analyzers, actual));
205212
Assert.True(false, message);
206213
}
207214
}
@@ -224,7 +231,9 @@ private static void VerifyDiagnosticLocation(ImmutableArray<DiagnosticAnalyzer>
224231
string message =
225232
string.Format(
226233
"Expected diagnostic to be in file \"{0}\" was actually in file \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n",
227-
expected.Path, actualSpan.Path, FormatDiagnostics(analyzers, diagnostic));
234+
expected.Path,
235+
actualSpan.Path,
236+
FormatDiagnostics(analyzers, diagnostic));
228237
Assert.True(
229238
actualSpan.Path == expected.Path || (actualSpan.Path != null && actualSpan.Path.Contains("Test0.") && expected.Path.Contains("Test.")),
230239
message);
@@ -239,7 +248,9 @@ private static void VerifyDiagnosticLocation(ImmutableArray<DiagnosticAnalyzer>
239248
string message2 =
240249
string.Format(
241250
"Expected diagnostic to be on line \"{0}\" was actually on line \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n",
242-
expected.Line, actualLinePosition.Line + 1, FormatDiagnostics(analyzers, diagnostic));
251+
expected.Line,
252+
actualLinePosition.Line + 1,
253+
FormatDiagnostics(analyzers, diagnostic));
243254
Assert.True(false, message2);
244255
}
245256
}
@@ -252,7 +263,9 @@ private static void VerifyDiagnosticLocation(ImmutableArray<DiagnosticAnalyzer>
252263
string message2 =
253264
string.Format(
254265
"Expected diagnostic to start at column \"{0}\" was actually at column \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n",
255-
expected.Column, actualLinePosition.Character + 1, FormatDiagnostics(analyzers, diagnostic));
266+
expected.Column,
267+
actualLinePosition.Character + 1,
268+
FormatDiagnostics(analyzers, diagnostic));
256269
Assert.True(false, message2);
257270
}
258271
}

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-beta012" targetFramework="net452" developmentDependency="true" />
11+
<package id="StyleCop.Analyzers" version="1.0.0-beta013" 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.ruleset

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
<Rule Id="SA1302" Action="Error" />
9191
<Rule Id="SA1303" Action="Error" />
9292
<Rule Id="SA1304" Action="Error" />
93+
<Rule Id="SA1305" Action="Warning" />
9394
<Rule Id="SA1309" Action="Error" />
9495
<Rule Id="SA1311" Action="Error" />
9596
<Rule Id="SA1400" Action="Error" />

StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1612ElementParameterDocumentationMustMatchElementParameters.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,12 @@ private static void HandleElement(SyntaxNodeAnalysisContext context, XmlNodeSynt
116116
}
117117
else if (parentParameters.Length <= index || parentParameters[index] != nameAttribute.Identifier.Identifier.ValueText)
118118
{
119-
context.ReportDiagnostic(Diagnostic.Create(OrderDescriptor, nameAttribute?.Identifier?.GetLocation() ?? alternativeDiagnosticLocation,
120-
nameAttribute.Identifier.Identifier.ValueText, parentParameters.IndexOf(nameAttribute.Identifier.Identifier.ValueText) + 1));
119+
context.ReportDiagnostic(
120+
Diagnostic.Create(
121+
OrderDescriptor,
122+
nameAttribute?.Identifier?.GetLocation() ?? alternativeDiagnosticLocation,
123+
nameAttribute.Identifier.Identifier.ValueText,
124+
parentParameters.IndexOf(nameAttribute.Identifier.Identifier.ValueText) + 1));
121125
}
122126
}
123127

StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1620GenericTypeParameterDocumentationMustMatchTypeParameters.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,12 @@ private static void HandleElement(SyntaxNodeAnalysisContext context, XmlNodeSynt
117117
}
118118
else if (parentTypeParameters.Length <= index || parentTypeParameters[index] != nameAttribute.Identifier.Identifier.ValueText)
119119
{
120-
context.ReportDiagnostic(Diagnostic.Create(OrderDescriptor, nameAttribute?.Identifier?.GetLocation() ?? alternativeDiagnosticLocation,
121-
nameAttribute.Identifier.Identifier.ValueText, parentTypeParameters.IndexOf(nameAttribute.Identifier.Identifier.ValueText) + 1));
120+
context.ReportDiagnostic(
121+
Diagnostic.Create(
122+
OrderDescriptor,
123+
nameAttribute?.Identifier?.GetLocation() ?? alternativeDiagnosticLocation,
124+
nameAttribute.Identifier.Identifier.ValueText,
125+
parentTypeParameters.IndexOf(nameAttribute.Identifier.Identifier.ValueText) + 1));
122126
}
123127
}
124128

0 commit comments

Comments
 (0)