I’m trying to automate the generation and cleanup of partial classes created using the .net framework’s XSD too. My main problem is that [System.Diagnostics.DebuggerStepThroughAttribute()] affects the code in my partial class as well as the automatically generated one. I can delete the offending attribute in the same batch file that I use to create the files.
However I don’t want to be stepping into all of the autogenerated file’s properties. I can stop the debugger from entering each property by applying [System.Diagnostics.DebuggerStepThrough()] to the get and set methods. Can I do this via a batch file? without needing to install/configure a third party scripting language to do the text processing?
Example property with attributes added:
public string FileFormatVersion
{
[System.Diagnostics.DebuggerStepThrough()]
get {
return this.fileFormatVersionField;
}
[System.Diagnostics.DebuggerStepThrough()]
set
{
this.fileFormatVersionField = value;
}
}
Link to deleting lines via a batch file (first part of the needed cleanup)
Delete certain lines in a txt file via a batch file
This is simplistic, and won’t handle cases like properties that already have the attribute added. It also might choke on some lines of code, but I haven’t found a line that does yet.
[Edit] Made the changes mentioned below, except for the extra echo indentation (would just look ugly on this page).