Reputation: 6542
Why doesn't Intellisense work if I do something like this.
It does work though if I explicitly declare Foo
Upvotes: 0
Views: 111
Reputation: 4983
The problem reproes. It is a problem with parsing incomplete code.
The line that you started (foo.
) gets parsed together with the local function on the line below. This causes the local function not to be parsed correctly, so VS doesn't know that GetFoo
is a local function any more or that it returns a Foo
.
Upvotes: 2
Reputation: 9704
This is likely a bug in visual studio. As a work around, you can get the intellisense to play nice in this situation by declaring GetFoo at the top of your function's scope.
void Test()
{
Foo GetFoo() => new Foo();
var foo = GetFoo();
foo.DoThing();
}
I observe the same behavior you have when placing the GetFoo
declaration below the point in which I'm trying to use it, so it would seem that order matters.
Upvotes: 1