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.

KaeL
  • 121

1 Answers1

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.

KaeL
  • 121