33using System . Diagnostics ;
44using System . Linq ;
55using System . Threading . Tasks ;
6- using System . Windows . Automation . Peers ;
6+ using Community . VisualStudio . Toolkit . Shared . Helpers ;
77using Microsoft . Internal . VisualStudio . PlatformUI ;
88using Microsoft . VisualStudio ;
99using Microsoft . VisualStudio . Shell ;
@@ -23,6 +23,7 @@ public class SolutionItem
2323 private IVsHierarchy _hierarchy = default ! ; // Initialized to non-null via the `Update()` method.
2424 private string ? _fullPath ;
2525 private uint _itemId ;
26+ private Lazy < bool > _isNonVisibleItem = default ! ; // Initialized to non-null via the `Update()` method.
2627
2728 /// <summary>
2829 /// Creates a new instance of the solution item.
@@ -38,9 +39,18 @@ internal void Update(IVsHierarchyItem item)
3839 {
3940 ThreadHelper . ThrowIfNotOnUIThread ( ) ;
4041 _item = item ;
41- _hierarchy = item . HierarchyIdentity . IsNestedItem ? item . HierarchyIdentity . NestedHierarchy : item . HierarchyIdentity . Hierarchy ;
42- _itemId = item . HierarchyIdentity . IsNestedItem ? item . HierarchyIdentity . NestedItemID : item . HierarchyIdentity . ItemID ;
42+ _hierarchy = item . GetHierarchy ( ) ;
43+ _itemId = item . GetItemId ( ) ;
4344 _fullPath = GetFullPath ( ) ;
45+ _isNonVisibleItem = new Lazy < bool > ( ( ) =>
46+ {
47+ if ( HierarchyUtilities . TryGetHierarchyProperty ( _hierarchy , _itemId , ( int ) __VSHPROPID . VSHPROPID_IsNonMemberItem , out bool isNonMemberItem )
48+ && isNonMemberItem )
49+ {
50+ return isNonMemberItem ;
51+ }
52+ return false ;
53+ } ) ;
4454 }
4555
4656 /// <summary>
@@ -73,6 +83,11 @@ internal void Update(IVsHierarchyItem item)
7383 /// </summary>
7484 public IEnumerable < SolutionItem ? > Children => _children ??= _item . Children . Select ( t => FromHierarchyItem ( t ) ) ;
7585
86+ /// <summary>
87+ /// Returns whether the item is normally visible in soltuion explorer
88+ /// </summary>
89+ public bool IsNonVisibleItem => _isNonVisibleItem . Value ;
90+
7691 /// <summary>
7792 /// Gets information from the underlying data types.
7893 /// </summary>
@@ -128,7 +143,7 @@ public void GetItemInfo(out IVsHierarchy hierarchy, out uint itemId, out IVsHier
128143 {
129144 throw new ArgumentNullException ( nameof ( hierarchy ) ) ;
130145 }
131-
146+
132147 ThreadHelper . ThrowIfNotOnUIThread ( ) ;
133148 IVsHierarchyItem item = hierarchy . ToHierarchyItem ( itemId ) ;
134149
0 commit comments