当我为 Ninject 配置 log4net 时,Resharper 引发了非常奇怪的消息“可能错误地调用了 GetType()”。知道这意味着什么吗?
kernel.Bind<ILog>().ToMethod(ctx => LogManager.GetLogger(ctx.Request.ParentRequest?.Service.GetType()));
最佳答案
我认为您收到此警告是因为 ParentRequest.Service
已经是一种类型。
对其调用 GetType()
可能总是会返回类似 System.RuntimeType
或 System.Type
的内容。
所以警告似乎很相关。
关于c# - Resharper - 可能错误调用 GetType(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59845139/