Home Dashboard Directory Help

Autocomplete on "new {" is interpreted as a new function instead of anonymous class by Rei Miyasaka


 as By Design Help for as By Design

Sign in
to vote
Type: Bug
ID: 584429
Opened: 8/7/2010 7:14:59 PM
Access Restriction: Public
User(s) can reproduce this bug


In ASP.NET MVC 2's C# aspx editor, typing "new {" causes it to become "new object {" -- which is surely not what anyone would want.

Or, typing

"asdf".Select(new {


"asdf".Select(new Func<char,TResult> {

I think it's interpreting it as a new delegate, but if that's the case, it should only respond to "new (", not "new {".

Very minor issue, but would be nice if it's fixed sometime.
Sign in to post a comment.
Posted by Microsoft on 8/16/2010 at 2:34 PM
Hi reinux,

Using method syntax for LINQ, we expect a lambda function here. As such, creating an anonymous type in this context isn't valid. Instead, intellisense is trying to help you complete out to the one thing that would be valid to instantiate in that location. I believe what you are looking for is this:

names.Select(result => { return new { name = result.Name }; });

Otherwise, you can force intellisense to be less aggressive about its completion, by pressing ctrl+alt+space while the list is up. This will place it in suggestion mode and means you will have to press tab to complete.

Chris Granger
Program Manager | Visual Studio Pro Experience
Posted by Microsoft on 8/8/2010 at 8:37 PM
Thank you for reporting the issue.
We are routing this issue to the appropriate group within the Visual Studio Product Team for triage and resolution.These specialized experts will follow-up with your issue.
Posted by Microsoft on 8/8/2010 at 4:03 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.