visual-studio Visual Studio - 在源代码级别显示对函数的所有调用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/336051/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 09:58:21  来源:igfitidea点击:

Visual Studio - show all calls to a function in source code level

visual-studiofunction-calls

提问by Timothy Chung

I am wondering if there is any way to list all the calls to a function in source code, so that I could see the dependencies if I modify that function.

我想知道是否有任何方法可以在源代码中列出对函数的所有调用,以便在修改该函数时可以看到依赖项。

One method I use is to search the function name in the "Entire Solution" but I am looking for a better way.

我使用的一种方法是在“整个解决方案”中搜索函数名称,但我正在寻找更好的方法。

回答by Mr Fooz

Right-click on the call and select "Find All References".

右键单击呼叫并选择“查找所有引用”。

回答by grepsedawk

A brute force method is to change the name of the function and recompile and look at the errors. Sometimes I have trouble with the Find References functionality in VS.

一种蛮力的方法是更改​​函数的名称并重新编译并查看错误。有时我在使用 VS 中的 Find References 功能时遇到问题。

回答by softarn

On method declaration: Ctrl+K, Ctrl+T

在方法声明上: Ctrl+ K, Ctrl+T

回答by Mauricio Scheffer

Use NDepend. It comes with a VS add-in that allows you to do CQL queries on the fly. See this screenshot.

使用NDepend。它带有一个 VS 插件,允许您即时执行 CQL 查询。请参阅此屏幕截图