Testura/Testura.Code

Ability to generate constructor chaining

Closed this issue · 2 comments

Hello,

How can we have constructor chaining? something like -

public ValidLocationRule(PlateFact plateLocationFact) : base(plateLocationFact)
        {
            _plateLocationFact = plateLocationFact;
        }

Hey! We don't support that right now but I can add it later today and upload a new version.

I have added this in the new version, you simply add a ConstructorInitializer object when creating your constructor. Like this:

ConstructorGenerator.Create("MyClass", BodyGenerator.Create(), constructorInitializer: new ConstructorInitializer(ConstructorInitializerTypes.Base, new List<Argument> { new ValueArgument("myText")})))

Which will give you:

"MyClass():base("myText"){}"