There is some way to add a member to a class with roslyn? I want to add :
public int number {get;set;}
UPDATE I used this code:
PropertyDeclarationSyntax o =
SyntaxFactory.PropertyDeclaration(SyntaxFactory.ParseTypeName("public
System.Windows.Forms.Timer"), "Ticker { get; set; }");
var newRoot = root.ReplaceNode(oldMethod, oldMethod.AddMembers(o));
newRoot = Formatter.Format(newRoot, new AdhocWorkspace());
File.WriteAllText(file, newRoot.ToFullString());
But the the result is this:
public class ClassChild
{
public int n;
private int n2;
public void method1()
{
string c = "";
Console.WriteLine();
}
public System.Windows.Forms.TimerTicker { get; set; }
}
}
I would like to inline public System.Windows.Forms.TimerTicker { get; set; } with n and n2. How Can I do this ?