ionide / ionide-vscode-fsharp

VS Code plugin for F# development
http://ionide.io
MIT License
856 stars 277 forks source link

Automatic open namespace feature generates incorrect code when the fully qualified prefix is a [type/static class] #1570

Open OkayX6 opened 3 years ago

OkayX6 commented 3 years ago

Describe the bug

Since recently, we can now open static classes just like namespaces/modules, like in C# (open type System.Console for using static System.Console).

In my example, Ionide generates an incorrect auto-open directive, it forgets the type keyword, and writes open Feliz.Html.

Steps to reproduce

image

Expected behaviour

It should writes: open type Feliz.Html

Screenshots

As you can see below:

image

Machine info

open-collective-bot[bot] commented 3 years ago

Hey @OkayX6 :wave:,

Thank you for opening an issue. We will get back to you as soon as we can. Also, check out our OpenCollective and consider backing us.

https://opencollective.com/ionide

PS.: We offer backer support for all backers. Don't forget to add backer label when you start backing us :smile:

baronfel commented 3 years ago

Thanks for the report. The fix for this one will be somewhere in FsAutoComplete, either in the CodeFix that provides these options or in the core logic that generates the suggestions, my leaning is towards the latter. This code probably needs to look at the kind of the entity here and suggest open type if the entity is a class-type.