Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add string interpolation conversions for other common .NET APIs #19

Open
DustinCampbell opened this issue Jul 21, 2015 · 5 comments
Open
Assignees
Labels
Milestone

Comments

@DustinCampbell
Copy link
Owner

It'd be great to be able to apply the "Convert to String Interpolation" to .NET APIs other than just String.Format(). For example:

  • Debug.WriteLine(string, params object[])
  • Console.WriteLine(string, params object[])
  • StringBuilder.AppendFormat() (even though this causes an allocation)
@DustinCampbell DustinCampbell self-assigned this Jul 21, 2015
@DustinCampbell DustinCampbell added this to the 1.0.3 milestone Jul 21, 2015
@pharring
Copy link
Contributor

Add to the list TextWriter.Write and TextWriter.WriteLine

@fsateler
Copy link

Or user-defined methods as well.

@DustinCampbell
Copy link
Owner Author

@fsateler, Do you have a proposal for how that might be detected? Requiring a parameter of type string and a parameter of object[] seems too permissive.

@fsateler
Copy link

@DustinCampbell I think the only reasonable way is to require annotation with an attribute. This would also allow formatters that require extra parameters:

 [FormatStringConsumer(FormatStringParameterNumber = 2)]
 void WriteToDevice(Device d, string format, params object[] arguments) { ... }

@DustinCampbell
Copy link
Owner Author

Nice idea! Should probably be a separate issue though. Added #21 to capture this.

@DustinCampbell DustinCampbell modified the milestones: 1.0.4, 1.0.3 Sep 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants