Visual Studio查看文件中所有#RIGE的列表

发布于 2025-01-20 18:45:45 字数 919 浏览 0 评论 0原文

我正在处理一个包含#Rigions分隔的几个测试的文件。

在vs 2022和2019中,右上角有一个不错的下拉列表,您可以单击,为您提供文件中所有符号的列表(属性,方法,构造函数等)

如果您扩展了文件名,则可以在解决方案资源管理器中使用相同的列表。


,我找不到Visual Studio中的任何此类列表,这些列表在Visual Studio中找到任何此类列表,这些列表列出了文件中的#Regions列表。在有意用#Rigions分段的非常大的文件中,看到所有区域的列表很有用,因此我可以快速浏览代码的各个部分,而不必滚动以找到区域或崩溃。

我可以使用ctrl+t去做我想要的任何东西,除区域外。

肯定有一种方法可以让我看到文件或类中所有#RIGE的列表,就像我一样查看文件或类中的所有符号?

我找不到这个简单问题的答案,并且似乎并没有在任何地方询问它。我在Google上的搜索(相当烦人)仅产生有关如何崩溃/扩展区域的结果,但没有看到所有区域。


在有人说:“如果您的课程需要那么大的话,请使用部分类”,即使我使用部分类(公平地说我已经在做),Ctrl+T和符号列表仍然在<<< em>班级的所有部分,,因此包含#Rigions仍然很有用。

I am working on a file full of several tests, separated by #regions.

In Both VS 2022 and 2019, there's a nice dropdown in the top right that you can click that gives you a list of all the symbols in the file (properties, methods, constructors, etc.)

Symbol List dropdown VS 2022

This same list is also available in Solution Explorer, if you expand the file name and then the class name.

Class Symbol List in Solution Explorer VS 2022


However, I cannot find any such list anywhere in Visual Studio that gives a list of the #regions within a file. In a very large file that is intentionally segmented with #regions, it would be useful to see the list of all the regions so I can quickly move through sections of the code, instead of having to scroll through to find regions, or collapse all regions.

I can use Ctrl+T to Go to whatever I want, except regions.

Surely there's a way for me to see a list of all #regions within a file or class, just like I can see all the symbols within a file or class?

I have not been able to find an answer to this simple question, and it doesn't seem to have been asked anywhere. My searches on google (rather annoyingly) only yield results about how to collapse/expand regions, but nothing about seeing all of them.


And before someone says, "Just use partial classes if your class needs to be that big", even if I use partial classes (which I am already doing, to be fair), Ctrl+T and the Symbols List still show symbols across all parts of the class, so it would still be useful for this to include #regions.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏雨凉 2025-01-27 18:45:45

根据您的代码包裹在#Rigions中的方式,您可以使用内置功能折叠到定义CTRL + M,O。然后导航到所需的区域。您可以使用CTRL + M,P

编辑:首先,如果启用了倒塌区域,请检查VS选项。路径是:
工具&gt;选项&gt;文本编辑&gt; c#&gt;高级检查“崩溃#崩溃时区域”

Depending on how your code is wrapped in #regions you can use the built-in feature to Collapse to Definition Ctrl + M , O. Then navigate to the region you want. You can undo the collapse by using Ctrl + M , P

Edit: First, check in VS options if collapse regions is enabled. The path is:
Tools > Options > Text Editors > C# > Advanced > Check "Collapse #regions when collapsing to definitions"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文