Book a Demo

Author Topic: Code engineering and C# enum classes  (Read 4589 times)

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Code engineering and C# enum classes
« on: September 09, 2015, 04:23:26 pm »
Hi,

I generated the code for enumeration classes in C# from EA and I get the following:
Code: [Select]
public enum myEnum : int {
LITERAL1,
LITERAL2
}

I don't need this "int" type and unfortunately I cannot figure out from the Code templates nor from the C# class in EA how to remove it.

Any idea?
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Code engineering and C# enum classes
« Reply #1 on: September 09, 2015, 05:04:02 pm »
Have you removed the type from the literal values (attributes)?

Since v12 EA sets it to int, which is kind of a bug in my opinion. Literal values shouldn't have a type.

Geert

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: Code engineering and C# enum classes
« Reply #2 on: September 09, 2015, 05:27:13 pm »
Hi Geert,

The attributes have been created without any type. They only have a name and the enum stereotype.
So it could be an EA 12 bug by the sound of it.

Guillaume
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


philchudley

  • EA User
  • **
  • Posts: 750
  • Karma: +22/-0
  • EA Consultant / Trainer - Sparx Europe
    • View Profile
Re: Code engineering and C# enum classes
« Reply #3 on: September 09, 2015, 06:11:40 pm »
Hi

The problem is with the enumeration override for the macro ClassDeclaration, specifically the last line of code:

Code: [Select]
%classTag:"enumType" ? ": " value : ": int"%

It appears this always evaluates to false

Either remove this line or simply comment it out as follows

Code: [Select]
$COMMENT=%classTag:"enumType" ? ": " value : ": int"%

Now should be all OK

Cheers
Models are great!
Correct models are even greater!

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: Code engineering and C# enum classes
« Reply #4 on: September 09, 2015, 07:23:51 pm »
It worked !  :)
Due to my screen's resolution, I couldn't see and forgot about the stereotype overrides list underneath the Class Declaration template where enumeration is available.

Thanks Phil.
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com