Table of Contents

AL0007: GetSchema should be explicitly implemented

Implement IXmlSerializable.GetSchema explicitly to avoid exposing it as part of the public API.

When it triggers

public class MySerializable : IXmlSerializable
{
    // AL0007: IXmlSerializable.GetSchema should be explicitly implemented
    public XmlSchema? GetSchema() => null;

    public void ReadXml(XmlReader reader) { }
    public void WriteXml(XmlWriter writer) { }
}

Why this matters

The GetSchema method is part of IXmlSerializable but should not be part of your type's public API. Making it explicit keeps your API clean and signals that this method exists only for interface compliance.

How to fix

Use explicit interface implementation:

public class MySerializable : IXmlSerializable
{
    XmlSchema? IXmlSerializable.GetSchema() => null;

    public void ReadXml(XmlReader reader) { }
    public void WriteXml(XmlWriter writer) { }
}

Configuration

[*.cs]
dotnet_diagnostic.AL0007.severity = warning