Search code examples
c#visual-studiovisual-studio-2019vsix

Retrieve all nodes of a IVsHierarchy


I am searching for a way to get all the child nodes of a given IVsHierarchy. From the documentation itself I can't see any way to get a list of all items, just a way to get the properties of any item with the GetProperty method. Which has a parameter named itemid, which from my understanding should be fed with an unique id of any of its nodes. Anyhow as per documentation it should be of type VSConstants.VSITEMID, but this kinda doesn't seem right.


Solution

  • For any given node, you'll need to iterate the tree structure by invoking IVsHierarchy.GetProperty with __VSHPROPID.VSHPROPID_FirstChild and __VSHPROPID_VSHPROPID_NextSibling.

    There are a couple of examples hidden in the archived SCC extensibility samples. That you may be able to use for additional guidance.

    Sincerely, Ed Dore