@@ -66,12 +66,12 @@ public partial class ExternalType : IEquatable<ExternalType>
6666
6767 var externalCompilation = CSharpCompilation . Create (
6868 "ExternalLib" ,
69- new [ ] { CSharpSyntaxTree . ParseText ( externalSource ) } ,
69+ new [ ] { CSharpSyntaxTree . ParseText ( externalSource , cancellationToken : TestContext . Current . CancellationToken ) } ,
7070 CoreReferences ,
7171 new CSharpCompilationOptions ( OutputKind . DynamicallyLinkedLibrary ) ) ;
7272
7373 // Verify the external compilation has no errors
74- var externalDiagnostics = externalCompilation . GetDiagnostics ( ) ;
74+ var externalDiagnostics = externalCompilation . GetDiagnostics ( TestContext . Current . CancellationToken ) ;
7575 var errors = externalDiagnostics . Where ( d => d . Severity == DiagnosticSeverity . Error ) . ToList ( ) ;
7676 if ( errors . Count > 0 )
7777 throw new Exception ( $ "External compilation had errors: { string . Join ( ", " , errors . Select ( e => e . GetMessage ( ) ) ) } ") ;
@@ -97,12 +97,12 @@ public partial class Container
9797
9898 var mainCompilation = CSharpCompilation . Create (
9999 "MainApp" ,
100- new [ ] { CSharpSyntaxTree . ParseText ( mainSource ) } ,
100+ new [ ] { CSharpSyntaxTree . ParseText ( mainSource , cancellationToken : TestContext . Current . CancellationToken ) } ,
101101 mainReferences ,
102102 new CSharpCompilationOptions ( OutputKind . DynamicallyLinkedLibrary ) ) ;
103103
104104 // Verify the main compilation has no errors
105- var mainDiagnostics = mainCompilation . GetDiagnostics ( ) ;
105+ var mainDiagnostics = mainCompilation . GetDiagnostics ( TestContext . Current . CancellationToken ) ;
106106 var mainErrors = mainDiagnostics . Where ( d => d . Severity == DiagnosticSeverity . Error ) . ToList ( ) ;
107107 if ( mainErrors . Count > 0 )
108108 throw new Exception ( $ "Main compilation had errors: { string . Join ( ", " , mainErrors . Select ( e => e . GetMessage ( ) ) ) } ") ;
@@ -153,7 +153,7 @@ public partial class ExternalType : IEquatable<ExternalType>
153153
154154 var externalCompilation = CSharpCompilation . Create (
155155 "ExternalLib" ,
156- new [ ] { CSharpSyntaxTree . ParseText ( externalSource ) } ,
156+ new [ ] { CSharpSyntaxTree . ParseText ( externalSource , cancellationToken : TestContext . Current . CancellationToken ) } ,
157157 CoreReferences ,
158158 new CSharpCompilationOptions ( OutputKind . DynamicallyLinkedLibrary ) ) ;
159159
@@ -176,7 +176,7 @@ public partial class Container
176176
177177 var mainCompilation = CSharpCompilation . Create (
178178 "MainApp" ,
179- new [ ] { CSharpSyntaxTree . ParseText ( mainSource ) } ,
179+ new [ ] { CSharpSyntaxTree . ParseText ( mainSource , cancellationToken : TestContext . Current . CancellationToken ) } ,
180180 mainReferences ,
181181 new CSharpCompilationOptions ( OutputKind . DynamicallyLinkedLibrary ) ) ;
182182
@@ -185,7 +185,7 @@ public partial class Container
185185 var compilationWithAnalyzers = mainCompilation . WithAnalyzers (
186186 ImmutableArray . Create ( analyzer ) ) ;
187187
188- var analyzerDiagnostics = await compilationWithAnalyzers . GetAnalyzerDiagnosticsAsync ( ) ;
188+ var analyzerDiagnostics = await compilationWithAnalyzers . GetAnalyzerDiagnosticsAsync ( TestContext . Current . CancellationToken ) ;
189189
190190 // Filter for GE002 diagnostics
191191 var ge002Diagnostics = analyzerDiagnostics
@@ -214,12 +214,12 @@ public partial record ExternalSettings
214214
215215 var externalCompilation = CSharpCompilation . Create (
216216 "ExternalLib" ,
217- new [ ] { CSharpSyntaxTree . ParseText ( externalSource ) } ,
217+ new [ ] { CSharpSyntaxTree . ParseText ( externalSource , cancellationToken : TestContext . Current . CancellationToken ) } ,
218218 CoreReferences ,
219219 new CSharpCompilationOptions ( OutputKind . DynamicallyLinkedLibrary ) ) ;
220220
221221 // Verify the external compilation has no errors
222- var externalDiagnostics = externalCompilation . GetDiagnostics ( ) ;
222+ var externalDiagnostics = externalCompilation . GetDiagnostics ( TestContext . Current . CancellationToken ) ;
223223 var errors = externalDiagnostics . Where ( d => d . Severity == DiagnosticSeverity . Error ) . ToList ( ) ;
224224 if ( errors . Count > 0 )
225225 throw new Exception ( $ "External compilation had errors: { string . Join ( ", " , errors . Select ( e => e . GetMessage ( ) ) ) } ") ;
@@ -244,7 +244,7 @@ public readonly partial record struct ContainerState
244244
245245 var mainCompilation = CSharpCompilation . Create (
246246 "MainApp" ,
247- new [ ] { CSharpSyntaxTree . ParseText ( mainSource ) } ,
247+ new [ ] { CSharpSyntaxTree . ParseText ( mainSource , cancellationToken : TestContext . Current . CancellationToken ) } ,
248248 mainReferences ,
249249 new CSharpCompilationOptions ( OutputKind . DynamicallyLinkedLibrary ) ) ;
250250
@@ -288,7 +288,7 @@ public partial record ExternalSettings
288288
289289 var externalCompilation = CSharpCompilation . Create (
290290 "ExternalLib" ,
291- new [ ] { CSharpSyntaxTree . ParseText ( externalSource ) } ,
291+ new [ ] { CSharpSyntaxTree . ParseText ( externalSource , cancellationToken : TestContext . Current . CancellationToken ) } ,
292292 CoreReferences ,
293293 new CSharpCompilationOptions ( OutputKind . DynamicallyLinkedLibrary ) ) ;
294294
@@ -311,7 +311,7 @@ public readonly partial record struct ContainerState
311311
312312 var mainCompilation = CSharpCompilation . Create (
313313 "MainApp" ,
314- new [ ] { CSharpSyntaxTree . ParseText ( mainSource ) } ,
314+ new [ ] { CSharpSyntaxTree . ParseText ( mainSource , cancellationToken : TestContext . Current . CancellationToken ) } ,
315315 mainReferences ,
316316 new CSharpCompilationOptions ( OutputKind . DynamicallyLinkedLibrary ) ) ;
317317
@@ -320,7 +320,7 @@ public readonly partial record struct ContainerState
320320 var compilationWithAnalyzers = mainCompilation . WithAnalyzers (
321321 ImmutableArray . Create ( analyzer ) ) ;
322322
323- var analyzerDiagnostics = await compilationWithAnalyzers . GetAnalyzerDiagnosticsAsync ( ) ;
323+ var analyzerDiagnostics = await compilationWithAnalyzers . GetAnalyzerDiagnosticsAsync ( TestContext . Current . CancellationToken ) ;
324324
325325 var ge002Diagnostics = analyzerDiagnostics
326326 . Where ( d => d . Id == "GE002" )
@@ -355,12 +355,12 @@ public partial record ExternalSettings
355355
356356 var externalCompilation = CSharpCompilation . Create (
357357 "ExternalLib" ,
358- new [ ] { CSharpSyntaxTree . ParseText ( externalSource ) } ,
358+ new [ ] { CSharpSyntaxTree . ParseText ( externalSource , cancellationToken : TestContext . Current . CancellationToken ) } ,
359359 CoreReferences ,
360360 new CSharpCompilationOptions ( OutputKind . DynamicallyLinkedLibrary ) ) ;
361361
362362 // Emit to actual DLL
363- var emitResult = externalCompilation . Emit ( externalDllPath ) ;
363+ var emitResult = externalCompilation . Emit ( externalDllPath , cancellationToken : TestContext . Current . CancellationToken ) ;
364364 if ( ! emitResult . Success )
365365 {
366366 var errors = emitResult . Diagnostics . Where ( d => d . Severity == DiagnosticSeverity . Error ) ;
@@ -393,12 +393,12 @@ public readonly partial record struct ContainerState
393393
394394 var mainCompilation = CSharpCompilation . Create (
395395 "MainApp" ,
396- new [ ] { CSharpSyntaxTree . ParseText ( mainSource ) } ,
396+ new [ ] { CSharpSyntaxTree . ParseText ( mainSource , cancellationToken : TestContext . Current . CancellationToken ) } ,
397397 mainReferences ,
398398 new CSharpCompilationOptions ( OutputKind . DynamicallyLinkedLibrary ) ) ;
399399
400400 // Debug: Check compilation errors first
401- var mainErrors = mainCompilation . GetDiagnostics ( ) . Where ( d => d . Severity == DiagnosticSeverity . Error ) . ToList ( ) ;
401+ var mainErrors = mainCompilation . GetDiagnostics ( TestContext . Current . CancellationToken ) . Where ( d => d . Severity == DiagnosticSeverity . Error ) . ToList ( ) ;
402402 if ( mainErrors . Count > 0 )
403403 throw new Exception ( $ "Main compilation had errors: { string . Join ( ", " , mainErrors . Select ( e => e . GetMessage ( ) ) ) } ") ;
404404
@@ -444,7 +444,7 @@ public readonly partial record struct ContainerState
444444 var compilationWithAnalyzers = mainCompilation . WithAnalyzers (
445445 ImmutableArray . Create ( analyzer ) ) ;
446446
447- var analyzerDiagnostics = await compilationWithAnalyzers . GetAnalyzerDiagnosticsAsync ( ) ;
447+ var analyzerDiagnostics = await compilationWithAnalyzers . GetAnalyzerDiagnosticsAsync ( TestContext . Current . CancellationToken ) ;
448448
449449 var ge002Diagnostics = analyzerDiagnostics
450450 . Where ( d => d . Id == "GE002" )
@@ -485,7 +485,7 @@ public AliasAttribute(string name) { }
485485
486486 var mockPackageCompilation = CSharpCompilation . Create (
487487 "MockPackage" ,
488- new [ ] { CSharpSyntaxTree . ParseText ( mockPackageSource ) } ,
488+ new [ ] { CSharpSyntaxTree . ParseText ( mockPackageSource , cancellationToken : TestContext . Current . CancellationToken ) } ,
489489 CoreReferences ,
490490 new CSharpCompilationOptions ( OutputKind . DynamicallyLinkedLibrary ) ) ;
491491
@@ -509,11 +509,11 @@ public sealed partial record Settings
509509 var externalRefs = CoreReferences . Append ( mockPackageReference ) . ToArray ( ) ;
510510 var externalCompilation = CSharpCompilation . Create (
511511 "ExternalLib" ,
512- new [ ] { CSharpSyntaxTree . ParseText ( externalSource ) } ,
512+ new [ ] { CSharpSyntaxTree . ParseText ( externalSource , cancellationToken : TestContext . Current . CancellationToken ) } ,
513513 externalRefs ,
514514 new CSharpCompilationOptions ( OutputKind . DynamicallyLinkedLibrary ) ) ;
515515
516- var externalErrors = externalCompilation . GetDiagnostics ( ) . Where ( d => d . Severity == DiagnosticSeverity . Error ) . ToList ( ) ;
516+ var externalErrors = externalCompilation . GetDiagnostics ( TestContext . Current . CancellationToken ) . Where ( d => d . Severity == DiagnosticSeverity . Error ) . ToList ( ) ;
517517 if ( externalErrors . Count > 0 )
518518 throw new Exception ( $ "External compilation had errors: { string . Join ( ", " , externalErrors . Select ( e => e . GetMessage ( ) ) ) } ") ;
519519
@@ -537,7 +537,7 @@ public readonly partial record struct ContainerState
537537
538538 var mainCompilation = CSharpCompilation . Create (
539539 "MainApp" ,
540- new [ ] { CSharpSyntaxTree . ParseText ( mainSource ) } ,
540+ new [ ] { CSharpSyntaxTree . ParseText ( mainSource , cancellationToken : TestContext . Current . CancellationToken ) } ,
541541 mainReferences ,
542542 new CSharpCompilationOptions ( OutputKind . DynamicallyLinkedLibrary ) ) ;
543543
@@ -562,7 +562,7 @@ public readonly partial record struct ContainerState
562562 var compilationWithAnalyzers = mainCompilation . WithAnalyzers (
563563 ImmutableArray . Create ( analyzer ) ) ;
564564
565- var analyzerDiagnostics = await compilationWithAnalyzers . GetAnalyzerDiagnosticsAsync ( ) ;
565+ var analyzerDiagnostics = await compilationWithAnalyzers . GetAnalyzerDiagnosticsAsync ( TestContext . Current . CancellationToken ) ;
566566
567567 var ge002Diagnostics = analyzerDiagnostics
568568 . Where ( d => d . Id == "GE002" )
@@ -592,11 +592,11 @@ public sealed partial record ExternalSettings
592592
593593 var externalCompilation = CSharpCompilation . Create (
594594 "ExternalLib" ,
595- new [ ] { CSharpSyntaxTree . ParseText ( externalSource ) } ,
595+ new [ ] { CSharpSyntaxTree . ParseText ( externalSource , cancellationToken : TestContext . Current . CancellationToken ) } ,
596596 CoreReferences ,
597597 new CSharpCompilationOptions ( OutputKind . DynamicallyLinkedLibrary ) ) ;
598598
599- var errors = externalCompilation . GetDiagnostics ( )
599+ var errors = externalCompilation . GetDiagnostics ( TestContext . Current . CancellationToken )
600600 . Where ( d => d . Severity == DiagnosticSeverity . Error ) . ToList ( ) ;
601601 if ( errors . Count > 0 )
602602 throw new Exception ( $ "Compilation errors: { string . Join ( ", " , errors . Select ( e => e . GetMessage ( ) ) ) } ") ;
@@ -605,7 +605,7 @@ public sealed partial record ExternalSettings
605605
606606 var mainCompilation = CSharpCompilation . Create (
607607 "MainApp" ,
608- new [ ] { CSharpSyntaxTree . ParseText ( "// empty" ) } ,
608+ new [ ] { CSharpSyntaxTree . ParseText ( "// empty" , cancellationToken : TestContext . Current . CancellationToken ) } ,
609609 CoreReferences . Append ( externalReference ) . ToArray ( ) ,
610610 new CSharpCompilationOptions ( OutputKind . DynamicallyLinkedLibrary ) ) ;
611611
0 commit comments