Saturday, December 08, 2007

Automatic Properties of c# and problems with Intellisense

Just did a little program to try out the new Automatic Properties of c# as seen on ScottGu’s Blog

It compiles with no errors and runs ok, but in design time I get a lot of errors saying:

“Accessor in non-abstract and non-extern property must declare a body” after the get; and set;

And some “unexpected token” on the new Person …

I’m using Visual Studio 2008 RTM.

Sample console app:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

Person person = new Person { FirstName = "Scott", LastName = "Guthrie", Age = 32 };

}

}

public class Person

{

public string FirstName { get; set; }

public string LastName { get; set; }

public int Age { get; set; }

}

}

Also there is no intellisense as it was supposed to …

Any ideas why it’s not working as it is supposed ?

I'm using Resharper 3.0.2 .. .but with intellisense disabled ... mybe the problem is from this mix...

1 comment:

Tiago Andrade e Silva said...

I Posted about this on the MSDN c# forum for Visual Studio 2008 and I got my answers there :)

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2541880&SiteID=1&mode=1

Also here:

http://grabbagoft.blogspot.com/2007/11/resharper-in-vs-2008.html

Hope this helps anybody that has the same problem!