C# 3.0 Automatic Properties
May 16, 2007
Yesterday I read two excellent posts about C# 3.0 automatic properties feature: ScottGu’s «New C# “Orcas” Language Features: Automatic Properties, Object Initializers, and Collection Initializers» and Bart De Smet’s «C# 3.0 Automatic Properties explained».
It was a pleasure to see that my old «A programming language pattern idea» hit straight to the point.
By the way, this “Orcas” feature is still missing the “container” concept, enabling an access to the auto-generated field from the constructor. Another missing point is a read-only automatic properties.
May 16, 2007 at 3:12 pm
Hear, hear. I second the “missing read-only automatic properties”. Especially with anonymous classes created with LINQ via projection, the option to create those properties as read-only would be so useful.
Maybe something like ‘new readonly { foo = “bar” };’
Creating a writable anonymous class via projection at best leaves the impression that setting those values means something. In reality it is very likely just a way to give you data to look at. It certainly doesn’t propagate the changes back to the originating object.
May 16, 2007 at 4:05 pm
I thought about making an anonymous classes derived from LINQ queries to be immutable.
But I see that there is nothing to complain about this: Sree just blogged that they decided to infer all anonymous classes as immutable.
May 16, 2007 at 8:36 pm
I did a first pass at implementing auto-properties in Mono: http://lists.ximian.com/pipermail/mono-devel-list/2007-May/023460.html
I’ll be redoing this patch soon(ish). Should be done by the end of the week.
May 17, 2007 at 7:00 am
Hi Scott!
Good to hear about it, especially since I somehow missed your post on this.
May 27, 2007 at 4:58 am
It’s in: http://groups.google.com/group/mono-svn-patches/browse_thread/thread/b103dbe0daa8532f/b148ce3221d099cb?lnk=gst&q=Scott+Peterson&rnum=1#b148ce3221d099cb
May 27, 2007 at 4:59 am
I mean, http://groups.google.com/group/mono-svn-patches/browse_thread/thread/288d3fddaca3c3d0/3dde563d5a948663?lnk=gst&q=Scott+Peterson&rnum=2#3dde563d5a948663