Metadata for a custom logger that uses string.Format under the hood

So I have a logger that defaults to the old old one Console.WriteLine()

, but it can be tested with a block and in a windows application, to name one example, I can use a different implementation to write the output to the window that can see. The interface looks like this:

public interface ILog
{
    void WriteLine(string text, params object[] args);
}

      

So far, such a pattern. However, there is something else I would like to do. In Visual Studio, if you use string.Format

or Console.WriteLine

, the editor and compiler will match the arguments in args

to the contents of your string and warn you if they don't match. In addition, the components of {0}, {1:0.00}, ...

your string are rendered with nice highlighting to show where your arguments will appear in the string you are building.

Is there some kind of metadata that I can pass to the compiler so that it knows my method ILog.WriteLine

should behave the same as string.Format

or Console.WriteLine

? I searched but couldn't find anything.

+3
c # visual-studio


source to share


No one has answered this question yet

See similar questions:

6
How to write a method of type string.Format with intellisense support

or similar:

713
Escape curly brace '{' in String.Format
681
.NET String.Format () to add commas to thousands of number places
658
MetadataException: Unable to load the specified metadata resource
631
The metadata file '.dll' was not found.
480
Curious Zero Coalescent Collaboration Operator
133
Why use String.Format?
8
What is under the hood molding
1
C # argument error
0
Passing parameters / properties with MEF
0
Strange modification of XML when entering and outputting it in a console application using Visual Studio



All Articles
Loading...
X
Show
Funny
Dev
Pics