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.
source to share
No one has answered this question yet
See similar questions:
or similar: