mamift / LinqToXsdCore

LinqToXsd ported to .NET Core (targets .NET Standard 2 for generated code and .NET Core 3.1, .NET 5+ for the code generator CLI tool).
Microsoft Public License
41 stars 15 forks source link

Remove CodeDom dependency from runtime #27

Closed jods4 closed 3 years ago

jods4 commented 3 years ago

Fixes #24

I moved code around so that the CodeDom dependency is removed from XObjectsCore (i.e. the runtime package).

High level changes

  1. Turned XObjectCode into a real C# project, referencing CodeDom. It's referenced by the CLI tool and the tests.
  2. Removed XObjectCode dependency from XObjectsCore, as well as CodeDom.
  3. Moved code around until everything compiled fine again, mostly moving files was enough.
  4. Some stuff was marked internal but is used by both projects. To solve this easily without exposing new members, I added a InternalsVisibleTo attribute on XObjectsCore allowing XObjectCode to use internal stuff.
  5. I think there was one single class that contained code referenced by Core but also using CodeDom. I extracted what Core used into ListFormatter (new file, old code).

Is it good?

This is not well tested but:

  1. I did not change any actual code in this PR.
  2. The project fully compiles with no error and the same warnings as before.
  3. I have taken every generated .cs file from the test Schemas folder and they all compile fine with no reference other than XObjectsCore.

(3) makes me feel pretty confident we've got all the public APIs covered as there's a lot of big xsd in there. That said, there could be a rare public API that was left in XObjectsCode (which would be detected at compilation time for any affected user).

Further improvements

I deliberately made no attempt at cleaning up the code (as diffs would be hard to review with so many moves).

The layering is very crude and could be better with more efforts. There's a lot of stuff left in XObjectsCore that's actually only used by XObjectsCode. At least the external CodeDom dependency is gone and I think it's a good first step.