Skip to content

Conversation

@maryamariyan
Copy link
Contributor

@maryamariyan maryamariyan commented Mar 23, 2025

Every time a developer uses the 💡 Generate Method feature in VS, then with a ctrl+dot the cursor gets placed on the name of the newly generated method which by default contains throw new NotImplementedException():

Implement_with_Copilot_GH_Clip.mp4

To help the discoverability and usability of Implement with Copilot, especially for the developers frequently using the Generate Method feature, I am making the analyzer diagnostic for Implement with Copilot also light up on the method or property name containing the NotImplementedException throw nodes.

@maryamariyan maryamariyan requested a review from a team as a code owner March 23, 2025 02:04
@ghost ghost added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Mar 23, 2025
@maryamariyan maryamariyan changed the title Make Implement with Copilot light up on method or property name with throw node Make Implement with Copilot light up on member name of throw node Mar 23, 2025
@maryamariyan maryamariyan changed the title Make Implement with Copilot light up on member name of throw node Make Implement with Copilot light up on member name Mar 23, 2025
@dotnet-policy-service dotnet-policy-service bot added Community The pull request was submitted by a contributor who is not a Microsoft employee. VSCode labels Mar 23, 2025
@JoeRobich
Copy link
Member

What are the downsides of reporting one diagnostic with the span of the entire method?

@maryamariyan
Copy link
Contributor Author

maryamariyan commented Mar 24, 2025

What are the downsides of reporting one diagnostic with the span of the entire method?

I considered that too. just went with this flow instead. can't think of downsides, just that I'd have to make new changes :) I like that the code action is specifically on the throw.

I just know that I got specific feedback that having it light up on method name makes sense.
@phil-allen-msft do you have opinions on this?

@CyrusNajmabadi
Copy link
Member

can't think of downsides,

The downside (including being on the method signature) is that this now shows up for anywhere in teh method no matter what you are on (and even if you don't see the throw-new-... part.

My recommendation woudl be that we only show this on the method itself if hte method is trivial. So it's a method that only contains the throw. Otherwise, we're making a strange connection here between a particular single expression in a method, with its header, which is not something we do elsewhere.

.RunAsync();
}

private static ImmutableDictionary<SyntaxNode, ImplementationDetails> BuildResult(ImmutableDictionary<SyntaxNode, ImmutableArray<ReferencedSymbol>> memberReferences, Dictionary<string, string> implementationMap)
Copy link
Member

Choose a reason for hiding this comment

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

why is the impl map keyed on string?

also, how would the impl map work if you have multiple methods with the same name. something is weird here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's just to mock copilot behavior for testing

Copy link
Contributor Author

@maryamariyan maryamariyan Mar 26, 2025

Choose a reason for hiding this comment

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

how would the impl map work if you have multiple methods with the same name

The method BuildResult here is mocking copilot behavior. In reality we match on other parts of the member such as params, return, etc. so that means we properly support overload use cases. The logic you see here is an oversimplification of what copilot service does and I am just mocking it here.

as far as roslyn is concerned, it gives and receives member nodes and therefore we are properly keying off of member, not any string whatsoever

…ntedExceptionDiagnosticAnalyzer.cs

Co-authored-by: Cyrus Najmabadi <cyrus.najmabadi@gmail.com>
@CyrusNajmabadi CyrusNajmabadi merged commit fa65373 into dotnet:main Mar 27, 2025
25 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Mar 27, 2025
@maryamariyan maryamariyan deleted the dev/maryamariyan/hint-on-name branch March 27, 2025 01:00
@jjonescz jjonescz modified the milestones: Next, 17.14 P3 Apr 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee. 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.

4 participants