0

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?

user2154171
  • 145
  • 1
  • 1
  • 8
  • 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. – Ian Feb 06 '15 at 08:55
  • 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. – user2154171 Feb 06 '15 at 09:06
  • The question is pretty much good. I have reproduced the problem. I am investigating. – Carlos Quintero Feb 14 '15 at 11:24

1 Answers1

2

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;
  }
Carlos Quintero
  • 4,300
  • 1
  • 11
  • 18