Book a Demo

Author Topic: Possible C# code generation bug with interface?  (Read 4778 times)

fluxtah

  • EA User
  • **
  • Posts: 144
  • Karma: +0/-0
    • View Profile
Possible C# code generation bug with interface?
« on: April 06, 2004, 10:37:39 am »
If I make an interface, add some operations to it, then make a class, then realize the interface from the class and implement the operations from the interface...

Now if I forward engineer the class and interface into c# code.

I look at the code and the implemented members do not have a visibility settings, ie there is no public or private before the operation name :(

Code: [Select]

int SomeOperation(){

}


OK, so I just add the visibility I want in front of my methods directly into the generated code:

Code: [Select]

public int SomeOperation(){

}


now... when I reverse engineer it back into my model, then again, I forward engineer it I get this again:

Code: [Select]

int SomeOperation(){

}


So the forward engineering appears to remove all the visibilty settings of operations from a realized interface :(

This get's annoying when dealing wtih 10+ classes that all realize this interface.

anyone know if I am doing somethign wrong?

regards

Ian

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: Possible C# code generation bug with interface
« Reply #1 on: April 06, 2004, 04:00:25 pm »
I have already submitted this as a bug.
But I haven't looked at whether it was fixed in 724.
B
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Possible C# code generation bug with interface
« Reply #2 on: April 06, 2004, 04:04:26 pm »
Hi fluxtah,

What build of EA are you using?  This was a bug, but I believe that it was fixed in build 724.

Just so you know, it was fixed entirely within the C# Operation Declaration template.  Also, support for a new tag for operations was added.  This tag is "ImplementsExplicit" and it needs to be set to "true" if you want to output the function as an Explicit Implementation of the Interface function.

Hope this helps.

Simon

fluxtah

  • EA User
  • **
  • Posts: 144
  • Karma: +0/-0
    • View Profile
Re: Possible C# code generation bug with interface
« Reply #3 on: April 07, 2004, 07:24:45 am »
Still no joy after update  :-[

I am probably doing something very stupidly wrong

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Possible C# code generation bug with interface
« Reply #4 on: April 07, 2004, 09:06:52 pm »
Have you overridden any of the default templates?  If you have then your templates will override the new default ones.  Here's some tips so you could update your own if you desire.

For this issue there are two parts of the C# Operation Declaration template that are involved.  The first part of the template determines what the visibility settings of the operation are.  It should look like this.

Code: [Select]
%if opTag:"Implements" == ""%
%CONVERT_SCOPE(opScope)%
%elseIf opTag:"ImplementsExplicit" != "true"%
public
%endIf%


What that essentially means is that if the operation is not implementing anything it will output the visibility settings (or scope).  If it is implementing something and that tag isn't true it will output "public".  If the tag is true then it won't output a scope at all.  As I understand the C# specs this is correct.

The next part of the template that concerns an interface is only the name of the function and whether to output the qualifier at the front of it.  That bit of code looks like this.

Code: [Select]
%if opTag:"Implements" != "" and opTag:"ImplementsExplicit" == "true"%
%opTag:"Implements"%
%else%
%opName%
%endIf%


Obviously only the first bit of template code there is relevant to your problem, but I like complete solutions.

Anyway, I hope I was of some help this time.

Simon

fluxtah

  • EA User
  • **
  • Posts: 144
  • Karma: +0/-0
    • View Profile
Re: Possible C# code generation bug with interface
« Reply #5 on: April 09, 2004, 12:38:26 pm »
Cheers Simon! I have played with the default templates but not since ea4.00

that worked a treat :D


regards

Ian