//-----------------------------------------------------------------------------------------------------------------------------------------------------

        public ImplementationClassWriter <TBase> Constructor(Action <ConstructorWriter> body)
        {
            var constructor = DefineConstructor(ConstructorMethodFactory.InstanceConstructor(OwnerClass, Type.EmptyTypes));
            var writer      = new ConstructorWriter(constructor, body);

            return(this);
        }
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        public ImplementationClassWriter <TBase> Constructor <TA1, TA2>(Action <ConstructorWriter, Argument <TA1>, Argument <TA2> > body)
        {
            var constructor = DefineConstructor(ConstructorMethodFactory.InstanceConstructor(OwnerClass, new[] { typeof(TA1), typeof(TA2) }));
            var writer      = new ConstructorWriter(constructor, w => body(w, w.Arg1 <TA1>(), w.Arg2 <TA2>()));

            return(this);
        }
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        private FieldMember[] DefinePrimaryConstructor(Func <MethodMember, AttributeWriter> attributes, params object[] argumentNameTypePairs)
        {
            if ((argumentNameTypePairs.Length % 2) != 0)
            {
                throw new ArgumentException("argumentNameTypePairs must be of even length");
            }

            var argumentNames = new string[argumentNameTypePairs.Length / 2];
            var fieldNames    = new string[argumentNameTypePairs.Length / 2];
            var fieldTypes    = new Type[argumentNameTypePairs.Length / 2];

            for (int i = 0; i < fieldNames.Length; i++)
            {
                var name = (string)argumentNameTypePairs[i * 2];

                argumentNames[i] = name.Substring(0, 1).ToLower() + name.Substring(1);
                fieldNames[i]    = "m_" + name;
                fieldTypes[i]    = (Type)argumentNameTypePairs[i * 2 + 1];
            }

            var constructorMember = new ConstructorMember(OwnerClass, ConstructorMethodFactory.InstanceConstructor(OwnerClass, fieldTypes, argumentNames));

            OwnerClass.AddMember(constructorMember);

            var fieldMembers      = fieldTypes.Select((type, index) => DefineField(fieldNames[index], type, isStatic: false)).ToArray();
            var constructorWriter = new PrimaryConstructorWriter(constructorMember, fieldMembers);

            constructorWriter.AddAttributes(attributes);

            return(fieldMembers);
        }
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        public ImplementationClassWriter <TBase> Constructor <TA1, TA2, TA3, TA4, TA5, TA6, TA7, TA8>(Action <ConstructorWriter, Argument <TA1>, Argument <TA2>, Argument <TA3>, Argument <TA4>, Argument <TA5>, Argument <TA6>, Argument <TA7>, Argument <TA8> > body)
        {
            var constructor = DefineConstructor(ConstructorMethodFactory.InstanceConstructor(OwnerClass, new[] { typeof(TA1), typeof(TA2), typeof(TA3), typeof(TA4), typeof(TA5), typeof(TA6), typeof(TA7), typeof(TA8) }));
            var writer      = new ConstructorWriter(constructor, w => body(w, w.Arg1 <TA1>(), w.Arg2 <TA2>(), w.Arg3 <TA3>(), w.Arg4 <TA4>(), w.Arg5 <TA5>(), w.Arg6 <TA6>(), w.Arg7 <TA7>(), w.Arg8 <TA8>()));

            return(this);
        }
        public ImplementationClassWriter <TBase> Constructor <TA1>(Func <MethodMember, AttributeWriter> attributes, Action <ConstructorWriter, Argument <TA1> > body)
        {
            var constructor = DefineConstructor(ConstructorMethodFactory.InstanceConstructor(OwnerClass, new[] { typeof(TA1) }));
            var writer      = new ConstructorWriter(constructor, w => body(w, w.Arg1 <TA1>()));

            writer.AddAttributes(attributes);
            return(this);
        }
        public ImplementationClassWriter <TBase> Constructor(Func <MethodMember, AttributeWriter> attributes, Action <ConstructorWriter> body)
        {
            var constructor = DefineConstructor(ConstructorMethodFactory.InstanceConstructor(OwnerClass, Type.EmptyTypes));
            var writer      = new ConstructorWriter(constructor, body);

            writer.AddAttributes(attributes);
            return(this);
        }
        public ImplementationClassWriter <TBase> Constructor <TA1, TA2, TA3, TA4, TA5, TA6>(Func <MethodMember, AttributeWriter> attributes, Action <ConstructorWriter, Argument <TA1>, Argument <TA2>, Argument <TA3>, Argument <TA4>, Argument <TA5>, Argument <TA6> > body)
        {
            var constructor = DefineConstructor(ConstructorMethodFactory.InstanceConstructor(OwnerClass, new[] { typeof(TA1), typeof(TA2), typeof(TA3), typeof(TA4), typeof(TA5), typeof(TA6) }));
            var writer      = new ConstructorWriter(constructor, w => body(w, w.Arg1 <TA1>(), w.Arg2 <TA2>(), w.Arg3 <TA3>(), w.Arg4 <TA4>(), w.Arg5 <TA5>(), w.Arg6 <TA6>()));

            writer.AddAttributes(attributes);
            return(this);
        }