[745] Use implicitly typed local variable and auto-properties with NET 2.0

I'm using build num 745.
I'm using VS2008 to build a .NET 2.0 application, but R# suggests me to change all local variable declarations to "Implicitly typed" ones: the "var" ones.

I think that this confuses the user since with .NET 2.0 applications it's not possible to use C# 3.0 constructs.

The same happens with properties with "simple" getters/setters like:
public string Nome
{
get { return _nome; }
set { _nome = value; }
}

R# suggests me to convert it to auto-properties.
This should not happen as well.

I know I can configure R# not to display the hint or suggestion, but I want it to appear on .NET 3.5 projects and not in NET 2.0/3.0 ones.
Simo

3 comments
Comment actions Permalink

It actually is possible to use these C# 3.0 constructs in VS2008, even for
.NET 2.0 applications. The reason is that regardless of the framework
version that you are targeting, you are still using the C# 3.0 compiler.
Only in VS2005 would these constructs be unavailable. The new language
features do not affect the CLR runtime--they are handled at compile time.

Regards,
Mike

"Simone" <no_replay@jetbrains.com> wrote in message
news:15463872.1204819458782.JavaMail.itn@is.intellij.net...

I'm using build num 745.
I'm using VS2008 to build a .NET 2.0 application, but R# suggests me to
change all local variable declarations to "Implicitly typed" ones: the
"var" ones.

>

I think that this confuses the user since with .NET 2.0 applications it's
not possible to use C# 3.0 constructs.

>

The same happens with properties with "simple" getters/setters like:
public string Nome
{
get { return _nome; }
set { _nome = value; }
}

>

R

  1. suggests me to convert it to auto-properties.



0
Comment actions Permalink

Hello Simone,

By targeting .NET Framework 2.0 you just forces assemblies to be used, not
compiler. Compiler is still C# 3.0 and vars are allowed. You CAN use vars
and they WILL work on machine with just .NET 2.0 installed.

If you want to enforce C# 2.0 for the project, select project in solution
explorer, open Properties toolwindow (F4), not project properties window,
and change Language Level.

Sincerely,
Ilya Ryzhenkov

JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


S> I'm using build num 745.
S> I'm using VS2008 to build a .NET 2.0 application, but R# suggests me
S> to change all local variable declarations to "Implicitly typed" ones:
S> the "var" ones.
S> I think that this confuses the user since with .NET 2.0 applications
S> it's not possible to use C# 3.0 constructs.
S>
S> The same happens with properties with "simple" getters/setters like:
S> public string Nome
S> {
S> get { return _nome; }
S> set { _nome = value; }
S> }
S> R# suggests me to convert it to auto-properties.
S>


0
Comment actions Permalink

Yep, you are right, C#3 is only at compile time... silly question, pardon

0

Please sign in to leave a comment.