views:

432

answers:

3

When I am working in .NET 2.0 projects with the newest version of ReSharper (4.1) I am getting warnings about using the var keyword and lambadas etc.. Any idea how I can disable this only for .NET 2.0 projects?

+2  A: 

You can actually use var in 2.0 projects. It's syntactical sugar and the compiler works with it. Check out this for more info.

http://weblogs.asp.net/shahar/archive/2008/01/23/use-c-3-features-from-c-2-and-net-2-0-code.aspx

dbugger
Greg
Good question. Don't have 2005 on this box. Will try it out at the office on Monday.
dbugger
VS 2005 doesn't know what to do with it.
dbugger
+4  A: 

Indeed, you can use C# 3.0 compiler features when targeting .NET 2.0, except extension methods and default LINQ implementations, which are located in newer assemblies. But if you need to co-operate with VS2005 users, you can open Properties view for a given project (not Project Properties, but Edit \ Properties Window, or F4) and select desired language level.

Ilya Ryzhenkov
This works for class libraries and I am assuming applications, but I don't see this same option for my ASP.NET website.
Greg
+1  A: 

Daniel Moth has a great blog post on how to using C# 3.0 features (including extension methods) in .Net 2.0.

After rereading the question, this really doesn't help. You can turn off specific inspections via the R# Options window. I don't know of a way to switch back and forth between 2.0 and 3.5 project settings without manually changing them :S.

Mark