Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading