Skip to content

Add IDE tests for nameof(parameter) and mitigation for speculation issue#60802

Merged
jcouv merged 4 commits intodotnet:features/nameof-parameterfrom
jcouv:nameof-ide
Apr 25, 2022
Merged

Add IDE tests for nameof(parameter) and mitigation for speculation issue#60802
jcouv merged 4 commits intodotnet:features/nameof-parameterfrom
jcouv:nameof-ide

Conversation

@jcouv
Copy link
Copy Markdown
Member

@jcouv jcouv commented Apr 17, 2022

Filed #60801 (issue with speculation inside attributes)
Filed #60812 (issue with completion in empty nameof in new locations)

Test plan #40524

Comment on lines +12028 to +12029
// An invocation may not be considered a 'nameof' operator unless it has one argument
await VerifyItemIsAbsentAsync(MakeMarkup(source), "parameter");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it would be good to support this. It can be very helpful for CallerArgumentExpression too:

void M(int arg, [CallerArgumentExpression(nameof($$))] int parameter) { }

It would be good to suggest arg without having to type a

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed, but that will likely have to be left for IDE layer to refine, as compiler API is behaving by-design. I think there's already IDE logic to handle nameof specially, and it would have to be expanded in some later PR.

@jcouv jcouv marked this pull request as ready for review April 18, 2022 05:28
@jcouv jcouv requested review from a team as code owners April 18, 2022 05:28
@jcouv
Copy link
Copy Markdown
Member Author

jcouv commented Apr 18, 2022

@sharwell for IDE review. This is the outcome of my IDE test pass on nameof(parameter) feature.
There is no IDE product code change, only added some tests and a flag to test helpers to skip the speculation part of test (see issues listed in OP).

@jcouv
Copy link
Copy Markdown
Member Author

jcouv commented Apr 18, 2022

@AlekseyTs @RikkiGibson @dotnet/roslyn-compiler for review (small change to mitigate a binding issue when speculating). Thanks

@RikkiGibson RikkiGibson self-assigned this Apr 18, 2022
Co-authored-by: Rikki Gibson <rikkigibson@gmail.com>
@jcouv
Copy link
Copy Markdown
Member Author

jcouv commented Apr 19, 2022

@AlekseyTs @RikkiGibson @dotnet/roslyn-compiler for review. Thanks

@jcouv jcouv requested a review from sharwell April 19, 2022 17:11
Copy link
Copy Markdown
Member

@RikkiGibson RikkiGibson left a comment

Choose a reason for hiding this comment

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

changes under Compilers LGTM

@jcouv
Copy link
Copy Markdown
Member Author

jcouv commented Apr 20, 2022

@AlekseyTs https://github.com/orgs/dotnet/teams/roslyn-compiler for second review. Thanks

Copy link
Copy Markdown
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

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

Changes under Compilers LGTM (commit 4)

int? glyph, int? matchPriority, bool? hasSuggestionItem, string displayTextSuffix,
string displayTextPrefix, string inlineDescription = null, bool? isComplexTextEdit = null,
List<CompletionFilter> matchingFilters = null, CompletionItemFlags? flags = null)
List<CompletionFilter> matchingFilters = null, CompletionItemFlags? flags = null, bool skipSpeculation = false)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

? :-/

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There's an existing compiler issue with speculation inside attributes on local functions and lambdas (see filed issue from OP). One of the impacts is that nameof doesn't introducing extra identifiers in scope during speculation.
So speculation portion of these IDE tests was skipped for now (tracked with follow-up issue). It's sad that this flag had to be threaded through so many places :-/

";
// Speculation within attributes on local functions is broken
// Tracked by https://github.com/dotnet/roslyn/issues/60801
await VerifyItemExistsAsync(MakeMarkup(source), "parameter", skipSpeculation: true);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

so that really worries me. is this high pri to fix?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Brainstormed with Aleksey and it's a bit involved to fix (I have notes from what Aleksey suggested). I likely won't be able to look at it before June. Might ask Rikki if he has bandwidth, since likely affects other scenarios with attributes on local functions and lambdas.

@jcouv
Copy link
Copy Markdown
Member Author

jcouv commented Apr 22, 2022

@CyrusNajmabadi Did you have any other feedback? Thanks

Copy link
Copy Markdown
Contributor

@CyrusNajmabadi CyrusNajmabadi left a comment

Choose a reason for hiding this comment

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

LGTM, as long as we take care of the speculation flag :)

@jcouv jcouv merged commit 33fe264 into dotnet:features/nameof-parameter Apr 25, 2022
@jcouv jcouv deleted the nameof-ide branch April 25, 2022 04:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants