I have an old guard class - it constisted or static methods, typical of a utilty class.
However, recently I've started to use NLog - so my guards can now log as well as throw. The thing is with NLog that each calling class (where the guard resides) creates its own logger, so instead of a method like this:
public static void NotNull<T>(T obj, string param)
{
if (obj.Equals(null))
throw new ArgumentNullException(param);
}
I have a method with a signature like this:
public static void NotNull<T>(T obj, string param, Logger logger, LogLevel logLevel)
{
}
Now all my methods contain the two same parameters relating to the logger, so I've almost decided that dependency injection would be a better approach, passing the logger into the constructor, and obj into the method.
The question I have is based on my inexperience - my new class won't be static, but should I leave the methods inside as static?