@@ -61,6 +61,26 @@ private async Task Method2Async() { }
6161 await this . VerifyCSharpDiagnosticAsync ( testCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
6262 }
6363
64+ [ Fact ]
65+ public async Task TestCancellationTokenIsOutParameterAsync ( )
66+ {
67+ string testCode = @"
68+ using System.Threading;
69+ using System.Threading.Tasks;
70+ class ClassName
71+ {
72+ public Task MethodAsync(out CancellationToken cancellationToken)
73+ {
74+ cancellationToken = CancellationToken.None;
75+ return Task.FromResult(0);
76+ }
77+ }
78+ " ;
79+
80+ var expected = this . CSharpDiagnostic ( ) . WithArguments ( "MethodAsync" ) . WithLocation ( 6 , 17 ) ;
81+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
82+ }
83+
6484 [ Fact ]
6585 public async Task TestCancellationTokenInStructureAsync ( )
6686 {
@@ -165,6 +185,31 @@ struct Context
165185 await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
166186 }
167187
188+ [ Fact ]
189+ public async Task TestContextStructureIsOutParameterAsync ( )
190+ {
191+ string testCode = @"
192+ using System.Threading;
193+ using System.Threading.Tasks;
194+ class ClassName
195+ {
196+ public Task MethodAsync(out Context context)
197+ {
198+ context = default(Context);
199+ return Task.FromResult(0);
200+ }
201+ }
202+
203+ struct Context
204+ {
205+ public CancellationToken CancellationToken { get; }
206+ }
207+ " ;
208+
209+ var expected = this . CSharpDiagnostic ( ) . WithArguments ( "MethodAsync" ) . WithLocation ( 6 , 17 ) ;
210+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
211+ }
212+
168213 [ Fact ]
169214 public async Task TestCancellationTokenInInterfaceAsync ( )
170215 {
0 commit comments