Disabling C# 3.0 code analysis on .NET 2.0 projects?

Is it possible to have Resharper not check C# 3.0 conventions on .NET 2.0 projects? All my 2.0 projects are littered with squigglies for using the var keyword etc. I do also have .NET 3.5 projects as well so I would like to keep the analysis available.

Thanks.

11 comments

Hello,

Select your project in solution explorer, and change the language level in properties window to C# 2.0.
Also note that C# 3.0 is binary compatible with .NET 2.0, the new constructs are compiled to the same MSIL 2, so you can use C# 3.0 that are targetting .NET 2.0 without problem.

A small table:
MSIL 1.0: C# 1.0, .NET 1.0
MSIL 1.1: C# 1.1, .NET 1.1
MSIL 2.0: C# 2.0, C# 3.0, .NET 2.0, .NET 3.0, .NET 3.5

So any C# 2.0 or 3.0 is binary compatible with .NET 2.0, no problem will occur long as long as you don't use new features of the framework 3.0 or 3.5.

PS: blame the guy who decided to rename the WinFX extensions (WPF, WCF, etc) as ".NET 3.0" when they were just an addition - a noticeable one, I agree - to framework 2.0. The versions are so messed up now.

--
Julien

0

I still don't seem to be able to get this to work and am getting suggestions to use the var keyword, sorry for my late response.

Thanks.

0

Did you find where to change that selection in the project properties?

I think you might also need to reload the solution once you've changed that option.

0

All my apps are written for 2.0 only. The web server I host on and the customers who use our window applications only have the 2.0 .NET Framework available to them. Am I still missing something? I am still getting warnings about Auto-Properties and the var keyword.

Thanks.

0

I have found the proper location now, but I cannot find the same for my ASP.NET websites.. any ideas?

Thanks.

0

I have double-checked what you told: The "Target framework" must be set to ".NET Framework 2.0" - which of course is already set.

Still, I get the wrong suggestions, see this image.

Question: Any hints on what to do?

Thanks
Uwe

0

You need to change the "Language Level" property, which is not on the big project properties page - it's on the little properties window which normally shows stuff like control properties on the form editor.

Having two completely different things called 'properties' in VS was not a helpful design decision by MS!

Will

0

This option does not appear on Website Projects. Is there an alternative?

0

Hello Julien,

Do you mean that if I develop a class library targeting .NET 2.0 I can accept the ReSharper suggestions about the auto-properties and the implicit var declaration?

On the machine where the assembly will be used there is only .NET 2.0 installed, not .NET 3.0. Is it OK?
Thanks

0

Hello,

Do you mean that if I develop a class library targeting .NET 2.0 I can
accept the ReSharper suggestions about the auto-properties and the
implicit var declaration?


Yes.

On the machine where the assembly will be used there is only .NET 2.0
installed, not .NET 3.0. Is it OK?


Yes. Especially that new language features are coming with .NET 3.5 not 3.0.

That's how R# itself goes about its codebase and target env requirements.


Serge Baltic
JetBrains, Inc — http://www.jetbrains.com
“Develop with pleasure!”


0

Hello,

... OK unless you're doing Web dev, that is. It would run csc on site and
it must be the new one (netfx 3.5) for the features to work.


Serge Baltic
JetBrains, Inc — http://www.jetbrains.com
“Develop with pleasure!”




0

Please sign in to leave a comment.