Home Bug Reports

strcuts and ["clr:property"]

kwaclawkwaclaw Oshawa, CanadaMember Karl WaclawekOrganization: Personal
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

  • michimichi Member Michi HenningOrganization: Triodia TechnologiesProject: I have a passing interest in Ice :-) ✭✭✭
    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.
  • michimichi Member Michi HenningOrganization: Triodia TechnologiesProject: I have a passing interest in Ice :-) ✭✭✭
    I've posted a patch for this. Thanks for reporting the problem!

    Cheers,

    Michi.
Sign In or Register to comment.