R# PowerToys ToString modification and problems


Just discovered the PowerToys package, and i really missed the ToString that was in intelliJ :D

With this great ToString feature i want to make a small adjustment to the generator. My goal is to include the Type Name of the object having the ToString member, this way i can see which type is used in implementation of a interface. Secondly i want to use String.Concat instead of StringBuilder - most for cosmetic reasons ;)

I have attached the file ToStringGenerator.cs with my changes. Look in the method "GenerateBody" and its comments for further descriptions. I have generated a ToString method so you can see my little problem. For some reason my concat lines are cut'ed, no values/reference fields are present?

Hopefully i am doing something wrong ;)

TIA, Frank

1 comment
Comment actions Permalink

Well i did one thing wrong, i attached the wrong file ;)

Meanwhile i've had a second view on the code and got it to work. it still fuzz me why i can't get it to work with the String.Concat function, but it is properly due to some missing escaping in the double formatting?!

I have attached the new, and correct, file. The ToString will print out in this format;

public override string ToString()
StringBuilder builder = new StringBuilder(512);
builder.Append("myFieldsPage=\"").Append(myFieldsPage != null ? myFieldsPage.ToString() : "(null)").Append("\"");
builder.Append(",myReplacePage=\"").Append(myReplacePage != null ? myReplacePage.ToString() : "(null)").Append("\"");
builder.Append(",mySolution=\"").Append(mySolution != null ? mySolution.ToString() : "(null)").Append("\"");
builder.Append(",myTextControl=\"").Append(myTextControl != null ? myTextControl.ToString() : "(null)").Append("\"");
builder.Append(",myTypeDeclaration=\"").Append(myTypeDeclaration != null ? myTypeDeclaration.ToString() : "(null)").Append("\"");
return builder.ToString();

If any want the binary version, post a comment here...

Cheers Frank


Please sign in to leave a comment.