AL0009: Don't call IXmlSerializable.GetSchema
Calling GetSchema is not supported; it should always return null and isn't intended to be invoked.
When it triggers
IXmlSerializable serializable = GetSerializable();
// AL0009: Don't call IXmlSerializable.GetSchema
var schema = serializable.GetSchema();
Why this matters
The GetSchema method in IXmlSerializable is a historical artifact. It should always return null and isn't meant to be called. Schema information should be retrieved via XmlSchemaProviderAttribute instead.
How to fix
Remove the call and use proper schema discovery mechanisms:
// Use XmlSchemaProviderAttribute on your type for schema information
[XmlSchemaProvider("GetMySchema")]
public class MySerializable : IXmlSerializable
{
public static XmlQualifiedName GetMySchema(XmlSchemaSet schemas)
{
// Return schema information here
}
}
Configuration
[*.cs]
dotnet_diagnostic.AL0009.severity = warning