dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.05k stars 4.03k forks source link

Intellisense override helper shows proper use of alias but the resulting code is missing it and invalid #42437

Open jnm2 opened 4 years ago

jnm2 commented 4 years ago

Version Used: VS 16.5-p5

With using CS = Microsoft.CodeAnalysis.CSharp.Syntax;, intellisense shows the correct syntax while offering to generate this overload:

image

When the intellisense entry is used, it produces invalid code instead of generating what was previously shown:

image

jinujoseph commented 4 years ago

cc @genlu

genlu commented 4 years ago

related to #39909, possibly a dup

jnm2 commented 4 years ago

Just to clarify, this is a case where intellisense should not alter the using directives or I'd have to fix it and it might be easier not to use the override completion helper.

genlu commented 4 years ago

This is caused by Code Generator doesn't take the context into account when generate/add new member, the completion item shows the correct alias because symbol display visitor support this when IsMinimizing is true. I think the proper fix would be adding an option to code generator to support "minimizing" as well. Thoughts @CyrusNajmabadi?

CyrusNajmabadi commented 4 years ago

I think the proper fix would be adding an option to code generator to support "minimizing" as well. Thoughts @CyrusNajmabadi?

It should already work this way. We'll need to debug through to find out why that isn't working.

genlu commented 4 years ago

@CyrusNajmabadi I assume you were trying to quote my comment above?

CyrusNajmabadi commented 4 years ago

@genlu Yes :) bad cliipboard copy/paste. :)