private ClassDeclarationSyntax GenerateFields(ConstructorDeclarationSyntax constructor, ClassDeclarationSyntax @class)
        {
            var variables = GetRelevantFields();

            var baseFields = @class.RemoveFields(variables).ToList();

            var fieldsOrdered = variables
                                .Select(c => syntaxGenerator.FieldDeclaration(c))
                                .Cast <MemberDeclarationSyntax>();

            baseFields.InsertRange(0, fieldsOrdered);
            @class = @class.WithMembers(new SyntaxList <MemberDeclarationSyntax>(baseFields));

            return(@class);

            IEnumerable <VariableDeclaratorSyntax> GetRelevantFields()
            {
                VariableDeclaratorSyntax[] result = new VariableDeclaratorSyntax[constructor.ParameterList.Parameters.Count];

                int index = 0;

                foreach (var param in constructor.ParameterList.Parameters)
                {
                    var item = @class.FindField(c => c.Identifier.ValueText == param.Identifier.ValueText);
                    if (item == null)
                    {
                        var declared = syntaxGenerator.FieldDeclaration(param.Identifier.ValueText, param.Type, Accessibility.Private, DeclarationModifiers.ReadOnly) as FieldDeclarationSyntax;
                        item = declared.Declaration.Variables.First(); //Only 1 variable inited with the field
                    }
                    result[index] = item;
                    index++;
                }
                return(result);
            }
        }