Reputation: 410
I want to write code that creates an XSD based on a C# class.
I can't find information how to do this without using XSD.exe. Example class:
[XmlRoot("Sync")]
public class SyncFileSettings : ISyncSettings
{
public SyncFileSettings(int pingIntervalSec, bool useCompression)
{
PingIntervalSec = pingIntervalSec;
UseCompression = useCompression;
}
public int PingIntervalSec { get; set; }
public bool UseCompression { get; private set; }
}
Upvotes: 1
Views: 2487
Reputation: 21
old thread, I know.
but now in the end of 2020 it was still hard for me to find a solution. I did, but it tooks a lot of time after I first found this thread. So - for all the guys finding just 'use XSD-tool' - there is a class XsdDataContractExporter in .net 5.0 now (System.Runtime.Serialization)
easy going, see microsoft XsdDataContractExporter Class. works fine!
happy coding :-)
Upvotes: 2
Reputation: 151730
how to generate xsd from class in code
without XSD.exe?
Why? Then you'll have to reinvent the wheel, or use a library.
Upvotes: 3