Пройдя немного дальше, чем ответ s7orm, я написал эту простую функцию, которую я извлек из отражения в xsd.exe:
private void ExtractXsdFromType(Type type, FileInfo xsd)
{
XmlReflectionImporter importer = new XmlReflectionImporter();
XmlTypeMapping mapping = importer.ImportTypeMapping(type);
XmlSchemas xmlSchemas = new XmlSchemas();
XmlSchemaExporter xmlSchemaExporter = new XmlSchemaExporter(xmlSchemas);
using (FileStream fs = xsd.Create())
{
xmlSchemaExporter.ExportTypeMapping(mapping);
xmlSchemas[0].Write(fs);
}
}