Book a Demo

Author Topic: Import C# - unexpected result  (Read 5020 times)

Viking

  • EA User
  • **
  • Posts: 478
  • Karma: +2/-2
    • View Profile
Import C# - unexpected result
« on: November 20, 2018, 12:47:13 am »
Hi experts,

I imported C#-code into EA with Code Y Source Code > Import Code.

I expected the importer to create attributes with getters and setters or at least public attributes.

Instead it created operations, one for each line (1). Furthermore the class was stereotyped with "property" (2).

Is that behavior ((1) and (2)) correct?

Many thanks in advance, V.

public class Security
    {
        public string description { get; set; }
        public string id { get; set; }
        public string name { get; set; }
        public string self { get; set; }
    }

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Import C# - unexpected result
« Reply #1 on: November 20, 2018, 01:01:55 am »
IIRC that's the way EA is handling getters/setters. Different languages use different syntax for that. Open the Property Attribute for an attribute to see the different switches.

q.

Viking

  • EA User
  • **
  • Posts: 478
  • Karma: +2/-2
    • View Profile
Re: Import C# - unexpected result
« Reply #2 on: November 20, 2018, 02:59:54 am »
Thank you, q.

Open the Property Attribute for an attribute to see the different switches.

I am sorry. I do not understand what you mean. There are no attributes, only operations. That's why I am asking.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Import C# - unexpected result
« Reply #3 on: November 20, 2018, 03:04:55 am »
In that case I probably misunderstood your issue.

q.

Viking

  • EA User
  • **
  • Posts: 478
  • Karma: +2/-2
    • View Profile
Re: Import C# - unexpected result
« Reply #4 on: November 20, 2018, 03:42:10 am »
My expectations are:

I expected the EA importer to create:
- (private) attributes and
- getters (which are operations) and
- setters (which are operations)

If without setters and getters then I would expect that the EA importer creates public attributes (so setters and getters are not needed).

The reality (what the EA importer produces) is:

Instead the EA importer created operations, one for each line. Furthermore the class was stereotyped with "property". So there are NO attributes.
« Last Edit: November 20, 2018, 05:00:31 am by Viking »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Import C# - unexpected result
« Reply #5 on: November 20, 2018, 05:30:27 am »
Well, to be honest, your code doesn't contain any attributes either. :-X

So it fact it seems that the result in EA is an exact representation of your code, including the fact that you choose to make your attributes implicit.
I guess this is the way EA distinguishes implicit from explicit attributes.

Geert

Viking

  • EA User
  • **
  • Posts: 478
  • Karma: +2/-2
    • View Profile
Re: Import C# - unexpected result
« Reply #6 on: November 20, 2018, 10:20:31 pm »
Well, to be honest, your code doesn't contain any attributes either. :-X

So it fact it seems that the result in EA is an exact representation of your code, including the fact that you choose to make your attributes implicit.
I guess this is the way EA distinguishes implicit from explicit attributes.

Geert

My code describes "Auto-Implemented Properties" / "Automatic Properties". My understanding is that this class uses attributes. And I doubt that getters and setter make sense without attributes (at least most often).



Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Import C# - unexpected result
« Reply #7 on: November 20, 2018, 10:45:24 pm »
I'm guessing EA has to do it this way to be able to generate the same code if you would do forward engineering.

It is in fact the most literal translation of the code I can think of.

Geert