Skip to content

Patch for NeTEx v1.3#624

Open
Micovec wants to merge 2 commits into
mganss:masterfrom
Micovec:netex-patch
Open

Patch for NeTEx v1.3#624
Micovec wants to merge 2 commits into
mganss:masterfrom
Micovec:netex-patch

Conversation

@Micovec

@Micovec Micovec commented Jul 5, 2026

Copy link
Copy Markdown

This PR fixes two main issues that are related to NeTEx v1.3 (#620).

Firstly, it removes all XmlElementAttributes that 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 XmlElementAttribute a XmlChoiceIdentifierAttribute is added to the property and two new members are introduced to the class:

  • an enum with all possible element names
  • array of this enum

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.1 and add new one netex/1.3 for the problematic version of NeTEx. I will wait for your feedback on that.

Micovec added 2 commits July 5, 2026 19:39
- 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

codecov Bot commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 12.50000% with 42 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.42%. Comparing base (f25d2d4) to head (dadfef7).

Files with missing lines Patch % Lines
XmlSchemaClassGenerator/Models/PropertyModel.cs 10.63% 40 Missing and 2 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mganss

mganss commented Jul 7, 2026

Copy link
Copy Markdown
Owner

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.

@Micovec

Micovec commented Jul 8, 2026

Copy link
Copy Markdown
Author

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 base

The solution would be to make the property of type EquipmentRefStructure. I will look into this.

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 XmlSerializer. I have no idea what to do about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants