Archived

This forum has been archived. Please start a new discussion on GitHub.

strcuts and ["clr:property"]

kwaclaw
kwaclaw Oshawa, Canada
When the directive ["clr: property"] is used with structs, incorrect code is generated. Given this Slice definition:
["clr:property"]
struct Date {
  byte Day;
  byte Month;
  short Year;
};

The code generated for the struct constructor does not compile, returning the error "'this' object cannot be used before all of its fields are assigned to":
public Date(byte Day, byte Month, short Year)
{
    this.Day = Day;
    this.Month = Month;
    this.Year = Year;
}

The assigments should be made to the fields, not the properties.

Btw, is there a reason why private fields and method parameters in the C# code are capitalized? This is a very uncommon code style for C#.

Karl

Comments

  • kwaclaw wrote: »
    When the directive ["clr: property"] is used with structs, incorrect code is generated.

    Thanks for the bug report! I'll have a look at this.
    Btw, is there a reason why private fields and method parameters in the C# code are capitalized? This is a very uncommon code style for C#.

    They use whatever capitalization you use for the corresponding Slice identifier.

    Cheers,

    Michi.
  • I've posted a patch for this. Thanks for reporting the problem!

    Cheers,

    Michi.