c# - 警告 CA1065 Microsoft 设计未实现异常

标签 c# code-analysis notimplementedexception

我用谷歌搜索但找不到正确答案。谁能知道如何处理这类错误?错误是:

 public override ReadOnlyCollection<SecurityKey> SecurityKeys
    {
        get { throw new NotImplementedException(); }
    }

Warning 20 CA1065 : Microsoft.Design : 'someToken.SecurityKeys.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. D:\some\Security\someUserToken.cs

最佳答案

如果您抛出它是因为您还没有编写该属性,即您将其视为 Not(Yet)ImplementedException,那么您需要实现该属性。

但是,如果您向消费者表明此属性不合适,请改用 NotSupportedException。

关于c# - 警告 CA1065 Microsoft 设计未实现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13815148/

相关文章:

c# - 请求的 URL 返回 500 - 内部服务器错误

c++ - Coverity 扫描设置?

Java POI : How to read Excel cell value and not the formula computing it?

c# - 在 C# 中将 JSON 变量转换为小写

c# - 更改几个表中的列参数

visual-studio - 您是如何选择 Visual Studio 生产力插件的?

visual-studio - 何时使用 `silent` 代码分析严重性?

visual-studio - 为什么代码分析不警告 NotImplementedException?

python - 使用 NumPy 的 isnan 函数检查用户输入

c# - 如何清除 ElementHost 控件的内存泄漏