c# code geneartion

M

Marek

Actually, the very first question I should ask is "does it make sense at
all?". For 2 days I've been trying to generate C# classes using XML schema
and xsd.exe tool. So far the results are not exciting but I assume I am
seriously short of knowledge, so here I am - asking for help.

My friend is strongly advocating gsl-gen (a third-party code generator), so
I wonder if perhaps he is right ? I would really like to be able getting
that work done using just .net infrastructure, without any additional pieces
but I need somebody to tell me if I am going right way.

My current situation is that I can define schemas that will generate very
simple classes but I have three major problems:

(1) I do not know how to write a schema, so that my classes can get
properties with skeletons for getter and setter, as opposed to public fields
? Right now, for every generated class, all the attributes defined in xsd,
get converted into public fields, not properties.

(2) How to write a schema to get class structure that exposes inheritance
and incorporates interfaces ? I try to use "complexContent" with "extension"
and "base" attributes but when compiling the schema with xsd.exe I am
getting different kind of errors (i.e. "cannot generate classes because no
top-level elements with complex type were found" or "cannot generate
classes because no top-level elements with complex type were found" ). I
even tried to compile an example from MSDN (Person->ExtendedPerson) but no
success at all...

(3) How to define a schema that will generate classess with methods their
implementation ?

I would appreciate any useful hints, especially some exmaples for my two
problems that I mentioned above. Thank you very much,

Marek
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top