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

FullyQualifyNamespace light bulb does not appear in certain contexts #20397

Closed
TanayParikh opened this issue Apr 1, 2020 · 7 comments
Closed
Assignees
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates bug This issue describes a behavior which is not expected - a bug. Done This issue has been fixed External This is an issue in a component not contained in this repository. It is open for tracking purposes.

Comments

@TanayParikh
Copy link
Contributor

This issue is a branch off of the work in #19449 however it addresses a seperate underlying issue highlighted by @ajaybhargavb (link).

Reproduce:

  1. dotnet new blazorserver
  2. Open Counter.razor
  3. In the IncrementCount() method add the following below the currentCount++; line: RenderTree.

Invoke the FullyQualifyNamespace light bulb
Expected:

    private void IncrementCount()
    {
        currentCount++;
        RenderTree // code action for Microsoft.AspNetCore.Components.RenderTree provided
    }

Actual:

    private void IncrementCount()
    {
        currentCount++;
        RenderTree // code action for Microsoft.AspNetCore.Components.RenderTree (erroneously) not provided
    }
@TanayParikh TanayParikh added bug This issue describes a behavior which is not expected - a bug. cost: S area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels Apr 1, 2020
@TanayParikh TanayParikh self-assigned this Apr 1, 2020
@TanayParikh
Copy link
Contributor Author

I've isolated this issue and have been able to reproduce it in a vanilla MVC project. Inspecting the omnisharp-vscode codebase, we don't seem to manipulate the context.diagnostics which contain the compiler errors.

https://github.com/OmniSharp/omnisharp-vscode/blob/master/src/features/codeActionProvider.ts#L29

This indicates dotnet/roslyn itself isn't providing the underlying CS0246 compiler error in certain situations. I've created an issue there with repro-repo and demo video.

dotnet/roslyn#42974

@TanayParikh TanayParikh added the External This is an issue in a component not contained in this repository. It is open for tracking purposes. label Apr 1, 2020
@TanayParikh
Copy link
Contributor Author

dotnet/roslyn#42974 (comment)

Given this, we can either keep the behavior as is, or remove the filtering we do for the code actions shown to the user:

https://github.com/dotnet/aspnetcore-tooling/blob/master/src/Razor/src/Microsoft.AspNetCore.Razor.VSCode/src/CodeActions/RazorFullyQualifiedCodeActionTranslator.ts#L29-L32

Are there any preferences for this? @ryanbrandenburg @NTaylorMullen @ajaybhargavb

@TanayParikh TanayParikh reopened this Apr 1, 2020
@NTaylorMullen
Copy link
Contributor

Are there any preferences for this? @ryanbrandenburg @NTaylorMullen @ajaybhargavb

Really thorough investigation, nice job Tanay! We need to keep the filtering as-is because we don't support every light bulb diagnostic. Given this is "by design" from Roslyn's perspective we want to treat it the same as well. I'd close this issue as by-design.

@ryanbrandenburg
Copy link
Contributor

Secret option number 3 might be to just add this new CS-code that we've verified to the list of allowable codes on that Translator. That way this scenario works as expected but we also aren't allowing untested CodeActions through.

@TanayParikh
Copy link
Contributor Author

TanayParikh commented Apr 2, 2020

@ryanbrandenburg we'd have to allow either:

CS0103 "The name 'RenderTree' does not exist in the current context [blazorserver]"
OR
CS1002 ; expected [blazorserver]"

in addition to the existing CS0246 missing namespace compiler error. In my opinion both CS0103, CS1002 may be a bit too general and we could end up with code actions in unanticipated situations. This is under the assumption the suggested code action also passes the secondary filtering logic for fully qualified namespace:

https://github.com/dotnet/aspnetcore-tooling/blob/master/src/Razor/src/Microsoft.AspNetCore.Razor.VSCode/src/CodeActions/RazorFullyQualifiedCodeActionTranslator.ts#L42-L51

I think it may be fine to leave our logic as is, to maintain feature parity with Roslyn if you're okay with that?

@ryanbrandenburg
Copy link
Contributor

Sounds totally reasonable, just wanted to give it as an options.

@TanayParikh
Copy link
Contributor Author

TanayParikh commented Apr 2, 2020

Thanks for the feedback! Closing out as "by design" in Roslyn dotnet/roslyn#42974 (comment).

@NTaylorMullen NTaylorMullen added the Done This issue has been fixed label Apr 7, 2020
@ghost ghost locked as resolved and limited conversation to collaborators May 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates bug This issue describes a behavior which is not expected - a bug. Done This issue has been fixed External This is an issue in a component not contained in this repository. It is open for tracking purposes.
Projects
None yet
Development

No branches or pull requests

3 participants