Skip to content

Commit

Permalink
Implements support for adding and removing await/yield return in C# i…
Browse files Browse the repository at this point in the history
…n the IDE (#61521)
  • Loading branch information
tmat authored May 31, 2022
1 parent ad3278f commit cc2bbf4
Show file tree
Hide file tree
Showing 11 changed files with 514 additions and 202 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9418,7 +9418,7 @@ static IEnumerable<int> F()
var active = GetActiveStatements(src1, src2);

edits.VerifySemanticDiagnostics(active,
Diagnostic(RudeEditKind.InsertAroundActiveStatement, "yield return 1;", CSharpFeaturesResources.yield_return_statement));
Diagnostic(RudeEditKind.UpdatingStateMachineMethodAroundActiveStatement, "static IEnumerable<int> F()"));
}

[Fact]
Expand Down Expand Up @@ -9512,7 +9512,7 @@ static async Task<int> F()
var active = GetActiveStatements(src1, src2);

edits.VerifySemanticDiagnostics(active,
Diagnostic(RudeEditKind.InsertAroundActiveStatement, "await", CSharpFeaturesResources.await_expression));
Diagnostic(RudeEditKind.UpdatingStateMachineMethodAroundActiveStatement, "static async Task<int> F()"));
}

[Fact]
Expand Down Expand Up @@ -9544,7 +9544,7 @@ static async Task<int> F()
var active = GetActiveStatements(src1, src2);

edits.VerifySemanticDiagnostics(active,
Diagnostic(RudeEditKind.InsertAroundActiveStatement, "await foreach (var x in AsyncIter())", CSharpFeaturesResources.asynchronous_foreach_statement));
Diagnostic(RudeEditKind.UpdatingStateMachineMethodAroundActiveStatement, "static async Task<int> F()"));
}

[Fact]
Expand Down Expand Up @@ -9576,8 +9576,7 @@ static async Task<int> F()
var active = GetActiveStatements(src1, src2);

edits.VerifySemanticDiagnostics(active,
Diagnostic(RudeEditKind.InsertAroundActiveStatement, "x = new AsyncDisposable()", CSharpFeaturesResources.asynchronous_using_declaration),
Diagnostic(RudeEditKind.InsertAroundActiveStatement, "y = new AsyncDisposable()", CSharpFeaturesResources.asynchronous_using_declaration));
Diagnostic(RudeEditKind.UpdatingStateMachineMethodAroundActiveStatement, "static async Task<int> F()"));
}

[Fact]
Expand Down Expand Up @@ -9825,7 +9824,7 @@ static void F()
var active = GetActiveStatements(src1, src2);

edits.VerifySemanticDiagnostics(active,
Diagnostic(RudeEditKind.InsertAroundActiveStatement, "await", CSharpFeaturesResources.await_expression));
Diagnostic(RudeEditKind.UpdatingStateMachineMethodAroundActiveStatement, "()"));
}

[Fact]
Expand Down Expand Up @@ -9922,7 +9921,7 @@ async Task<int> f()
var active = GetActiveStatements(src1, src2);

edits.VerifySemanticDiagnostics(active,
Diagnostic(RudeEditKind.InsertAroundActiveStatement, "await", CSharpFeaturesResources.await_expression));
Diagnostic(RudeEditKind.UpdatingStateMachineMethodAroundActiveStatement, "f"));
}

[Fact]
Expand Down Expand Up @@ -9951,7 +9950,7 @@ static void F()
var active = GetActiveStatements(src1, src2);

edits.VerifySemanticDiagnostics(active,
Diagnostic(RudeEditKind.InsertAroundActiveStatement, "await", CSharpFeaturesResources.await_expression));
Diagnostic(RudeEditKind.UpdatingStateMachineMethodAroundActiveStatement, "f"));
}

[Fact]
Expand Down
191 changes: 76 additions & 115 deletions src/EditorFeatures/CSharpTest/EditAndContinue/StatementEditingTests.cs

Large diffs are not rendered by default.

Loading

0 comments on commit cc2bbf4

Please sign in to comment.