Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: MBreuer on May 06, 2014, 05:30:18 pm

Title: (Re)generate C# code for constructor with chaining
Post by: MBreuer on May 06, 2014, 05:30:18 pm
Hello,
I want to reorganise the parameters in a constructor which calls the constructor of ist base class. But when I generate ist code the already existing chaining code is gone. Is there a solution to avoid this ?

class before
    public B(int i, string s)
        : base(i,s)
    {
     }

class after Generation (call of base is missing)
    public B(string s, int i)
    {
     }

thank you
Title: Re: (Re)generate C# code for constructor with chai
Post by: webfox on May 06, 2014, 06:08:16 pm
Hi,

after modifying the underlying code, make sure you always sync your model with it before re-generating code. To do this in EA, select the class on the diagram and press CTRL + R. If you open the properties dialog of the class and select "Tagged Values" on the left, you should now see an "initializer" tag on the right, containing the string "base(i,s)" as value. Re-generating the code from the model now will preserve your existing constructor call chain.

Hope this helps.

Cheers,

Till