diff --git a/src/VisualStudio/Core/Impl/SolutionExplorer/SymbolTree/RootSymbolTreeItemSourceProvider.cs b/src/VisualStudio/Core/Impl/SolutionExplorer/SymbolTree/RootSymbolTreeItemSourceProvider.cs index 8a43903283e4e..8e216246c56ee 100644 --- a/src/VisualStudio/Core/Impl/SolutionExplorer/SymbolTree/RootSymbolTreeItemSourceProvider.cs +++ b/src/VisualStudio/Core/Impl/SolutionExplorer/SymbolTree/RootSymbolTreeItemSourceProvider.cs @@ -179,26 +179,24 @@ await source.UpdateIfEverBeenAskedToComputeAsync(cancellationToken) return null; } - var hierarchy = item.HierarchyIdentity.NestedHierarchy; - var itemId = item.HierarchyIdentity.NestedItemID; - - if (hierarchy.GetProperty(itemId, (int)__VSHPROPID7.VSHPROPID_ProjectTreeCapabilities, out var capabilitiesObj) != VSConstants.S_OK || - capabilitiesObj is not string capabilities) - { + // Important: currentFilePath is mutable state captured *AND UPDATED* in the local function + // OnItemPropertyChanged below. It allows us to know the file path of the item *prior* to + // it being changed *when* we hear the update about it having changed (since the event doesn't + // contain the old value). + if (item.CanonicalName is not string currentFilePath) return null; - } - if (!capabilities.Contains(nameof(VisualStudio.ProjectSystem.ProjectTreeFlags.SourceFile)) || - !capabilities.Contains(nameof(VisualStudio.ProjectSystem.ProjectTreeFlags.FileOnDisk))) + if (item.HierarchyIdentity.NestedHierarchy.GetGuidProperty( + item.HierarchyIdentity.NestedItemID, + (int)__VSHPROPID.VSHPROPID_TypeGuid, + out var guid) != VSConstants.S_OK) { return null; } - // Important: currentFilePath is mutable state captured *AND UPDATED* in the local function - // OnItemPropertyChanged below. It allows us to know the file path of the item *prior* to - // it being changed *when* we hear the update about it having changed (since hte event doesn't - // contain the old value). - if (item.CanonicalName is not string currentFilePath) + // We only support this for real files that we'll then have Roslyn Documents for. All the other + // things in a project (like folders, nested projects, etc) are not supported. + if (guid != VSConstants.ItemTypeGuid.PhysicalFile_guid) return null; var source = new RootSymbolTreeItemCollectionSource(this, item);