为什么代码分析不警告NotImplementedException? [英] Why does Code Analysis not warn about NotImplementedException?

查看:113
本文介绍了为什么代码分析不警告NotImplementedException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我敢肯定,Visual Studio Code Analysis的早期版本会警告您不要使用NotImplementedException,即包含此内容的任何成员

I'm pretty sure that previous versions of Visual Studio Code Analysis warned about the use of NotImplementedException, i.e. any member that contained this

throw new NotImplementedException();

会发出CA警告.

Visual Studio 2008似乎不是这种情况.

This doesn't seem to be the case with Visual Studio 2008.

该特定规则是否已删除,或者我只是在想它曾经存在过?

Was that particular rule removed, or am I just imagining that it ever existed?

推荐答案

您可能正在考虑

You are probably thinking about this FxCop warning that you get when throwing NotImplementedException from special methods such as a property getter, event accessor, Equals, GetHashCode, Dispose etcetera:

CA1065:Microsoft.Design: 'SomeClass.SomeProperty.get()' 创建一个类型的异常 'NotImplementedException',一个 不应为的异常类型 在财产中募集.如果这 可能会引发异常实例, 使用不同的异常类型 将此属性转换为方法, 或更改此属性的逻辑,以便 它不再引起

CA1065 : Microsoft.Design : 'SomeClass.SomeProperty.get()' creates an exception of type 'NotImplementedException', an exception type that should not be raised in a property. If this exception instance might be raised, use a different exception type, convert this property into a method, or change this property's logic so that it no longer raises an exception.

但是,它与NotImplementedException没有明确的关系. FxCop列出了这些方法可能(直接)抛出的异常的白名单.

However, it is not explicitly related to NotImplementedException. FxCop has white lists for the exceptions that may be (directly) thrown by these methods.

这篇关于为什么代码分析不警告NotImplementedException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆