1

I am trying to implement an ISO standard which by summary has the following:

  1. There are operations (like an action in MVC)
  2. There are respective request and response per operation
  3. These requests and responses have corresponding XSD's
  4. These XSD's are changing per year (as per my observation)

Here are my challenges for now:

  1. XSD to C# classes generation (via VS command line) are so much pain. There are certain classes like Header and Enum's which are common to these XSDs but are getting generated separately.
  2. I only need specific properties from each response, the other values will be mapped to its response as return values. Which creates a conflict because of my problem in #1

    mapping the header from the request to response is not straightforward because they are of different classes. Same for other classes and enum values.

  3. I can manually map these values from request to response of all the operations that I need. But now my problem is the item #4 from my summary above. These XSD's are getting updates per year. I saw some considerable amount of change from last year's version to now like new values added to enum and new elements in XML.

Here are my thoughts for next action:

  1. Is there any XSD to C# classes generator which is smart enough not to duplicate the common classes and enumerations? This will primarily solve my problem as the mapper will be easily created. But doing it manually is an issue of deadlines and also the changing XSD's.
  2. If #1 is not a feasible solution, I am thinking of PropertyCopiers which can map values from different classes. But I haven't searched of such copiers that can map nested classes (deep property copiers). I would only rely on propertyNames which I can say is not reliable enough and reflection is quite slow.
  3. My last resort is doing the mapper manually like:

    DifferentClass1.SamePropertyName1 = DifferentClass2.SamePropertyName1

    and just do another mapper again next year when the next version comes.

4
  • What is the top-level purpose of the ISO standard? To facilitate building web scrapers? Create Internet machine middleware communicating via HTTP? – Robert Harvey Jun 6 '18 at 4:43
  • @RobertHarvey it is to standardize the format of messages between entities. – KaeL Jun 6 '18 at 5:25
  • you want to automate the annual job of updating your c# client? instead see if there is a published client for the api – Ewan Jun 8 '18 at 17:29
  • @Ewan sorry for the late reply. I haven't really thought of automation. My problem was just it was too hassle to map nested properties from Type1 to Type2 every year. And this problem was caused by the way XSD.exe (of visual studio) generates C# classes. But as I continue my research, I began to realize that this is a common problem for others too. – KaeL Jun 11 '18 at 1:50
1

As I continue my research for days, given that XML and XSD's has been long on enterprise products, my problem has been been experienced by other developers too.

  1. If #1 is not a feasible solution, I am thinking of PropertyCopiers which can map values from different classes. But I haven't searched of such copiers that can map nested classes (deep property copiers). I would only rely on propertyNames which I can say is not reliable enough and reflection is quite slow.

Because still XSD.exe is widely used for generating C# classes, the conflict in namespaces, classes, enumerations and others were solved (in a way) using AutoMapper - a nuget package object-to-object mapper with a lot of features.

Still learning and exploring how to use this library, but I am still open for answers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.