.net c# Visual Studio 2013扩展解决方案资源管理器筛选器

Visual Studio 2013 Extending Solution Explorer Filter
2020-11-21
  •  译文(汉语)
  •  原文(英语)

我正在尝试为解决方案资源管理器创建一个带有自定义过滤器的VsPackage.我遵循了https://msdn.microsoft.com/zh-cn/library/hh966591.aspx上的演练,后一步,我看到了按钮,可以单击它,但从未应用过该过滤器.而且我什至无法调试它,因为没有调用过滤器类中的单个方法.有没有人有写自定义过滤器的经验,或者只是遇到过同样的问题?

速聊1:
您的问题过于模糊,以目前的形式很难回答,需要集中精力解决单个问题并显示一些代码.
速聊2:
该代码正是本教程中的代码,只需按照说明复制粘贴并更新Manifest.我认为问题可能是我没有在菜单命令回调中执行任何操作.我认为过滤器将在找到后自动加载,或者使用[SolutionTreeFilterProvider(GuidList.guidFileFilterCmdSetString,(uint)(PkgCmdIDList.cmdidFilterFile))]属性自动连接.如果是这样,我不确定命令处理程序必须执行什么操作来应用过滤器.我将在今天晚些时候尝试添加一些相关的代码,因为我现在还没有.
速聊3:
这个问题很好.我转载了问题.我正在调查.
解决过程1

命令处理程序不需要执行任何操作,实际上您可以删除命令绑定,过滤器是通过SolutionTreeFilterProvider(guid,id)属性的Guid / Id参数绑定的.

您的案例似乎是VS 2013的一个错误,因为在VS 2012中它可以工作.

我在MS Connect中打开了一个错误报告:https : //connect.microsoft.com/VisualStudio/feedback/details/1131606

更新:这是VS 2013文档样本中的一个错误,在VS 2012中是正确的:

第一个参数应该是SVsServiceProvider类型,而不是IServiceProvider类型:

  [ImportingConstructor]
  public FileNameFilterProvider(**SVsServiceProvider** serviceProvider, IVsHierarchyItemCollectionProvider hierarchyCollectionProvider)
  {
     ServiceProvider = serviceProvider;
     this.HierarchyCollectionProvider = hierarchyCollectionProvider;
  }

I'm trying to create a VsPackage with a custom filter for the solution explorer. I followed the walkthrough on https://msdn.microsoft.com/en-us/library/hh966591.aspx to the latter, I see the button and I can click it but the filter is never applied. And I can't even debug it because no single method in the filter class is ever called. Does anyone have experience writing a custom filter or maybe just had the same problem?

Talk1:
Your question is too vague and difficult to answer in it's current form, it needs work to focus on an individual problem and show some code.
Talk2:
The code is exactly the one from the tutorial, just copy paste and updating the Manifest as instructed. I think the problem might be that I'm not doing anything in the menu command callback. I thought the filter would be loaded automatically when found or rather automatically hooked up using the [SolutionTreeFilterProvider(GuidList.guidFileFilterCmdSetString, (uint)(PkgCmdIDList.cmdidFilterFile))] attribute. If so, I'm not sure what the command handler has to do to apply the filter. I will try to add some relevant code later today, as I don't have it just now.
Talk3:
The question is pretty much good. I have reproduced the problem. I am investigating.
Solutions1

The command handler doesn't need to do anything, in fact you can remove the command binding, the filter is bound through the Guid/Id parameters of the SolutionTreeFilterProvider(guid, id) attribute.

Your case seems a bug of VS 2013 because in VS 2012 it works.

I have opened a bug report in MS Connect: https://connect.microsoft.com/VisualStudio/feedback/details/1131606

UPDATE: it's a bug in the documentation sample of VS 2013 that it's correct in VS 2012:

The first parameter should be of type SVsServiceProvider and not IServiceProvider:

  [ImportingConstructor]
  public FileNameFilterProvider(**SVsServiceProvider** serviceProvider, IVsHierarchyItemCollectionProvider hierarchyCollectionProvider)
  {
     ServiceProvider = serviceProvider;
     this.HierarchyCollectionProvider = hierarchyCollectionProvider;
  }
转载于:https://stackoverflow.com/questions/28361843/visual-studio-2013-extending-solution-explorer-filter

本人是.net程序员,因为英语不行,使用工具翻译,希望对有需要的人有所帮助
如果本文质量不好,还请谅解,毕竟这些操作还是比较费时的,英语较好的可以看原文

留言回复
我们只提供高质量资源,素材,源码,坚持 下了就能用 原则,让客户花了钱觉得值
上班时间 : 周一至周五9:00-17:30 期待您的加入