C# Autocomplete: Lambda embedded Anonymous Types

SyntaxEditor for WPF Forum

Posted 12 years ago by Jack Nicholson
Version: 12.1.0561
Avatar

Hi,

C# Autocomplete doesn't work on this code:

var a = Enumerable.Range(0,10)
.Select(i=>new{
Number=i});

a.Last().

Comments (4)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Jack,

Thanks for the note.  At the moment, our resolver doesn't know how to determine a lambda's return type and use it in the calling Select method's return type when executed in this sort of context.  We've marked it down to look into in the future.


Actipro Software Support

Posted 12 years ago by Jack Nicholson
Avatar

OK well.  Visual Studio quality contexts for autocomplete is very important for my project.  So I will check back to your blog regularly and if you have this ready in a reasonable amount of time, I will purchase the appropriate licenses.  Thanks.

Posted 12 years ago by Jack Nicholson
Avatar

Is it possible to do a hacking type solution in code where I could modify the list of the CompletionItems (or modify resolver) by looking at the AST?

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Jack,

While you can override methods on CSharpCompletionProvider like OnSessionOpening (which you can use to filter/change what will show in the completion list), that only fires if the provider determines it has something to show.  The problem here is that the resolver needs to be returning results for this scenario.  You also could override CSharpCompletionProvider.CreateContext and make sure the IDotNetContext.Resolve method returns appropriate items.  But still, anything dealing with lambdas is extremely complex so there probably aren't any quick fixes for this on your end since it deals with lambdas, method overloads, resolving nested generic type parameters, etc.


Actipro Software Support

The latest build of this product (v24.1.2) was released 2 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.