Skip to content
This repository was archived by the owner on Nov 8, 2018. It is now read-only.

Commit d89aa22

Browse files
committed
Fix SA1101: Prefix local calls with this
1 parent 6958e4d commit d89aa22

File tree

5 files changed

+56
-56
lines changed

5 files changed

+56
-56
lines changed

AsyncUsageAnalyzers/AsyncUsageAnalyzers.CodeFixes/Usage/UseConfigureAwaitCodeFixProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
5555
return Task.FromResult(true);
5656
}
5757

58-
private async Task<Document> GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken)
58+
private static async Task<Document> GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken)
5959
{
6060
SyntaxNode root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
6161
ExpressionSyntax expression = (ExpressionSyntax)root.FindNode(diagnostic.Location.SourceSpan);

AsyncUsageAnalyzers/AsyncUsageAnalyzers.Test/Naming/AvoidAsyncSuffixUnitTests.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ void SecondMethod() { }
3232
}
3333
";
3434

35-
DiagnosticResult expected = CSharpDiagnostic().WithArguments("SecondMethodAsync").WithLocation(5, 10);
36-
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
37-
await VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
38-
await VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
35+
DiagnosticResult expected = this.CSharpDiagnostic().WithArguments("SecondMethodAsync").WithLocation(5, 10);
36+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
37+
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
38+
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
3939
}
4040

4141
[Fact]
@@ -49,7 +49,7 @@ async void SecondMethodAsync() { }
4949
}
5050
";
5151

52-
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
52+
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
5353
}
5454

5555
[Fact]
@@ -72,10 +72,10 @@ void SecondMethod(object sender, EventArgs e) { }
7272
}
7373
";
7474

75-
DiagnosticResult expected = CSharpDiagnostic().WithArguments("SecondMethodAsync").WithLocation(6, 10);
76-
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
77-
await VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
78-
await VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
75+
DiagnosticResult expected = this.CSharpDiagnostic().WithArguments("SecondMethodAsync").WithLocation(6, 10);
76+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
77+
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
78+
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
7979
}
8080

8181
[Fact]
@@ -90,7 +90,7 @@ async void SecondMethodAsync(object sender, EventArgs e) { }
9090
}
9191
";
9292

93-
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
93+
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
9494
}
9595

9696
[Fact]
@@ -105,7 +105,7 @@ async Task SecondMethodAsync() { }
105105
}
106106
";
107107

108-
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
108+
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
109109
}
110110

111111
[Fact]
@@ -120,7 +120,7 @@ class ClassName
120120
}
121121
";
122122

123-
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
123+
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
124124
}
125125

126126
[Fact]
@@ -135,7 +135,7 @@ class ClassName
135135
}
136136
";
137137

138-
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
138+
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
139139
}
140140

141141
[Fact]
@@ -150,7 +150,7 @@ class ClassName
150150
}
151151
";
152152

153-
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
153+
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
154154
}
155155

156156
protected override IEnumerable<DiagnosticAnalyzer> GetCSharpDiagnosticAnalyzers()

AsyncUsageAnalyzers/AsyncUsageAnalyzers.Test/Naming/UseAsyncSuffixUnitTests.cs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ async void SecondMethodAsync() { }
2525
}
2626
";
2727

28-
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
28+
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
2929
}
3030

3131
[Fact]
@@ -40,7 +40,7 @@ async void SecondMethodAsync(object sender, EventArgs e) { }
4040
}
4141
";
4242

43-
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
43+
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
4444
}
4545

4646
[Fact]
@@ -63,10 +63,10 @@ async Task SecondMethodAsync() { }
6363
}
6464
";
6565

66-
DiagnosticResult expected = CSharpDiagnostic().WithArguments("FirstMethod").WithLocation(5, 16);
67-
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
68-
await VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
69-
await VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
66+
DiagnosticResult expected = this.CSharpDiagnostic().WithArguments("FirstMethod").WithLocation(5, 16);
67+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
68+
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
69+
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
7070
}
7171

7272
[Fact]
@@ -89,10 +89,10 @@ class ClassName
8989
}
9090
";
9191

92-
DiagnosticResult expected = CSharpDiagnostic().WithArguments("FirstMethod").WithLocation(5, 21);
93-
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
94-
await VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
95-
await VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
92+
DiagnosticResult expected = this.CSharpDiagnostic().WithArguments("FirstMethod").WithLocation(5, 21);
93+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
94+
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
95+
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
9696
}
9797

9898
[Fact]
@@ -115,10 +115,10 @@ class ClassName
115115
}
116116
";
117117

118-
DiagnosticResult expected = CSharpDiagnostic().WithArguments("FirstMethod").WithLocation(5, 10);
119-
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
120-
await VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
121-
await VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
118+
DiagnosticResult expected = this.CSharpDiagnostic().WithArguments("FirstMethod").WithLocation(5, 10);
119+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
120+
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
121+
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
122122
}
123123

124124
[Fact]
@@ -141,10 +141,10 @@ class ClassName
141141
}
142142
";
143143

144-
DiagnosticResult expected = CSharpDiagnostic().WithArguments("FirstMethod").WithLocation(5, 15);
145-
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
146-
await VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
147-
await VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
144+
DiagnosticResult expected = this.CSharpDiagnostic().WithArguments("FirstMethod").WithLocation(5, 15);
145+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
146+
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
147+
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
148148
}
149149

150150
[Fact]
@@ -157,7 +157,7 @@ class ClassName
157157
public Task<string> TaskString { get; set; }
158158
}
159159
";
160-
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
160+
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
161161
}
162162

163163
protected override IEnumerable<DiagnosticAnalyzer> GetCSharpDiagnosticAnalyzers()

AsyncUsageAnalyzers/AsyncUsageAnalyzers.Test/Reliability/AvoidAsyncVoidUnitTests.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ async void MethodNameAsync() { }
2323
}
2424
";
2525

26-
DiagnosticResult expected = CSharpDiagnostic().WithArguments("MethodNameAsync").WithLocation(4, 16);
27-
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
26+
DiagnosticResult expected = this.CSharpDiagnostic().WithArguments("MethodNameAsync").WithLocation(4, 16);
27+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
2828
}
2929

3030
[Fact]
@@ -44,8 +44,8 @@ async void MethodNameAsync(object sender, EventArgs e) { }
4444
";
4545

4646
// This analyzer does not currently handle this case differently from any other method
47-
DiagnosticResult expected = CSharpDiagnostic().WithArguments("MethodNameAsync").WithLocation(10, 16);
48-
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
47+
DiagnosticResult expected = this.CSharpDiagnostic().WithArguments("MethodNameAsync").WithLocation(10, 16);
48+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
4949
}
5050

5151
[Fact]
@@ -69,11 +69,11 @@ class ClassName
6969
// This analyzer does not currently handle this case differently from any other method
7070
DiagnosticResult[] expected =
7171
{
72-
CSharpDiagnostic().WithArguments("<anonymous>").WithLocation(9, 49),
73-
CSharpDiagnostic().WithArguments("<anonymous>").WithLocation(10, 49),
74-
CSharpDiagnostic().WithArguments("<anonymous>").WithLocation(11, 32),
72+
this.CSharpDiagnostic().WithArguments("<anonymous>").WithLocation(9, 49),
73+
this.CSharpDiagnostic().WithArguments("<anonymous>").WithLocation(10, 49),
74+
this.CSharpDiagnostic().WithArguments("<anonymous>").WithLocation(11, 32),
7575
};
76-
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
76+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
7777
}
7878

7979
[Fact]
@@ -97,7 +97,7 @@ class ClassName
9797
}
9898
";
9999

100-
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
100+
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
101101
}
102102

103103
[Fact]
@@ -111,7 +111,7 @@ async Task MethodNameAsync() { }
111111
}
112112
";
113113

114-
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
114+
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
115115
}
116116

117117
[Fact]
@@ -125,7 +125,7 @@ class ClassName
125125
}
126126
";
127127

128-
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
128+
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
129129
}
130130

131131
[Fact]
@@ -139,7 +139,7 @@ class ClassName
139139
}
140140
";
141141

142-
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
142+
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
143143
}
144144

145145
[Fact]
@@ -153,7 +153,7 @@ class ClassName
153153
}
154154
";
155155

156-
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
156+
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
157157
}
158158

159159
protected override IEnumerable<DiagnosticAnalyzer> GetCSharpDiagnosticAnalyzers()

AsyncUsageAnalyzers/AsyncUsageAnalyzers.Test/Usage/UseConfigureAwaitUnitTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ async Task MethodNameAsync()
3838
}
3939
";
4040

41-
DiagnosticResult expected = CSharpDiagnostic().WithLocation(7, 15);
42-
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
43-
await VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
44-
await VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
41+
DiagnosticResult expected = this.CSharpDiagnostic().WithLocation(7, 15);
42+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
43+
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
44+
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
4545
}
4646

4747
[Fact]
@@ -80,12 +80,12 @@ async Task MethodNameAsync()
8080

8181
DiagnosticResult[] expected =
8282
{
83-
CSharpDiagnostic().WithLocation(12, 15),
84-
CSharpDiagnostic().WithLocation(12, 22)
83+
this.CSharpDiagnostic().WithLocation(12, 15),
84+
this.CSharpDiagnostic().WithLocation(12, 22)
8585
};
86-
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
87-
await VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
88-
await VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
86+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
87+
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
88+
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
8989
}
9090

9191
protected override IEnumerable<DiagnosticAnalyzer> GetCSharpDiagnosticAnalyzers()

0 commit comments

Comments
 (0)