Skip to content

Commit a37aeb1

Browse files
author
msftbot[bot]
authored
Merge pull request #44811 from jmarolf/bugfix/forward-cancellation-tokens
propagate cancellation tokens
2 parents 1b75734 + ce442e7 commit a37aeb1

File tree

71 files changed

+97
-93
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+97
-93
lines changed

src/Analyzers/CSharp/CodeFixes/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionCodeFixProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ protected override async Task FixAllAsync(
7878
if (declaratorToRemoveLocationOpt != null)
7979
{
8080
declaratorToRemoveNodeOpt = declaratorToRemoveLocationOpt.FindNode(cancellationToken);
81-
declaratorToRemoveTypeOpt = semanticModel.GetDeclaredSymbol(declaratorToRemoveNodeOpt).GetSymbolType();
81+
declaratorToRemoveTypeOpt = semanticModel.GetDeclaredSymbol(declaratorToRemoveNodeOpt, cancellationToken).GetSymbolType();
8282
}
8383

8484
var switchStatement = (SwitchStatementSyntax)switchLocation.FindNode(getInnermostNodeForTie: true, cancellationToken);

src/Analyzers/CSharp/CodeFixes/UseImplicitOrExplicitType/UseExplicitTypeCodeFixProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ internal static async Task HandleDeclarationAsync(
9999
// We're going to be passed through the simplifier. Tell it to not just convert this back to var (as
100100
// that would defeat the purpose of this refactoring entirely).
101101
var newTypeSyntax =
102-
semanticModel.GetTypeInfo(typeSyntax).ConvertedType
102+
semanticModel.GetTypeInfo(typeSyntax, cancellationToken).ConvertedType
103103
.GenerateTypeSyntax(allowVar: false)
104104
.WithTriviaFrom(typeSyntax);
105105

@@ -109,7 +109,7 @@ internal static async Task HandleDeclarationAsync(
109109
}
110110
else
111111
{
112-
var tupleTypeSymbol = semanticModel.GetTypeInfo(typeSyntax.Parent).ConvertedType;
112+
var tupleTypeSymbol = semanticModel.GetTypeInfo(typeSyntax.Parent, cancellationToken).ConvertedType;
113113

114114
var leadingTrivia = node.GetLeadingTrivia()
115115
.Concat(parensDesignation.GetAllPrecedingTriviaToPreviousToken().Where(t => !t.IsWhitespace()).Select(t => t.WithoutAnnotations(SyntaxAnnotation.ElasticAnnotation)));

src/Analyzers/Core/CodeFixes/SimplifyInterpolation/AbstractSimplifyInterpolationCodeFixProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ protected override async Task FixAllAsync(
6060
foreach (var diagnostic in diagnostics)
6161
{
6262
var loc = diagnostic.AdditionalLocations[0];
63-
var interpolation = semanticModel.GetOperation(loc.FindNode(getInnermostNodeForTie: true, cancellationToken)) as IInterpolationOperation;
63+
var interpolation = semanticModel.GetOperation(loc.FindNode(getInnermostNodeForTie: true, cancellationToken), cancellationToken) as IInterpolationOperation;
6464
if (interpolation?.Syntax is TInterpolationSyntax interpolationSyntax &&
6565
interpolationSyntax.Parent is TInterpolatedStringExpressionSyntax interpolatedString)
6666
{

src/Analyzers/Core/CodeFixes/UseConditionalExpression/ForAssignment/AbstractUseConditionalExpressionForAssignmentCodeFixProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ protected override async Task FixOneAsync(
6565
var ifStatement = diagnostic.AdditionalLocations[0].FindNode(cancellationToken);
6666

6767
var semanticModel = await document.GetRequiredSemanticModelAsync(cancellationToken).ConfigureAwait(false);
68-
var ifOperation = (IConditionalOperation)semanticModel.GetOperation(ifStatement)!;
68+
var ifOperation = (IConditionalOperation)semanticModel.GetOperation(ifStatement, cancellationToken)!;
6969

7070
if (!UseConditionalExpressionForAssignmentHelpers.TryMatchPattern(
7171
syntaxFacts, ifOperation,

src/Analyzers/Core/CodeFixes/UseConditionalExpression/ForReturn/AbstractUseConditionalExpressionForReturnCodeFixProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ protected override async Task FixOneAsync(
5151
var ifStatement = (TIfStatementSyntax)diagnostic.AdditionalLocations[0].FindNode(cancellationToken);
5252

5353
var semanticModel = await document.GetRequiredSemanticModelAsync(cancellationToken).ConfigureAwait(false);
54-
var ifOperation = (IConditionalOperation)semanticModel.GetOperation(ifStatement)!;
54+
var ifOperation = (IConditionalOperation)semanticModel.GetOperation(ifStatement, cancellationToken)!;
5555
var containingSymbol = semanticModel.GetEnclosingSymbol(ifStatement.SpanStart, cancellationToken);
5656

5757
if (!UseConditionalExpressionForReturnHelpers.TryMatchPattern(

src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2638,7 +2638,7 @@ internal ImmutableArray<Diagnostic> GetDiagnosticsForSyntaxTree(
26382638
AppendLoadDirectiveDiagnostics(builder, _syntaxAndDeclarations, syntaxTree,
26392639
diagnostics => FilterDiagnosticsByLocation(diagnostics, syntaxTree, filterSpanWithinTree));
26402640

2641-
var syntaxDiagnostics = syntaxTree.GetDiagnostics();
2641+
var syntaxDiagnostics = syntaxTree.GetDiagnostics(cancellationToken);
26422642
syntaxDiagnostics = FilterDiagnosticsByLocation(syntaxDiagnostics, syntaxTree, filterSpanWithinTree);
26432643
builder.AddRange(syntaxDiagnostics);
26442644
}

src/Compilers/CSharp/Portable/Compilation/CSharpSemanticModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4937,7 +4937,7 @@ protected sealed override ISymbol GetDeclaredSymbolCore(SyntaxNode node, Cancell
49374937

49384938
if (declarationSyntax.Parent is TupleTypeSyntax tupleTypeSyntax)
49394939
{
4940-
return (GetSymbolInfo(tupleTypeSyntax).Symbol.GetSymbol() as NamedTypeSymbol)?.TupleElements.ElementAtOrDefault(tupleTypeSyntax.Elements.IndexOf(declarationSyntax)).GetPublicSymbol();
4940+
return (GetSymbolInfo(tupleTypeSyntax, cancellationToken).Symbol.GetSymbol() as NamedTypeSymbol)?.TupleElements.ElementAtOrDefault(tupleTypeSyntax.Elements.IndexOf(declarationSyntax)).GetPublicSymbol();
49414941
}
49424942

49434943
return null;

src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedSimpleProgramEntryPointSymbol.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ internal override bool IsDefinedInSourceTree(SyntaxTree tree, TextSpan? definedW
236236
{
237237
var span = definedWithinSpan.GetValueOrDefault();
238238

239-
foreach (var global in ((CompilationUnitSyntax)tree.GetRoot()).Members.OfType<GlobalStatementSyntax>())
239+
foreach (var global in ((CompilationUnitSyntax)tree.GetRoot(cancellationToken)).Members.OfType<GlobalStatementSyntax>())
240240
{
241241
cancellationToken.ThrowIfCancellationRequested();
242242

src/Compilers/Core/Portable/Compilation/Compilation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2729,7 +2729,7 @@ internal abstract EmitDifferenceResult EmitDifference(
27292729
if (IsSubmission && !HasCodeToEmit())
27302730
{
27312731
// Still report diagnostics since downstream submissions will assume there are no errors.
2732-
diagnostics.AddRange(this.GetDiagnostics());
2732+
diagnostics.AddRange(this.GetDiagnostics(cancellationToken));
27332733
return null;
27342734
}
27352735

src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ private async Task ProcessCompilationEventsAsync(AnalysisScope analysisScope, An
11611161
cancellationToken.ThrowIfCancellationRequested();
11621162

11631163
// Kick off tasks to execute syntax tree actions.
1164-
var syntaxTreeActionsTask = Task.Run(() => ExecuteSyntaxTreeActions(analysisScope, analysisStateOpt, cancellationToken));
1164+
var syntaxTreeActionsTask = Task.Run(() => ExecuteSyntaxTreeActions(analysisScope, analysisStateOpt, cancellationToken), cancellationToken);
11651165

11661166
// Wait for all worker threads to complete processing events.
11671167
await Task.WhenAll(workerTasks.Concat(syntaxTreeActionsTask)).ConfigureAwait(false);

0 commit comments

Comments
 (0)