CSharpEssentials
CSharpEssentials copied to clipboard
Add support for string interpolation conversions on user-defined methods
Just wanted to capture the suggestion made by @fsateler in issue #19 to allow users to annotate their own methods with a custom attribute which would allow the Convert to String Interpolation refactoring to run on them:
[FormatStringConsumer(FormatStringParameterNumber = 2)]
void WriteToDevice(Device d, string format, params object[] arguments) { ... }
Where does that attribute come from?
@pharring it should be defined by CSharp essentials. This would probably require to provide the nuget package (#15)
Resharper defines a StringFormatMethodAttribute for this: http://www.jetbrains.com/resharper/help/Code_Analysis__String_Formatting_Methods.html
I've looked thru the .net framework in hopes of finding something built in and applicable, but couldn't find anything exact.
Perhaps we could use suppressmessageattribute to turn it on instead of off! https://msdn.microsoft.com/en-us/library/system.diagnostics.codeanalysis.suppressmessageattribute(v=vs.110).aspx
Maybe [Category("Format")] or [Category("StringFormatMethod")]? https://msdn.microsoft.com/en-us/library/system.componentmodel.categoryattribute.aspx?f=255&MSPPError=-2147217396