Discussion:
Automatic Properties on 2.0
Brady Kelly
2008-03-28 12:18:03 UTC
Permalink
I thought these were merely syntactical sugar offered by the 3.5 compiler,
but would compile down to normal getters and setters that would work on the
2.0 framework. Yes, when I try and 'down-grade' a 3.5 project to 2.0, I get
compiler errors for automatic properties. Is this just something I have to
live with, or is there another way?


===================================
This list is hosted by DevelopMentor� http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Peter Ritchie
2008-03-28 12:11:59 UTC
Permalink
Yes, unfortunately it's something you have to live with. A .NET 2.0
project invokes the .NET 2.0 compiler so you don't get the language
additions in a .NET 2.0 project.

You can, however create a .NET 3.5 class library and use it from a .NET
2.0 project.

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Sebastien Lambla
2008-03-28 12:39:11 UTC
Permalink
I've used automatic properties happily from the 3.0 compiler to generate a
2.0 assembly and see no issue with that. Same goes with extension methods
(provided you add a fake attribute in your class).

Of course you need to *target* 2.0 using the msbuild and compiler shipping
in 3.5, otherwise it won't work.

--
SerialSeb
http://serialseb.blogspot.com


-----Original Message-----
From: Discussion of development on the .NET platform using any managed
language [mailto:DOTNET-***@DISCUSS.DEVELOP.COM] On Behalf Of Peter Ritchie
Sent: 28 March 2008 12:12
To: DOTNET-***@DISCUSS.DEVELOP.COM
Subject: Re: [DOTNET-CLR] Automatic Properties on 2.0

Yes, unfortunately it's something you have to live with. A .NET 2.0
project invokes the .NET 2.0 compiler so you don't get the language
additions in a .NET 2.0 project.

You can, however create a .NET 3.5 class library and use it from a .NET
2.0 project.

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

No virus found in this incoming message.
Checked by AVG.
Version: 7.5.519 / Virus Database: 269.22.1/1345 - Release Date: 26/03/2008
18:50


No virus found in this outgoing message.
Checked by AVG.
Version: 7.5.519 / Virus Database: 269.22.1/1345 - Release Date: 26/03/2008
18:50


===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Brady Kelly
2008-03-28 13:14:32 UTC
Permalink
Post by Sebastien Lambla
Of course you need to *target* 2.0 using the msbuild and compiler shipping
in 3.5, otherwise it won't work.
Cool, so it is possible, but needs some work and not just the lazy man's F6
build. Thanks.

===================================
This list is hosted by DevelopMentor� http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Per Bolmstedt
2008-03-28 12:13:40 UTC
Permalink
Yes, when I try and 'down-grade' a 3.5 project to 2.0, I get compiler error
Is your idea of "down-grading from 3.5 to 2.0" simply pasting the 3.5 code
into a 2.0 compiler? Why should that work?

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Brady Kelly
2008-03-28 13:12:22 UTC
Permalink
Post by Per Bolmstedt
Is your idea of "down-grading from 3.5 to 2.0" simply pasting the 3.5 code
into a 2.0 compiler? Why should that work?
I didn't know if targeting 2.0 specifically used the 2.0 compiler, or told
the
3.5 compiler to target 2.0. Where would I get such a silly idea as you
mention?

===================================
This list is hosted by DevelopMentor� http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Per Bolmstedt
2008-03-28 12:15:43 UTC
Permalink
On Fri, 28 Mar 2008 08:13:40 -0400, Per Bolmstedt
Post by Per Bolmstedt
Yes, when I try and 'down-grade' a 3.5 project to 2.0, I get compiler error
Is your idea of "down-grading from 3.5 to 2.0" simply pasting the 3.5 code
into a 2.0 compiler? Why should that work?
That should read 3.0 code, of course. Automatic properties are simply a C# 3
feature, aren't they?

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Brady Kelly
2008-03-28 13:25:44 UTC
Permalink
Post by Per Bolmstedt
That should read 3.0 code, of course. Automatic properties are simply a C# 3
feature, aren't they?
Yes, that is correct.

===================================
This list is hosted by DevelopMentor� http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Daniel Petersson
2008-03-28 13:26:22 UTC
Permalink
Brad; It is pretty obvious that the code for the 3.5 compiler won't compile in a 2.0 project!
(even if they used the same compiler in different modes) MS did slipp-up when they decided
on their current versioning scheme but I seems that you did a rather nasty slip yourself =)
--Daniel

________________________________________
From: Discussion of development on the .NET platform using any managed language [DOTNET-***@DISCUSS.DEVELOP.COM] On Behalf Of Brady Kelly [***@CHASESOFTWARE.CO.ZA]
Sent: Friday, March 28, 2008 1:18 PM
To: DOTNET-***@DISCUSS.DEVELOP.COM
Subject: [DOTNET-CLR] Automatic Properties on 2.0

I thought these were merely syntactical sugar offered by the 3.5 compiler,
but would compile down to normal getters and setters that would work on the
2.0 framework. Yes, when I try and 'down-grade' a 3.5 project to 2.0, I get
compiler errors for automatic properties. Is this just something I have to
live with, or is there another way?


===================================
This list is hosted by DevelopMentor? http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentor� http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Brady Kelly
2008-03-28 13:48:00 UTC
Permalink
Post by Daniel Petersson
Brad; It is pretty obvious that the code for the 3.5 compiler won't
compile in a 2.0 project!
(even if they used the same compiler in different modes) MS did slipp-
up when they decided
on their current versioning scheme but I seems that you did a rather nasty slip yourself =)
--Daniel
Not so nasty, the project is an ASP.NET prototype, and I got four data
capture pages, and two list/ grid pages for captured data, all working with
about five or six lines of code altogether. My client just didn't have 3.5
installed yet, so I quickly wanted to send him a 2.0 version. I made three
automatic properties public fields and, as they say, Voila!

===================================
This list is hosted by DevelopMentor� http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Shawn Wildermuth
2008-03-28 15:04:41 UTC
Permalink
Because its asp.net it isn't using the C# 3.0 compiler on the server but
pre-compiling the site might fix it.

Thanks,

Shawn Wildermuth
http://adoguy.com
http://wildermuthconsulting.com
http://geekdinners.com
Microsoft MVP (C#), MCSD.NET, Author and Speaker

The Silverlight Tour is coming to a city near you!

-----Original Message-----
From: Discussion of development on the .NET platform using any managed
language [mailto:DOTNET-***@DISCUSS.DEVELOP.COM] On Behalf Of Brady Kelly
Sent: Friday, March 28, 2008 9:48 AM
To: DOTNET-***@DISCUSS.DEVELOP.COM
Subject: Re: [DOTNET-CLR] Automatic Properties on 2.0
Post by Daniel Petersson
Brad; It is pretty obvious that the code for the 3.5 compiler won't
compile in a 2.0 project!
(even if they used the same compiler in different modes) MS did slipp-
up when they decided
on their current versioning scheme but I seems that you did a rather nasty slip yourself =)
--Daniel
Not so nasty, the project is an ASP.NET prototype, and I got four data
capture pages, and two list/ grid pages for captured data, all working with
about five or six lines of code altogether. My client just didn't have 3.5
installed yet, so I quickly wanted to send him a 2.0 version. I made three
automatic properties public fields and, as they say, Voila!

===================================
This list is hosted by DevelopMentor. http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentor� http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Eric Wild
2008-04-03 00:31:28 UTC
Permalink
Brad;
This will work.
1) With your site you need to make it a webApplication.
2) Make all of the references that are 3.5 and have them copied
locally. System.Core is one but there are others - you'll need to work on
that.
3) Pre-compile your site using the command line tool. I have the
command line at work so if you can't figure it out let me know, I'll get it.

The problem you're having is that ASP.NET compiles your site on the
first time the page is hit. It is trying to use the 2.0 compiler to compile
your 3.5 site. There is a section in your Web.Config that shows what
compiler to use. The 2.0 compiler doesn't work.
Pre-Compiling on your 3.5 machine and moving it to your server means
that when a page is hit for the first time, ASP.NET doesn't try to compile.
And your code will work fine with the locally copied 3.5 DLLs.
I have gotten this to work. I have a win 2000 machine, and it can't
run anything higher that .NET 2.0.
This also makes sense because when LINQ and others were in CTP, they
would send around builds that would run off of the 2.0 runtime.

Anyway I have some more notes on this at work, so if you are having issues
getting this to work let me know, and I'll get them out.

Good luck

Eric

-----Original Message-----
From: Discussion of development on the .NET platform using any managed
language [mailto:DOTNET-***@DISCUSS.DEVELOP.COM] On Behalf Of Brady Kelly
Sent: Friday, March 28, 2008 9:48 AM
To: DOTNET-***@DISCUSS.DEVELOP.COM
Subject: Re: Automatic Properties on 2.0
Post by Daniel Petersson
Brad; It is pretty obvious that the code for the 3.5 compiler won't
compile in a 2.0 project!
(even if they used the same compiler in different modes) MS did slipp-
up when they decided
on their current versioning scheme but I seems that you did a rather nasty slip yourself =)
--Daniel
Not so nasty, the project is an ASP.NET prototype, and I got four data
capture pages, and two list/ grid pages for captured data, all working with
about five or six lines of code altogether. My client just didn't have 3.5
installed yet, so I quickly wanted to send him a 2.0 version. I made three
automatic properties public fields and, as they say, Voila!

===================================
This list is hosted by DevelopMentor. http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentor� http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Loading...