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

Include CodeLens on remaining types and members #69608

Merged
merged 1 commit into from
Aug 18, 2023

Conversation

sharwell
Copy link
Member

@sharwell sharwell commented Aug 18, 2023

Support the following items in the LSP implementation of CodeLens (used by VS Code, but is not used by Visual Studio):

  • C#
    • Delegates
    • Enum members
    • Fields
    • Events (both full form and field form)
    • Destructors
  • Visual Basic
    • Delegates
    • Enum members
    • Fields
    • Events

Fixes #69583

@sharwell sharwell requested a review from a team as a code owner August 18, 2023 17:57
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Aug 18, 2023
_memberBuilder.Add(new CodeLensMember(node, node.Identifier.Span));
}

public override void VisitDestructorDeclaration(DestructorDeclarationSyntax node)
Copy link
Member

Choose a reason for hiding this comment

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

note: won't ever have results. so this may be likely to annoy people as it will always have "0 references" showing for it. Would prefer to not do this.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that's fine, for a few reasons:

  1. Behavior matches current Visual Studio behavior
  2. Destructors are rare and generally discouraged, so most users won't ever see the difference
  3. For the remaining users, it's less likely someone will ask why it shows 0 than for someone to ask why it's missing

public override void VisitDelegateDeclaration(DelegateDeclarationSyntax node)
{
_memberBuilder.Add(new CodeLensMember(node, node.Identifier.Span));
}
Copy link
Member

Choose a reason for hiding this comment

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

definitely approve of this.

{
_memberBuilder.Add(new CodeLensMember(variable, variable.Identifier.Span));
}
}
Copy link
Member

Choose a reason for hiding this comment

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

  1. what's teh consequence of this in VS for multi-declarator members?
  2. does thsi light up code-lens for fields for all users in VS. if so, i think this should be gated behind a user option peopel can opt into.

Copy link
Member Author

@sharwell sharwell Aug 18, 2023

Choose a reason for hiding this comment

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

what's teh consequence of this in VS [Code] for multi-declarator members?

I'm not sure how to test the UI in VS Code, but I would expect it to be able to handle this since today it's already possible to declare multiple properties on the same line of code.

does thsi light up code-lens for fields for all users in VS

This has no impact on Visual Studio. This is a VS Code feature.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure how to test the UI in VS Code

@dibarbet can you guide sam on this?

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure how to test the UI in VS Code, but I would expect it to be able to handle this since today it's already possible to declare multiple properties on the same line of code.

If you mean seeing the actual code lens items inside vscode, it should be relatively straightforward. Basically:

  1. Make sure the C# extension is installed and you can open a C# project
  2. Point the C# extension to your locally built server as described here - https://github.com/dotnet/vscode-csharp/blob/main/CONTRIBUTING.md#using-a-locally-developed-roslyn-server
  3. Reload the window

Copy link
Member Author

Choose a reason for hiding this comment

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

It's going to end up working like this:
image

@sharwell sharwell merged commit 6652c33 into dotnet:main Aug 18, 2023
@sharwell sharwell deleted the codelens-vscode-fields branch August 18, 2023 22:14
@ghost ghost added this to the Next milestone Aug 18, 2023
@dibarbet dibarbet modified the milestones: Next, 17.8 P2 Aug 28, 2023
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 VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Codelens to get the references on fields is missing
4 participants