Skip to content

Commit c946ae5

Browse files
committed
Merge pull request #1651 from NikolayIT/master
2 parents 191641c + 523fbb1 commit c946ae5

15 files changed

Lines changed: 23 additions & 40 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1615SA1616CodeFixProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private static async Task<Document> GetTransformedDocumentAsync(Document documen
9494
isAsynchronousTestMethod = false;
9595
}
9696

97-
XmlNodeSyntax returnsElement = documentationComment.Content.GetFirstXmlElement(XmlCommentHelper.ReturnsXmlTag) as XmlNodeSyntax;
97+
XmlNodeSyntax returnsElement = documentationComment.Content.GetFirstXmlElement(XmlCommentHelper.ReturnsXmlTag);
9898
if (returnsElement != null && !isTask)
9999
{
100100
// This code fix doesn't know how to do anything more than document Task-returning methods.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public virtual string GetFixAllTitle(FixAllContext fixAllContext)
180180
{
181181
var diagnosticIds = fixAllContext.DiagnosticIds;
182182
string diagnosticId;
183-
if (diagnosticIds.Count() == 1)
183+
if (diagnosticIds.Count == 1)
184184
{
185185
diagnosticId = diagnosticIds.Single();
186186
}

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1120CodeFixProvider.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,7 @@ private static async Task<Document> GetTransformedDocumentAsync(Document documen
8080
}
8181

8282
// Replace all roots with an empty node
83-
var newRoot = root.ReplaceTrivia(triviaToRemove, (original, rewritten) =>
84-
{
85-
return default(SyntaxTrivia);
86-
});
83+
var newRoot = root.ReplaceTrivia(triviaToRemove, (original, rewritten) => default(SyntaxTrivia));
8784

8885
Document updatedDocument = document.WithSyntaxRoot(newRoot);
8986
return updatedDocument;

StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Events.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public event EventHandler Bar
9292
}
9393

9494
/// <summary>
95-
/// Verifies that an event with its block defined on a mutiple lines will pass without diagnostic.
95+
/// Verifies that an event with its block defined on a multiple lines will pass without diagnostic.
9696
/// </summary>
9797
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
9898
[Fact]

StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Indexers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public bool this[int index]
7474
}
7575

7676
/// <summary>
77-
/// Verifies that an indexer with its block defined on a mutiple lines will pass without diagnostic.
77+
/// Verifies that an indexer with its block defined on a multiple lines will pass without diagnostic.
7878
/// </summary>
7979
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
8080
[Fact]

StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Namespaces.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public async Task TestNamespaceWithBlockOnSingleLineAsync()
6969
}
7070

7171
/// <summary>
72-
/// Verifies that a namespace with its block defined on a mutiple lines will pass without diagnostic.
72+
/// Verifies that a namespace with its block defined on a multiple lines will pass without diagnostic.
7373
/// </summary>
7474
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
7575
[Fact]

StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1119UnitTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,7 @@ public void Bar()
11691169
public async Task TestElementAccessExpressionAroundConditionalMemberAccessExpressionAsync()
11701170
{
11711171
// In this case removing the parenthesis is an syntactical(because char is a value type) change to the code.
1172-
// If (myObject?.Foo)[0] would be a refrrence type removing parenthesis would be a semantic change
1172+
// If (myObject?.Foo)[0] would be a reference type removing parenthesis would be a semantic change
11731173
// because (myObject?.Foo)[0] crashes if myObject is null, but myObject?.Foo[0] evaluates to null.
11741174
string testCode = @"class Foo
11751175
{

StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1122UnitTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void Bar()
4949
[Fact]
5050
public async Task TestCodeFixMultipleNodesAsync()
5151
{
52-
// Tests if the code fix works if the SourceSpan of the diagnostic has more then one SynatxNode associated with it
52+
// Tests if the code fix works if the SourceSpan of the diagnostic has more then one SyntaxNode associated with it
5353
// In this case it is a InterpolatedStringInsert and the StringLiteralExpression
5454
string oldSource = @"public class Foo
5555
{

StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/NumberSignSpacingTestBase.cs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ void Foo()
8080
}
8181
";
8282

83-
string test;
84-
85-
test = string.Format(testFormat, this.Sign + "3");
83+
string test = string.Format(testFormat, this.Sign + "3");
8684
await this.VerifyCSharpDiagnosticAsync(test, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
8785
await this.VerifyCSharpFixAsync(test, fixedTest, cancellationToken: CancellationToken.None).ConfigureAwait(false);
8886

@@ -123,9 +121,7 @@ void Foo()
123121
}
124122
";
125123

126-
string test;
127-
128-
test = string.Format(testFormat, this.Sign + "3");
124+
string test = string.Format(testFormat, this.Sign + "3");
129125
await this.VerifyCSharpDiagnosticAsync(test, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
130126
await this.VerifyCSharpFixAsync(test, fixedTest, cancellationToken: CancellationToken.None).ConfigureAwait(false);
131127

@@ -164,9 +160,7 @@ void Foo()
164160
}
165161
";
166162

167-
string test;
168-
169-
test = string.Format(testFormat, " " + this.Sign + "3");
163+
string test = string.Format(testFormat, " " + this.Sign + "3");
170164
await this.VerifyCSharpDiagnosticAsync(test, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
171165
await this.VerifyCSharpFixAsync(test, fixedTest, cancellationToken: CancellationToken.None).ConfigureAwait(false);
172166

@@ -229,9 +223,7 @@ void Foo()
229223
}
230224
";
231225

232-
string test;
233-
234-
test = string.Format(testFormat, this.Sign + "3");
226+
string test = string.Format(testFormat, this.Sign + "3");
235227
await this.VerifyCSharpDiagnosticAsync(test, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
236228
await this.VerifyCSharpFixAsync(test, fixedTest, cancellationToken: CancellationToken.None).ConfigureAwait(false);
237229

@@ -270,9 +262,7 @@ void Foo()
270262
}
271263
";
272264

273-
string test;
274-
275-
test = string.Format(testFormat, this.Sign + "3");
265+
string test = string.Format(testFormat, this.Sign + "3");
276266
await this.VerifyCSharpDiagnosticAsync(test, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
277267
await this.VerifyCSharpFixAsync(test, fixedTest, cancellationToken: CancellationToken.None).ConfigureAwait(false);
278268

@@ -332,9 +322,7 @@ void Foo()
332322
}
333323
";
334324

335-
string test;
336-
337-
test = string.Format(testFormat, this.Sign + "3");
325+
string test = string.Format(testFormat, this.Sign + "3");
338326
await this.VerifyCSharpDiagnosticAsync(test, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
339327
await this.VerifyCSharpFixAsync(test, fixedTest, cancellationToken: CancellationToken.None).ConfigureAwait(false);
340328

@@ -394,9 +382,7 @@ void Foo()
394382
}
395383
";
396384

397-
string test;
398-
399-
test = string.Format(testFormat, this.Sign + "0");
385+
string test = string.Format(testFormat, this.Sign + "0");
400386
await this.VerifyCSharpDiagnosticAsync(test, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
401387
await this.VerifyCSharpFixAsync(test, fixedTest, cancellationToken: CancellationToken.None).ConfigureAwait(false);
402388

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ protected Task VerifyCSharpDiagnosticAsync(string[] sources, DiagnosticResult[]
129129
/// diagnostics for the sources.</param>
130130
private static void VerifyDiagnosticResults(IEnumerable<Diagnostic> actualResults, ImmutableArray<DiagnosticAnalyzer> analyzers, DiagnosticResult[] expectedResults)
131131
{
132-
int expectedCount = expectedResults.Count();
132+
int expectedCount = expectedResults.Length;
133133
int actualCount = actualResults.Count();
134134

135135
if (expectedCount != actualCount)
@@ -284,7 +284,7 @@ private static string FormatDiagnostics(ImmutableArray<DiagnosticAnalyzer> analy
284284
{
285285
var diagnosticsId = diagnostics[i].Id;
286286

287-
builder.AppendLine("// " + diagnostics[i].ToString());
287+
builder.Append("// ").AppendLine(diagnostics[i].ToString());
288288

289289
var applicableAnalyzer = analyzers.FirstOrDefault(a => a.SupportedDiagnostics.Any(dd => dd.Id == diagnosticsId));
290290
if (applicableAnalyzer != null)
@@ -300,7 +300,7 @@ private static string FormatDiagnostics(ImmutableArray<DiagnosticAnalyzer> analy
300300
{
301301
Assert.True(
302302
location.IsInSource,
303-
string.Format("Test base does not currently handle diagnostics in metadata locations. Diagnostic in metadata:\r\n", diagnostics[i]));
303+
string.Format("Test base does not currently handle diagnostics in metadata locations. Diagnostic in metadata:\r\n{0}", diagnostics[i]));
304304

305305
string resultMethodName = diagnostics[i].Location.SourceTree.FilePath.EndsWith(".cs") ? "GetCSharpResultAt" : "GetBasicResultAt";
306306
var linePosition = diagnostics[i].Location.GetLineSpan().StartLinePosition;

0 commit comments

Comments
 (0)