Add back async fixers#81835
Merged
Merged
Conversation
CyrusNajmabadi
commented
Jan 2, 2026
CyrusNajmabadi
commented
Jan 2, 2026
| [ExtensionOrder(After = PredefinedCodeFixProviderNames.AddImport)] | ||
| [method: ImportingConstructor] | ||
| [method: SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")] | ||
| internal sealed class CSharpMakeMethodSynchronousCodeFixProvider() : AbstractMakeMethodSynchronousCodeFixProvider |
Contributor
Author
There was a problem hiding this comment.
this type is unchanged from the original. It was brought back from #80144
CyrusNajmabadi
commented
Jan 2, 2026
| [ExtensionOrder(After = PredefinedCodeFixProviderNames.MakeMethodSynchronous)] | ||
| [method: ImportingConstructor] | ||
| [method: SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")] | ||
| internal sealed partial class CSharpRemoveAsyncModifierCodeFixProvider() : AbstractRemoveAsyncModifierCodeFixProvider<ReturnStatementSyntax, ExpressionSyntax> |
Contributor
Author
There was a problem hiding this comment.
This type is unchanged. It was brought back directly from #80144
CyrusNajmabadi
commented
Jan 2, 2026
|
|
||
| namespace Microsoft.CodeAnalysis.CSharp.RemoveAsyncModifier; | ||
|
|
||
| internal static class RemoveAsyncModifierHelpers |
Contributor
Author
There was a problem hiding this comment.
This type is unchanged it was brought back directly from #80144
Contributor
Author
|
@dotnet/roslyn-ide @JoeRobich ptal. |
JoeRobich
approved these changes
Jan 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a new IDE/code-style layer analyzer for detecting when an
asyncmethod/lambda contains noawaits and thus can be made synchronous (and no longer task-returning). This previously existed, but was removed when we removed the reporting of CS1998 in #80144.The reason to add this back in is that it can still be useful for users to know when they have made a method asynchronous unintentionally. For example, if it at one point had an
asynccall, but then the lastasynccall was removed. In that case, the method could be made entirely synchronous, potentially virally, making a large swath of a component that was previously async, sync.The analyzer is NOT enabled by default. It can be opted into by users who liked having CS1998 catch and notify them when they no longer needed tasks at all.
There are places though where this sort of notification may be undesirable. For example, it is common to have task-returning methods in interfaces or as virtual methods in base classes. Implementations of these methods need to stay task-returning to abide by their contract. Because of this, instead of having a single diagnostic ID controlling this, we have two:
Users who want to strictly avoid unnecessary task-returning methods in all cases can enable both. Users that just want to know for the standard case, but need to keep tasks for interface/overrides, can just enable the first.
--
Note: teh codefixprovider was just brought back from #80144, as were the tests. The tests were updated to use the new diagnostic id. and new tests were added to validate that we now have two distinct diagnostic IDs.