visual-studio - 仅在特定文件名(+扩展名)的上下文菜单中显示命令

标签 visual-studio contextmenu visual-studio-extensions vsix visual-studio-2019

所以基本上我只想在我右键单击名为“example.cs”的文件时显示命令。由于我使用的是 Visual Studio 2019,我不能使用旧的 BeforeQueryStatus道路。而是使用 ProvideUIContextRule我的 Package 类上的属性。目前看起来像这样:

    [ProvideUIContextRule(_uiContextSupportedFiles,
    name: "Supported Files",
    expression: "CSharp",
    termNames: new[] { "CSharp" },
    termValues: new[] { "HierSingleSelectionName:.cs$" })]

对于文件本身的扩展名,这完全看起来不错。那么有什么方法可以将其限制为 example.cs ?

顺便说一下,我正在使用这个 Guide .

最佳答案

所以对于和我有同样问题的其他人。解决方案相当简单,关于 MSDN:

(...) The term evaluates to true whenever the current selection in the active hierarchy has a name that matches the regular expression pattern(...)



所以基本上改变{ "HierSingleSelectionName:.cs$" }{ "HierSingleSelectionName:Program.cs$" }只会显示以 Program.cs 结尾的文件.

这导致分号之后的所有内容都包含正则表达式。

关于visual-studio - 仅在特定文件名(+扩展名)的上下文菜单中显示命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57166170/

相关文章:

java - 无法右键单击,Java Selenium WebDriver java.lang.UnsupportedOperationException : contextMenu

jquery - z-index 在右键单击时不起作用

visual-studio-2010 - Visual Studio 2010 中垂直滚动条上的彩色小位是什么?

visual-studio - “favorite” 文件夹和文件是否有任何 Visual Studio 扩展?

import - 导出/导入 VS 扩展列表?

visual-studio - VSIX 安装程序扩展不可安装在任何当前安装的产品上

c++ - "Invalid template argument"错误在 Visual Studio 但不是 GCC

c# - 如何在 wpf 的分层数据模板中显示 TreeView 项的上下文菜单

c++ - 如何从 Visual Studio 调试器执行所有进程内存的高级搜索?

C++Boost.ASIO : passing accepted TCP connection from one opened socket to another using Windows APIs ( while works with Linux APIs)?