XmlSchemaClassGenerator icon indicating copy to clipboard operation
XmlSchemaClassGenerator copied to clipboard

Option to prevent the prefix from being added to the output path

Open MrMikeJJ opened this issue 3 years ago • 8 comments

Hi, It would be nice if there was an option to prevent the Prefix from being added to the output path thanks Mike

MrMikeJJ avatar Jan 27 '22 20:01 MrMikeJJ

Hi,

The prefix is only used for autogenerated namespaces, not explicit namespaces.

When i was playing around with this, i seemed to get mixed results. As in, when ran through the library - yes that is how it works through the GeneratorConfiguration constructor.

However i seem to get different results when ran from the EXE - it always adding it. I believe it is because the command line version goes through CodeUtilities.ParseNamespace which seems to always append the Prefix. (so is this inconsistant behaviour a bug ?)

So, what i was requesting with this feature request, was really how i was expecting it to work: Added Prefix always added and output into the directory specified.

e.g. for an XSD with namespace "Foobar" - set to separate files with the output directory - ProgramDirectory\Entities\Xml and the prefix to be "ProgramName.Entities.Xml"

Expecting files to like ProgramDirectory\Entities\Xml\Foobar\Foo.cs ProgramDirectory\Entities\Xml\Foobar\Bar.cs with namespace "ProgramName.Entities.Xml.Foobar"

Also, while i was testing the behaviour of this running as a library, i wrote about 20 unit test (which test the current behaviour) - with the Prefix being added in a few different ways, 1 file vs Separate files, etc. Would you like a PR for these Unit Tests ? (they run of a local copy of the sample Xsd from https://docs.microsoft.com/en-us/visualstudio/xml-tools/sample-xsd-file-simple-schema?view=vs-2022

MrMikeJJ avatar Feb 06 '22 10:02 MrMikeJJ

Sure. If you're interested, a PR implementing the behavior you have described (optionally create separate folders for every namespace component) would be welcome as well.

mganss avatar Feb 07 '22 15:02 mganss