Skip to content

Object Initializer Intellisense Broken #119

@KevinRansom

Description

@KevinRansom

originally opened at CodePlex by tahir_cs

Hi All,

I was trying to use the F# object initialization syntax in a FSharp script file (*.fsx) like so:

 let fileTarget = new NLog.Targets.FileTarget( Name = "logger" ) 

but no suggestions come through. A workaround I ended up using was:

let fileTarget = 
    let ft = new NLog.Targets.FileTarget()
    ft.Name <- "logger"
    ft

But this is not as nice as having intellisense, where needed between the brackets.

comments
Mariuszz wrote Oct 31, 2014 at 3:55 PM [x]
yes, this is very irritating. Hope it will be fixed

dsyme wrote Nov 1, 2014 at 3:06 PM [x]
I think the specific request here is that "Name" be shown as a completion when pressing ctrl-space at positions like:

 let fileTarget = new NLog.Targets.FileTarget( $

 let fileTarget = new NLog.Targets.FileTarget( Na$

 let fileTarget = new NLog.Targets.FileTarget( $ )

 let fileTarget = new NLog.Targets.FileTarget( Na$ )

 let fileTarget = new NLog.Targets.FileTarget( Na$ = "logger" )

and all the same when the "new" is not present. I agree this is a major missing piece of functionality in intellisense and has an impact on how you end up writing code.

One problem is that there the intellisense list shown at the plain "$" positions above will still be long (all in-scope identifiers, namespaces etc.), since a lot of things can still be written at those locations. But still, some intellisense help would be appreciated.

dsyme wrote Nov 1, 2014 at 3:20 PM [x]
And also in multi-argument versions of the same.... e.g.

 let fileTarget = new NLog.Targets.FileTarget(foo, $

let fileTarget = new NLog.Targets.FileTarget(foo(), Na$

let fileTarget = new NLog.Targets.FileTarget(foo(), $ )

let fileTarget = new NLog.Targets.FileTarget(foo(), Na$ )

let fileTarget = new NLog.Targets.FileTarget(foo(), Na$ = "logger" )

>>but NOT on the rhs of the "=" here:
>>```fsharp
 let fileTarget = new NLog.Targets.FileTarget(Name = $
 let fileTarget = new NLog.Targets.FileTarget(Name = $ )
 let fileTarget = new NLog.Targets.FileTarget(Name = Buz$
 let fileTarget = new NLog.Targets.FileTarget(Name = Buz$ )
 let fileTarget = new NLog.Targets.FileTarget(foo(), Name = $ 
 let fileTarget = new NLog.Targets.FileTarget(foo(), Name = $ )
 let fileTarget = new NLog.Targets.FileTarget(foo(), Name = Buz$ 
 let fileTarget = new NLog.Targets.FileTarget(foo(), Name = Buz$ )

latkin wrote Nov 25, 2014 at 2:53 PM [x]
I agree this would be nice to fix.
There is a handy workaround (which might qualify as a bug itself...): type "." in the ctor call and an intellisense list pops up containing only members of the type being constructed. You have to go back and delete the . character later, but it's helpful from a UI perspective.

6iodwkv

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions