有任何 VS C# 方法可以列出所有“抛出新的 NotImplementedException()”方法吗?

问题描述 投票:0回答:4

是否有任何懒惰的方法来列出所有在其主体中只有

throw new NotImplementedException();
的方法...这是内置的 Visual Studio C#?与
(Todo) Task List Pane
类似的东西,但只会列出此类空的抛出占位符方法,这些方法显然正在等待/等待实现?

这对于实现接口和轻松跟踪事物将很有帮助。

c# visual-studio
4个回答
7
投票

您是否尝试过

CTRL+SHIFT+F
并在
*.cs
文件中搜索
NotImplementedException


4
投票

转到对象浏览器 (Ctrl+Alt+J)。
找到

NotImplementedException
课程。
右键单击它并选择查找所有引用。


3
投票

这是一个你可以使用的黑客,虽然邪恶,但有效。 在项目中的某个位置添加以下类。 请务必在将其投入生产之前将其删除,或者使其与原始版本兼容。

namespace System
{
    [Obsolete("Fix this")]
    public class NotImplementedException : Exception 
    {
        public NotImplementedException() : base() {}
        public NotImplementedException(string message) : base(message) {}
        public NotImplementedException(string message, Exception innerException) : base(message, innerException) {}
        protected NotImplementedException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context) {}
    }
}

这将导致代码中的所有 NotImplementedExceptions 显示为警告。

这是一种针对源代码的类型拦截技术,我之前使用过一两次。 我通常不建议做这样的事情,除非你真的知道自己在做什么。


0
投票

我写了这个扩展https://marketplace.visualstudio.com/items?itemName=trungkien45.NotImplementedExceptionList

用于列出 NotImplementedException :)

© www.soinside.com 2019 - 2024. All rights reserved.