Patch for NeTEx v1.3#624
Conversation
- add XmlChoiceIdentifierAttribute for properties that are of the same type as one of theirs XmlElementAttribute's type parameter - for such properties also generate corresponding enum and property
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #624 +/- ##
==========================================
- Coverage 93.52% 92.42% -1.11%
==========================================
Files 33 33
Lines 3489 3536 +47
Branches 550 558 +8
==========================================
+ Hits 3263 3268 +5
- Misses 128 168 +40
- Partials 98 100 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Thanks a lot, that's awesome. I think it might be best to replace the current NeTEx test with the newer 1.3 schema. The tests already take a long time and I don't think there is any gain from keeping both tests. |
|
I apologize for the premature enthusiasm but I've just found out that this patch works only on v1.3 (latest v2.0) AND only when it is used in separate assembly that is referenced in a web application project with enabled AOT. I can't get it to work in a regular console app. There seems to be an issue with some property types. Some of them declare a base type that lays on a sibling-derived tree like so: // In ActivationAssignmentVersionStructure.cs
[XmlElement("MeetingPointServiceRef", Type=typeof(MeetingPointServiceRefStructure), ...)]
[XmlElement("ActivatedEquipmentRef", Type=typeof(ActivatedEquipmentRefStructure), ...)]
public ActivatedEquipmentRefStructure EquipmentRef { get; set; }The derivation tree looks like this: VersionOfObjectRefStructure
└── EquipmentRefStructure
├── ActivatedEquipmentRefStructure
└── LocalServiceRefStructure
└── MeetingPointServiceRefStructure - Does not have ActivatedEquipmentRefStructure as a baseThe solution would be to make the property of type Sadly, this is just v1.3 schema, not the lastest. In v2.0 some classes have properties with the exact same element name and type which is not allowed for |
This PR fixes two main issues that are related to NeTEx v1.3 (#620).
Firstly, it removes all
XmlElementAttributesthat have abstract types. Abstract types cannot be instantiated and it doesn't make sense to annotate properties with them. It also fixes an issue with duplicated element names (relative only to NeTEx).Secondly, whenever there is a property that has the same type as one of its
XmlElementAttributeaXmlChoiceIdentifierAttributeis added to the property and two new members are introduced to the class:These new members are needed by
XmlSerializer. Without them serialization throws an error.I have not yet added unit tests. My suggestion is to preserve all unit tests for currently supported NeTEx: move the current schema into a folder
netex/1.1and add new onenetex/1.3for the problematic version of NeTEx. I will wait for your feedback on that.