Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify fix-all code #73805

Merged
merged 3 commits into from
May 31, 2024

Conversation

CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented May 31, 2024

No need for a fix-all provider to force creating a semantic model (which also creates compilations/SG docs) if it doesn't need it.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner May 31, 2024 16:44
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels May 31, 2024
/// the <see cref="FixAllState"/> in case that would be useful (for example if the <see
/// cref="IFixAllState.CodeActionEquivalenceKey"/> is used.
/// <para/>
/// Only one of these three overloads needs to be overridden if you want to customize behavior.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

three

two?

@@ -55,42 +51,24 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
if (declarationTypeToFix == null)
return;

RegisterCodeFix(context, CSharpCodeFixesResources.Declare_as_nullable, GetEquivalenceKey(node, model));
RegisterCodeFix(context, CSharpCodeFixesResources.Declare_as_nullable, GetEquivalenceKey(node));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RegisterCodeFix

Can getting the model be pushed into TryGetDeclarationTypeToFix as it might not always need it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@@ -108,29 +86,31 @@ static bool IsRemoteApiUsage(SyntaxNode node, SemanticModel model)
foreach (var diagnostic in diagnostics)
{
var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
MakeDeclarationNullable(editor, model, node, alreadyHandled, cancellationToken);
await MakeDeclarationNullableAsync(
document, model, editor, node, alreadyHandled, cancellationToken).ConfigureAwait(false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

model

could be lazy so model isn't needed up front here too

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true. but i'm ok here deferring that until we have some traces indicating benefit :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants