[Mono-dev] [PATCH] C# 3.0 Feature: Automatic Properties

Scott Peterson lunchtimemama at gmail.com
Fri May 11 12:05:20 EDT 2007


On 5/11/07, Raja R Harinath <rharinath at novell.com> wrote:
>
> Hi,
>
> "Scott Peterson" <lunchtimemama at gmail.com> writes:
>
> > This patch implements the automatic properties feature of C# 3.0 as
> demoed by Anders Hejlsberg at Mix (http://int1.fp.sandpiper.net/
> > soma/applications/silverlight/v1/videos/DEV04.wmv at 12 minutes, 40
> seconds). Please vet!
>
> > +Field current_accessor_field;
> > +ToplevelBlock make_accessor_block (Expression type, bool get)
> > +{
> > +     if (current_accessor_field == null) {
> > +             current_accessor_field = new Field (current_container,
> implicit_value_parameter_type,
> > +                     Modifiers.PRIVATE, CompilerGeneratedClass.MakeName("CompilerGeneratedField"),
> > +                     null, Location.Null);
> > +             current_container.AddField (current_accessor_field);
> > +     }
>
> Very messy It's an unnecessary global, with wierd behaviour.  Why don't
> you move this to the rule itself, and make it a local.


Agreed. This whole patch is actually pretty terrible. I'm refactoring it
soon(ish).

> +     Parameter value = new Parameter (type, "value",
> Parameter.Modifier.NONE, null, Location.Null);
> > +     Parameters parameters = new Parameters (new Parameter [] { value
> });
> > +
> > +     ToplevelBlock block = new ToplevelBlock (current_block,
> parameters, Location.Null);
> > +     This t = new This (block, Location.Null);
> > +     MemberAccess ma = new MemberAccess (t,
> current_accessor_field.Name);
>
> The get accessor should not have any parameters.
>
> > +     if (get) {
> > +             Return r = new Return (ma, Location.Null);
> > +             block.AddStatement (r);
> > +     }
> > +     else {
>
> On a stylistic note, we prefer the } and the else to be on line:
>
>   } else {
>
> Preferably the only two forms of 'else' that we have in the code are:
>
>   else
>   } else {
>
> Use the second form even when one arm of the 'if' has multiple
> statements and the other has only a single statement.

- Hari
>



-- 
Scott.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070511/af13a875/attachment.html 


More information about the Mono-devel-list mailing list