public static void WriteValidator(this IndentedTextWriter writer, Validator validator)
    {
        if (!validator.Version.HasValue && !validator.Arguments.Any())
        {
            writer.Write(validator.Name);
            writer.Write(".Instance");
        }
        else
        {
            writer.Write("new ");
            writer.Write(validator.Name);
            writer.Write("(");

            var hasInitialization = false;

            foreach (var arg in validator.Arguments)
            {
                if (arg.Name is null)
                {
                    writer.WriteArgument(arg);
                }
                else
                {
                    hasInitialization = true;
                }
            }

            writer.Write(")");

            if (hasInitialization || validator.Version.HasValue)
            {
                writer.Write(" { ");

                var written = false;

                foreach (var arg in validator.Arguments)
                {
                    if (arg.Name is not null)
                    {
                        if (written)
                        {
                            writer.Write(", ");
                        }

                        writer.Write(arg.Name);
                        writer.Write(" = ");
                        writer.Write("(");
                        writer.WriteArgument(arg);
                        writer.Write(")");
                        written = true;
                    }
                }

                if (validator.Version.HasValue)
                {
                    if (written)
                    {
                        writer.Write(", ");
                    }

                    writer.Write(validator.IsInitialVersion ? "InitialVersion" : "Version");
                    writer.Write(" = (FileFormatVersions.");
                    writer.Write(validator.Version.Value);
                    writer.Write(")");
                }

                writer.Write(" }");
            }
        }
    }