Generate classes without DataAnnotations
Is it possible to generate C# classes without the DataAnnotations?
I'm using the generated classes inside Unity and I got an error:
Assets\Scripts\Integrations\OpenDrive\XsdSchemas\out\Integrations.OpenDRIVE.cs(4987,48): error CS1069: The type name 'RequiredAttributeAttribute' could not be found in the namespace 'System.ComponentModel.DataAnnotations'. This type has been forwarded to assembly 'System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Consider adding a reference to that assembly.
and I can't add that reference to the project (I won't be even using those features).
Thank you :)
This is currently not possible. What does the generated code look like? RequiredAttributeAttribute sounds strange, it should be RequiredAttribute.
Sorry for the delayed reply.
The code looks like this:
/// <summary>
/// <para>s-coordinate of start position</para>
/// <para xml:lang="en">Minimum inclusive value: 0.0.</para>
/// </summary>
[System.ComponentModel.DescriptionAttribute("s-coordinate of start position")]
//[System.ComponentModel.DataAnnotations.RequiredAttribute()]
[System.Xml.Serialization.XmlAttributeAttribute("s")]
public double S { get; set; }
/// <summary>
/// <para>Start position (x inertial)</para>
/// </summary>
[System.ComponentModel.DescriptionAttribute("Start position (x inertial)")]
//[System.ComponentModel.DataAnnotations.RequiredAttribute()]
[System.Xml.Serialization.XmlAttributeAttribute("x")]
public double X { get; set; }
/// <summary>
/// <para>Start position (y inertial)</para>
/// </summary>
[System.ComponentModel.DescriptionAttribute("Start position (y inertial)")]
//[System.ComponentModel.DataAnnotations.RequiredAttribute()]
[System.Xml.Serialization.XmlAttributeAttribute("y")]
public double Y { get; set; }
Because of that, I had to manually comment out all of the occurrences of DataAnnotations, which is doable with Find and Replace, but tedious and I think it's not the right way of doing this. :/
This is the screenshot of the problem inside Visual Studio.

I know that in an ordinary .NET application, you just need to add a reference to the appropriate assembly. However, in Unity it is not so trivial nor currently desired.
OK I'll try and make this configurable. I won't be getting to it until next week, though.
That's awesome to hear! The project where I'm using this tool will still be a while away, so it's no problem to wait for a little. Plus I think anyone using this tool on Unity projects would appreciate that configuration option.
As I've read on many forums these DataAnnotations due to being in a different .dll than the rest are a pain in the ass (even outside of Unity projects).
There already is support for this feature through the -c option (PCL compatible output). This does a few other things as well but hopefully those won't impact your use case.