OPCFoundation / UA-ModelCompiler

ModelCompiler converts XML files into C# and ANSI C
MIT License
151 stars 94 forks source link

PropertyDesign Enum attributes don't get serialized #110

Closed gregorvilkner closed 2 years ago

gregorvilkner commented 2 years ago

In the simple model below, the Purpose attribute on the Object type gets serialized, but the ValueRank on the PropertyDesign attribute doesn't get serialized.

Any idea of how to fix this?

Kind regards, Gregor

ModelDesign md = new ModelDesign(); md.Items = new NodeDesign[] { new ObjectTypeDesign() { Purpose=DataTypePurpose.ServicesOnly, Children=new ListOfChildren() { Items=new InstanceDesign[] { new PropertyDesign() { ValueRank=ValueRank.Array } } } } }; using (var writer = XmlWriter.Create(Console.OpenStandardOutput())) { var serializer = new XmlSerializer(md.GetType()); serializer.Serialize(writer, md); }

opcfoundation-org commented 2 years ago

When serializing from auto generated classes to need to check if a "Specified" property exists and set it. i.e. ValueRankSpecified = true;

gregorvilkner commented 2 years ago

new PropertyDesign() { ValueRank=ValueRank.Array, ValueRankSpecified=true, }

cool. that was easy. thanks a lot. #livesaver