Author Topic: C# Struct implementing interfaces  (Read 3916 times)

kossmann

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
C# Struct implementing interfaces
« on: March 09, 2004, 01:05:46 pm »
I forward engineer from EA structs (struct stereotype as opposed to a class). My structs have attributes, and also implement one or more interfaces.

When I reverse engineer a struct such as

internal struct MyStruct : ICompare
{
     internal int i1;
     internal int i2;

     int CompareTo(object obj){
           return i1 - ((MyStruct)obj).i1;
     }
}

it works fine, but then when I forward engineer that again, the Interface being implemented disappears, ie. the forward engineering produces:

internal struct MyStruct
{
     internal int i1;
     internal int i2;

     int CompareTo(object obj){
           return i1 - ((MyStruct)obj).i1;
     }
}


Any ideas?

Rainer

benc

  • EA Administrator
  • EA User
  • *****
  • Posts: 200
  • Karma: +0/-0
    • View Profile
Re: C# Struct implementing interfaces
« Reply #1 on: March 10, 2004, 10:32:42 pm »
Hi Rainer,

Thanks for the note.

This is caused by an error in one of the the C# code generation templates.

We will fix this for release of EA 4.0.

As a short term work around, you can override the default C# "ClassInherits" code template for the struct stereotype:

1. Open the Code Template Editor (Ctrl+Shift+P)
2. Select C# as the language
3. Select the ClassInherits template
4. Select the struct stereotype override
5. Replace the line :

$interfaces=%list="ClassInterfaces" @separator=", "%

with

$interfaces=%list="ClassInterface" @separator=", "%
6. Click save

Next time you generate the interface should appear.

I hope this helps.

Regards,
Ben

kossmann

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: C# Struct implementing interfaces
« Reply #2 on: March 11, 2004, 07:15:15 am »
Thanks, Ben. That did the trick.

Rainer