Book a Demo

Author Topic: C# code generation  (Read 3953 times)

tomp

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
C# code generation
« on: April 23, 2007, 01:16:35 am »
I am having a couple of issues with the import and generation of c# code.

1.
I have a simple method with a return type of int. I have reverse engineered this class into EA and it shows a return type of int. However, when generated this return type is missing. This seems to be a random error as creating a copy of the class and re running the steps results in the correct export. However I cannot seem to force the original to export the return type even when deleted and recreated in EA.

2.
I have the need to create public properties which have a public get and an internal set. This does not seem to be supported in EA.
(I.e.)

   public int Test1
       {
           get
           {
               return mTest1;
           }
           internal set
           {
               mTest1 = value;
           }
       }

The second issue is clearly more important as the first has a work around (re-create/copy the class) and I hope to generate code from EA rather than reverse enginner anyway. The first issue current precludes this and reverse engineering since this information is lost (in fact the entire set seems to dissapear)

Tom
« Last Edit: April 23, 2007, 01:30:31 am by tomp »

tomp

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: C# code generation
« Reply #1 on: April 23, 2007, 01:41:42 am »
I have just discovered that the property can also be generated from the attribute when creating it in EA which would appear to allow for the get and set scope to be set individually. However I can only seem to set the Get scope despite choosing checking both the read and write options. It would appear that this setting is language dependent and the choice of c# sharp is restricting it.
« Last Edit: April 23, 2007, 01:42:52 am by tomp »

tomp

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: C# code generation
« Reply #2 on: April 24, 2007, 05:31:30 am »
bump...

If anyone can help or confirm point 2 is unsupported.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: C# code generation
« Reply #3 on: April 30, 2007, 01:13:21 pm »
1. I haven't seen anything like this happen.  Could you please post the original method declaration so that I can try repeat the error?

2. You are correct, this is unsupported.  Only one selection in the property dialog is used for .Net properties and that is for the scope of the overall property.  EA doesn't explicitly model the accessors contained in the property and therefore doesn't have any fields to specify aspects of it.

The easiest thing to do is generate the code and then add the "internal".  When synchronizing it won't change it.  If you want it generated from EA itself then you can put the relevant get/set accessors into the initial code field of the method.

tomp

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: C# code generation
« Reply #4 on: April 30, 2007, 11:27:47 pm »
Sorry, but I do not have the method that caused the problem anymore (I was using a scratch model to try some things out that has since been deleted) although I csan tell you it was the last method in a class with several methods and properties on it and was created in the maner detailed in my first post. It was supposed to return an int and had took a couple of parameters.  I have not encountered this since, but as far as I could tell the model had the information as described and it simply would not generate it. If it happens again I will re-post.

On point 2, is this likely to be supported in the near future? We were hoping that the model would be sufficient to allow others to view the interfaces provided by various packages. Since these are all wrapped in dlls then the distinction between a public get and internal set is quite important and although I can add to the initial code field this is not as elegant as being able to read the information from a class diagram.