Resharper - 可能错误调用 GetType()

Resharper - Possible mistaken call to GetType()

当我为 Ninject 配置 log4net 时,Resharper 引发了非常奇怪的消息 "Possible mistaken call to GetType()"。知道这是什么意思吗?

kernel.Bind<ILog>().ToMethod(ctx => LogManager.GetLogger(ctx.Request.ParentRequest?.Service.GetType()));

我认为您收到此警告是因为 ParentRequest.Service 已经是一个类型。

对其调用 GetType() 可能总是 return 类似于 System.RuntimeTypeSystem.Type。 所以警告似乎很相关。