Can Xsd2Code be made to run a series of Regex find/replace on the generated code?

Nov 4, 2009 at 2:17 PM

Hi there

I'm thinking that one option which may quiet a few people here is to allow the generated code to undergo a series of regex replacements after generation. For a simple example, I'd like to be able to:

Find: \b(\w+)Field\b

Replace: m_\1

To turn my member variable names someNameField into _someName

 

For more complex requests, Xsd2Code can first edit the patterns with a known set of variables before it runs the replacement. Some people ask not to generate a constructor.. No probs:

Find: public $$classname.*?\}

Replace: //constructor removed

 

Note: $$classname would be a variable that xsd2code would have to replace with a proper value., It might not be sucha  hardship for most if this last part wasnt implemented, they'd just have to write their regexes with the class name in it (or think of another way to identify a class, such as only one word before the open bracket (

-

 

This could also be used to achieve my other "ignore" request (perhaps) where I want to not generate an enum; if this were implemented then I could let xsd2code generate the enum and then I'll just regex replace it out of there..

 

Nov 4, 2009 at 3:31 PM
Sure it's a very good idea but i need time to implement this.
Currently I am the only developer working on the project.
Many people ask me changes.
So I can't tell you when regex will be studied and realized.
Pascal.

2009/11/4 cjard <notifications@codeplex.com>

From: cjard

Hi there

I'm thinking that one option which may quiet a few people here is to allow the generated code to undergo a series of regex replacements after generation. For a simple example, I'd like to be able to:

Find: \b(\w+)Field\b

Replace: m_\1

To turn my member variable names someNameField into _someName

 

For more complex requests, Xsd2Code can first edit the patterns with a known set of variables before it runs the replacement. Some people ask not to generate a constructor.. No probs:

Find: public $$classname.*?\}

Replace: //constructor removed

 

Note: $$classname would be a variable that xsd2code would have to replace with a proper value., It might not be sucha  hardship for most if this last part wasnt implemented, they'd just have to write their regexes with the class name in it (or think of another way to identify a class, such as only one word before the open bracket (

-

 

This could also be used to achieve my other "ignore" request (perhaps) where I want to not generate an enum; if this were implemented then I could let xsd2code generate the enum and then I'll just regex replace it out of there..

 

Read the full discussion online.

To add a post to this discussion, reply to this email (Xsd2Code@discussions.codeplex.com)

To start a new discussion for this project, email Xsd2Code@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Mar 27, 2011 at 1:12 AM

This could be a very good feature because I running into trouble when I want to generate xml attribute and use the generated classes with WCF.

The result is a double ...Field suffix added to my members when I generate stub for my WCF client.. and of course, I can't deserialize anymore in my client.

Apr 1, 2011 at 5:29 PM

hi, I have xsd files with more than one XSD schema type defined. The exd does not have top-level element definition. I am looking for a  way to create a single C# class for each XSD schema type (ComplextType or SimpleType)), preferably in a separate file. So for example, if the single XSD file has two ComplexType elements definitions I would like to generate 2 C# classes, preferably, each class in a separate file. Does Xsd2Code provide this flexibility? Thank you.,