private static void WriteType(this IndentedTextWriter writer, OpenXmlGeneratorServices services, SchemaType element)
    {
        writer.WriteDocumentationComment(BuildTypeComments(services, element));
        writer.WriteSchemaAttribute(element.Name.QName);
        writer.Write("public ");

        if (element.IsAbstract)
        {
            writer.Write("abstract ");
        }

        var className = services.FindClassName(element.Name, fullyQualified: false);

        writer.Write("partial class ");
        writer.Write(className);
        writer.Write(" : ");
        writer.WriteLine(element.IsPart ? "OpenXmlPartRootElement" : element.BaseClass);

        using (writer.AddBlock(new() { AddNewLineBeforeClosing = true, IncludeTrailingNewline = false }))
        {
            var delimiter = writer.TrackDelimiter(separator: string.Empty, newLineCount: 2);

            delimiter.AddDelimiter();
            writer.WriteDocumentationComment($"Initializes a new instance of the {className} class.");
            writer.Write(element.GetAccessibility());
            writer.Write(" ");
            writer.Write(className);
            writer.WriteLine("() : base()");

            using (writer.AddBlock(new() { IncludeTrailingNewline = false }))
            {
            }

            writer.WriteConstructors(services, element, ref delimiter);

            foreach (var attribute in element.Attributes)
            {
                delimiter.AddDelimiter();
                writer.WriteAttributeProperty(services, attribute);
            }

            delimiter.AddDelimiter();
            writer.WriteMetadata(services, element);

            if (!(element.IsDerived || element.CompositeType == ParticleOrderType.Other))
            {
                foreach (var node in element.Children)
                {
                    writer.WriteElement(services, element, node, ref delimiter);
                }
            }

            if (!element.IsAbstract)
            {
                delimiter.AddDelimiter();
                writer.WriteInheritDoc();
                writer.Write("public override OpenXmlElement CloneNode(bool deep) => CloneImp<");
                writer.Write(className);
                writer.Write(">(deep);");
            }

            if (element.IsPart)
            {
                writer.GetPartLoadMethods(element, className, ref delimiter);
            }
        }