In C#, How can an interface (such as ILogger), with 1 method signature for log(), show 5 on intellisense?

54 views Asked by At

As per the title, how is this done? I understand that the framework has its own class with overloaded extension methods for objects of type ILogger<t>, but what I don't understand is how these methods are exposed through intellisense when the actual interface only has a single definition for log()? How does var logger = new IloggerClass(); know about the other methods? The reason I am asking is because I created my own extension methods, but they do not show up in intellisense, so I am guessing I am missing something or have the whole concept wrong!

My extension methods are defined with...

 public static class LoggerExtensions
    {
        public static void Log<TState>(this ILogger<TState> logger, LogLevel logLevel, string message, int prority)
        {
            //
        }

        public static void LogCustomMessage<T>(this ILogger<T> logger, LogLevel logLevel, string message)
        {
            logger.Log(logLevel, new EventId(), message, null, (state, ex) => state.ToString());
        }
    }

I have tried rebuilding/restarting and still no joy.

0

There are 0 answers