I am creating an automation tool for inserting properties to existing class's source code. E.g. I have an existing source code like this:
public class MyClass
{
//class members goes here
}
I want to modify it to become like this
public class MyClass
{
//class members goes here
public string MyProp { get; set; }
}
and save it to the same file.
The class name, property type and property name will be known before hand and can be considered parameters of the operation. Any idea how to do this easily? Perhaps regex replace will work for this, but I don't know which expression to use that will be flexible regardless of the source code's new line, whitespace and identation policy.
EDIT: What I'm looking for is simply automatically generating the source code, not manipulating classes during runtime