Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8429635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:23:30+00:00 2026-06-10T05:23:30+00:00

I like how String.Format uses arguments to inject variables in to the string it

  • 0

I like how String.Format uses arguments to inject variables in to the string it is formatting. This is called Composite Formating and is discussed by MSDN here.

I want this functionality with my logging facade:

string foo = "fancy";
string bar = "message";
log.Debug("My {0} log {1}.", foo, bar)

My ILoggerFacade has the following method signature:

void Debug<T>(T message, params Object[] args);

And, I know I can implement this quite simply:

ILog m_Log = \\some logging implementation
public void Debug<T>(T message, params Object[] args)
{
    m_Log.Debug(String.Format(message, args));
}

However, in Visual Studio I don’t get the fancy highlighting of the {0}, {1}, … arguments:

Argument highlighting for Composite Formatting methods

I guess it is ReSharper who is resposible for them, and it seems like it is just ignoring the formatting arguments and giving no “intellisense” help. This isn’t good since the other developers who will be using the facade will be expecting this.

How do I get argument highlighting and “intellisense” for custom formatted methods similar to how these work:

Console.WriteLine(...)
String.Format(...)
etc...

Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:23:32+00:00Added an answer on June 10, 2026 at 5:23 am

    Check out ReSharpers External Annotations. Specifically, you want to use StringFormatMethodAttribute for this.

    To use the External Annotations there are actually 3 methods. Two that it spells out, and one that you have to read between the lines to see.

    1. Reference “JetBrains.Annotations.dll”. I would recommend against this one. I don’t like the idea of copying the DLL, or having to reference the ReSharper install directory. This could cause issues if you upgrade or re-install.

    2. Copying and pasting attribute declarations into your solution. I’d recommend this as it gives you more control. Additionally, you can get rid of ReSharper (why would anyone do this? Stranger things have happened, I guess.), and still provide this feature to anyone that consumes your library. There are step by step instructions on how to do this in the first link.

    3. Create an XML file, similar to what it uses for for the .NET Assemblies. I did this for the Silverlight Unit Test Framework. ReSharper does not recognize these tests by default.

      To do this

      1. Create a file name <assembly>.xml and put it in “ReSharper\vXX\Bin\ExternalAnnotations”.
      2. Add a root element "<assembly name="<assembly>">
      3. Now add <member> elements for each member that you want to give an attribute.

      I do not recommend doing this for your own code. However, if you have an assembly that you want to have this functionality, but cannot edit, this is the way to do it. This will only apply on your machine and each developer that uses the assembly will need to copy the xml file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

string format is always like this FirstName=ABC;LastName=XZY;Username=User1;Password=1234. I need the only UserName value (which
I have a string defined in my String.xml file that uses format arguments, i.e.:
I am generating an XML document from a StringBuilder, basically something like: string.Format(<text><row>{0}</row><col>{1}</col><textHeight>{2}</textHeight><textWidth>{3}</textWidth><data>{4}</data><rotation>{5}</rotation></text> Later,
Is there any way to create a new NSString from a format string like
According to the docs String text = String.format(%5.1e, 3.1415f); Should produce something like 3.1E+00
I'd like to use date time format string (possibly UTC) which is understandable and
How I can do something like this in C++: void my_print(format_string) { vector<string> data;
Just curious, is there a format string I can use to output something like
I have a string in the format: 'nn.nnnnn' in Python, and I'd like to
I like to format the local timeformat into a string without the year. At

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.