Skip to content

Add support for string interpolation conversions on user-defined methods #21

Open

Description

@DustinCampbell

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) { ... }

Activity

  1. added this to the milestone on Jul 22, 2015
  2. pharring commented on Jul 22, 2015

    @pharring
    Contributor

    Where does that attribute come from?

  3. fsateler commented on Jul 22, 2015

    @fsateler

    @pharring it should be defined by CSharp essentials. This would probably require to provide the nuget package (#15)

  4. Bryan-Legend commented on Jul 28, 2015

    @Bryan-Legend

    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

  5. modified the milestones: 1.0.4, on Sep 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions