Automate conversion to 'Format' Method

Hey Resharper Devs,


I have a Question regarding Resharper Annotations.

When I am using a StringBuilder and I use the Method StringBuilder.Append(string). But the String has concartinactions in it. And I transform it to a string.Format with Resharper. Resharper automaticly uses the StringBuilder.AppendFormat(string, params object[]) Method of the StringBuilder. I want to use this Feature on my own Classes.

Just for clarifications:

This:

StringBuilder sb = new StringBuilder();
int[] array = {1, 2, 4};

sb.Append("hello " + array[0]);


becomes to this:

StringBuilder sb = new StringBuilder();
int[] array = {1, 2, 4};

sb.AppendFormat("hello {0}", array[0]);


But when I declare my own Methods:

public void Error(string message) {      provider.Error(message); } [StringFormatMethod("format")] public void ErrorFormat(string format, params object[] args) {      provider.Error(string.Format(format, args)); }



It won't work.

As far as I can see from the Resharper .NET Annotations the only Attribute set on the StringBuilder Method is the "StringFormatMethodAttribute" which I also set

1 comment
Comment actions Permalink

Unfortunately, the conversion from StringBuilder.Append to StringBuilder.AppendFormat is hardcoded, and not based on either a naming convention. But it's a nice feature, so I've added a feature request that you can track, vote for and add any other detail to: RSRP-448117

0

Please sign in to leave a comment.