【问题标题】:Resharper - Possible mistaken call to GetType()Resharper - 可能错误调用 GetType()
【发布时间】:2020-01-21 16:14:43
【问题描述】:

当我为 Ninject 配置 log4net 时,Resharper 会发出非常奇怪的消息“可能错误地调用 GetType()”。知道这意味着什么吗?

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

【问题讨论】:

    标签: c# resharper ninject log4net


    【解决方案1】:

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

    在它上面调用GetType() 可能总是会返回类似System.RuntimeTypeSystem.Type 的内容。 所以这个警告似乎很相关。

    【讨论】:

    • 哦,我什至没有意识到 Service 实际上是一种类型......谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-12
    • 1970-01-01
    • 2014-09-28
    • 2011-11-09
    • 1970-01-01
    相关资源
    最近更新 更多