@@ -121,6 +121,205 @@ class ClassName
121121 await this . VerifyCSharpFixAsync ( testCode , fixedCode , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
122122 }
123123
124+ [ Fact ]
125+ public async Task TestInheritedReturnTaskAsync ( )
126+ {
127+ string testCode = @"
128+ using System.Threading.Tasks;
129+ class BaseName
130+ {
131+ protected virtual Task Method() { return Task.FromResult(3); }
132+ }
133+ class ClassName : BaseName
134+ {
135+ protected override Task Method() { return Task.FromResult(3); }
136+ }
137+ " ;
138+ string fixedCode = @"
139+ using System.Threading.Tasks;
140+ class BaseName
141+ {
142+ protected virtual Task MethodAsync() { return Task.FromResult(3); }
143+ }
144+ class ClassName : BaseName
145+ {
146+ protected override Task MethodAsync() { return Task.FromResult(3); }
147+ }
148+ " ;
149+
150+ DiagnosticResult expected = this . CSharpDiagnostic ( ) . WithArguments ( "Method" ) . WithLocation ( 5 , 28 ) ;
151+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
152+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
153+ await this . VerifyCSharpFixAsync ( testCode , fixedCode , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
154+ }
155+
156+ [ Fact ]
157+ public async Task TestExplicitInterfaceReturnTaskAsync ( )
158+ {
159+ string testCode = @"
160+ using System.Threading.Tasks;
161+ interface InterfaceName
162+ {
163+ Task Method();
164+ }
165+ class ClassName : InterfaceName
166+ {
167+ Task InterfaceName.Method() { return Task.FromResult(3); }
168+ }
169+ " ;
170+ string fixedCode = @"
171+ using System.Threading.Tasks;
172+ interface InterfaceName
173+ {
174+ Task MethodAsync();
175+ }
176+ class ClassName : InterfaceName
177+ {
178+ Task InterfaceName.MethodAsync() { return Task.FromResult(3); }
179+ }
180+ " ;
181+
182+ DiagnosticResult expected = this . CSharpDiagnostic ( ) . WithArguments ( "Method" ) . WithLocation ( 5 , 10 ) ;
183+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
184+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
185+ await this . VerifyCSharpFixAsync ( testCode , fixedCode , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
186+ }
187+
188+ [ Fact ]
189+ public async Task TestExplicitInterfaceReturnTaskPlusExtraAsync ( )
190+ {
191+ string testCode = @"
192+ using System.Threading.Tasks;
193+ interface InterfaceName
194+ {
195+ Task Method();
196+ }
197+ class ClassName : InterfaceName
198+ {
199+ Task Method() { return Task.FromResult(3); }
200+ Task InterfaceName.Method() { return Task.FromResult(3); }
201+ }
202+ " ;
203+ string fixedCode = @"
204+ using System.Threading.Tasks;
205+ interface InterfaceName
206+ {
207+ Task MethodAsync();
208+ }
209+ class ClassName : InterfaceName
210+ {
211+ Task MethodAsync() { return Task.FromResult(3); }
212+ Task InterfaceName.MethodAsync() { return Task.FromResult(3); }
213+ }
214+ " ;
215+
216+ DiagnosticResult [ ] expected =
217+ {
218+ this . CSharpDiagnostic ( ) . WithArguments ( "Method" ) . WithLocation ( 5 , 10 ) ,
219+ this . CSharpDiagnostic ( ) . WithArguments ( "Method" ) . WithLocation ( 9 , 10 )
220+ } ;
221+
222+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
223+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
224+ await this . VerifyCSharpFixAsync ( testCode , fixedCode , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
225+ }
226+
227+ [ Fact ]
228+ public async Task TestImplicitInterfaceReturnTaskAsync ( )
229+ {
230+ string testCode = @"
231+ using System.Threading.Tasks;
232+ interface InterfaceName
233+ {
234+ Task Method();
235+ }
236+ class ClassName : InterfaceName
237+ {
238+ public Task Method() { return Task.FromResult(3); }
239+ }
240+ " ;
241+ string fixedCode = @"
242+ using System.Threading.Tasks;
243+ interface InterfaceName
244+ {
245+ Task MethodAsync();
246+ }
247+ class ClassName : InterfaceName
248+ {
249+ public Task MethodAsync() { return Task.FromResult(3); }
250+ }
251+ " ;
252+
253+ DiagnosticResult expected = this . CSharpDiagnostic ( ) . WithArguments ( "Method" ) . WithLocation ( 5 , 10 ) ;
254+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
255+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
256+ await this . VerifyCSharpFixAsync ( testCode , fixedCode , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
257+ }
258+
259+ [ Fact ]
260+ public async Task TestImplicitGenericInterfaceReturnTaskAsync ( )
261+ {
262+ string testCode = @"
263+ using System.Threading.Tasks;
264+ interface InterfaceName<T>
265+ {
266+ Task Method(T value);
267+ }
268+ class ClassName : InterfaceName<int>
269+ {
270+ public Task Method(int value) { return Task.FromResult(value); }
271+ }
272+ " ;
273+ string fixedCode = @"
274+ using System.Threading.Tasks;
275+ interface InterfaceName<T>
276+ {
277+ Task MethodAsync(T value);
278+ }
279+ class ClassName : InterfaceName<int>
280+ {
281+ public Task MethodAsync(int value) { return Task.FromResult(value); }
282+ }
283+ " ;
284+
285+ DiagnosticResult expected = this . CSharpDiagnostic ( ) . WithArguments ( "Method" ) . WithLocation ( 5 , 10 ) ;
286+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
287+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
288+ await this . VerifyCSharpFixAsync ( testCode , fixedCode , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
289+ }
290+
291+ [ Fact ]
292+ public async Task TestImplicitGenericInterfaceMethodReturnTaskAsync ( )
293+ {
294+ string testCode = @"
295+ using System.Threading.Tasks;
296+ interface InterfaceName
297+ {
298+ Task Method<T>(T value);
299+ }
300+ class ClassName : InterfaceName
301+ {
302+ public Task Method<T>(T value) { return Task.FromResult(value); }
303+ }
304+ " ;
305+ string fixedCode = @"
306+ using System.Threading.Tasks;
307+ interface InterfaceName
308+ {
309+ Task MethodAsync<T>(T value);
310+ }
311+ class ClassName : InterfaceName
312+ {
313+ public Task MethodAsync<T>(T value) { return Task.FromResult(value); }
314+ }
315+ " ;
316+
317+ DiagnosticResult expected = this . CSharpDiagnostic ( ) . WithArguments ( "Method" ) . WithLocation ( 5 , 10 ) ;
318+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
319+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
320+ await this . VerifyCSharpFixAsync ( testCode , fixedCode , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
321+ }
322+
124323 [ Fact ]
125324 public async Task TestReturnGenericTaskAsync ( )
126325 {
0 commit comments