`this` is not recommended inside `nameof` in an attribute argument context
Version Used
Visual Studio Version 17.14.5 Roslyn 4.14.0-3.25279.5 @ 995f12b60535afe75cafbcefada9161d8dc4f31f
Steps to Reproduce
Paste the following code anywhere applicable and place the cursor in the $$ position:
public class Example
{
private string _field;
[MemberNotNull(nameof($$))]
public void Method()
{
}
}
Start typing this.
Expected result
this is recommended.
Actual result
this is not recommended.
Note, typing this. and then starting to type _field properly recommends the field.
This doesn't seem related, but it's such a coincidence that I'll point to it anyway: https://github.com/dotnet/roslyn/issues/78983
Hi @CyrusNajmabadi 👋 I’d like to work on this issue (#78979). It seems that inside an attribute like [MemberNotNull(nameof($$))], this. isn’t being suggested and the IDE shows “this is not recommended”—which isn't accurate. I'd like to explore the completion provider logic and adjust it so that this. is appropriately recommended in this context. Please let me know if there are existing tests to update or a preferred approach to proceed.
Sure. Look for the ThisKeywordRecomender and the corresponding ThisKeywordRecomenderTests.
Thanks!