The following rules have a similar purpose: do not use IXmlSerializable.GetSchema(). This method is reserved and should not be used. When implementing the IXmlSerializable
interface, you should return null from this method, and instead, if specifying a custom schema is required, apply the XmlSchemaProviderAttribute
to the class.
IXmlSerializable.GetSchema() must be implemented explicitly.
IXmlSerializable.GetSchema() must return null, and must not be abstract or throw exceptions.
IXmlSerializable.GetSchema() should never be called.
public class Class1 : IXmlSerializable {
public XmlSchema? GetSchema() => new();
public void ReadXml(XmlReader reader) => throw new NotImplementedException();
public void WriteXml(XmlWriter writer) => throw new NotImplementedException();
public XmlSchema? Test() => GetSchema();
}
public class Class1 : IXmlSerializable {
XmlSchema? IXmlSerializable.GetSchema() => null;
public void ReadXml(XmlReader reader) => throw new NotImplementedException();
public void WriteXml(XmlWriter writer) => throw new NotImplementedException();
}