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

Make completion handler more resilient #69795

Merged
merged 3 commits into from
Sep 6, 2023
Merged

Make completion handler more resilient #69795

merged 3 commits into from
Sep 6, 2023

Conversation

genlu
Copy link
Member

@genlu genlu commented Sep 1, 2023

This contains two individual fixes.

  1. A general defense against unknown errors when resolving completion changes in LSP handler.
  2. Fix override completion to not throw if for some reason we can't find System.NotImplementedExcetpion type in the compilation (i.e. the error in Unity assemblies targeting .Net framework 4.7.1 fail to load on Mac, plugin v2.0.328 vscode-csharp#6048)

@genlu genlu requested a review from a team as a code owner September 1, 2023 00:51
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Sep 1, 2023
}
catch (Exception e) when (FatalError.ReportAndCatchUnlessCanceled(e))
{
// In case of exception, we simply return DisplayText with default span as the change.
Copy link
Member

Choose a reason for hiding this comment

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

Does DisplayText have the risk of containing stars in the case of an IntelliCode suggestion?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, you are right. I thought I had moved them to use DisplayTextPrefix, turns out I never did.

Copy link
Member

Choose a reason for hiding this comment

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

So is this going to insert stars into the file in that case? Is there a change to make here or should we just be moving to DisplayTextPrefix?

Copy link
Member Author

@genlu genlu Sep 6, 2023

Choose a reason for hiding this comment

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

Yes, this will insert the star if call to GetChange crashes, which is unlikely to happen with current implementation though, since the change was computed during the calculation of CompletionItem, GetChange simply retrieve it from the property bag (see here). We should take this change as is (i.e. fallback to using DisplayText). I will make a separate change in Pythia to use DisplayTextPrefix for the star (because it's seems to be the right thing to do anyway)

Copy link
Member

@sharwell sharwell left a comment

Choose a reason for hiding this comment

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

Requesting more time to review

sharwell

This comment was marked as outdated.

Copy link
Member

@sharwell sharwell left a comment

Choose a reason for hiding this comment

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

Based on my review of the original issue, I believe the handling and presentation of the error is reasonable (no change needed). We should instead fix the override completion provider to not produce this error, either by avoiding the use of the NotImplementedException symbol altogether, or by falling back to construction from a fully qualified identifier in the case where it's null.

Copy link
Member

@jasonmalinowski jasonmalinowski left a comment

Choose a reason for hiding this comment

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

I like we're both fixing the underlying bug and also adding the try/catch to keep this more resilient.

@genlu
Copy link
Member Author

genlu commented Sep 6, 2023

@sharwell I have reset your review since I have added the fix for override completion provider, and I think having a general defense against CompletionProvider crash is an improvement.

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