@@ -238,7 +238,7 @@ public T TestMethod2<T>()
238238 }
239239
240240 /// <summary>
241- /// Verifies that <c>new CancellationTokenI ()</c> is replaced by <c>CancellationToken.None</c>.
241+ /// Verifies that <c>new CancellationToken ()</c> is replaced by <c>CancellationToken.None</c>.
242242 /// </summary>
243243 /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
244244 [ Fact ]
@@ -278,6 +278,47 @@ public void TestMethod()
278278 await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
279279 }
280280
281+ /// <summary>
282+ /// Verifies that the codefix will preserve trivia surrounding <c>new CancellationToken()</c>
283+ /// </summary>
284+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
285+ [ Fact ]
286+ public async Task VerifyCancellationTokenTriviaPreservationAsync ( )
287+ {
288+ var testCode = @"
289+ using System.Threading;
290+
291+ public class TestClass
292+ {
293+ public void TestMethod()
294+ {
295+ var ct1 = /* c1 */ new CancellationToken(); // c2
296+ }
297+ }
298+ " ;
299+
300+ var fixedTestCode = @"
301+ using System.Threading;
302+
303+ public class TestClass
304+ {
305+ public void TestMethod()
306+ {
307+ var ct1 = /* c1 */ CancellationToken.None; // c2
308+ }
309+ }
310+ " ;
311+
312+ DiagnosticResult [ ] expected =
313+ {
314+ this . CSharpDiagnostic ( ) . WithLocation ( 8 , 28 ) ,
315+ } ;
316+
317+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
318+ await this . VerifyCSharpDiagnosticAsync ( fixedTestCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
319+ await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
320+ }
321+
281322 /// <inheritdoc/>
282323 protected override IEnumerable < DiagnosticAnalyzer > GetCSharpDiagnosticAnalyzers ( )
283324 {
0 commit comments