src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/Shell/Interop/VsProjectExtensions.cs
/// <summary>
///     Returns the <see cref="HierarchyId"/> of the given document moniker, or 
///     <see cref="HierarchyId.Nil"/> if the document moniker is not part of the project.
/// </summary>
Returns the  of the given document moniker, or
if the document moniker is not part of the project.
Returns the of the given document moniker or if the document moniker is not part of the project .
public static HierarchyId GetHierarchyId(this IVsProject project, string documentMoniker)
        {
            Requires.NotNull(project, nameof(project));
            Requires.NotNullOrEmpty(documentMoniker, nameof(documentMoniker));
            var priority = new VSDOCUMENTPRIORITY[1];
            HResult result = project.IsDocumentInProject(documentMoniker, out int isFound, priority, out uint itemId);
            if (result.Failed)
                throw result.Exception;
            if (isFound == 0 || priority[0] != VSDOCUMENTPRIORITY.DP_Standard && priority[0] != VSDOCUMENTPRIORITY.DP_Intrinsic)
                return HierarchyId.Nil;
            HierarchyId id = itemId;
            Assumes.False(id.IsNilOrEmpty);
            return id;
        }
public static HierarchyId GetHierarchyId ( this IVsProject project , string documentMoniker ) { Requires . NotNull ( project , nameof ( project ) ) ; Requires . NotNullOrEmpty ( documentMoniker , nameof ( documentMoniker ) ) ; var priority = new VSDOCUMENTPRIORITY [ 1 ] ; HResult result = project . IsDocumentInProject ( documentMoniker , out int isFound , priority , out uint itemId ) ; if ( result . Failed ) throw result . Exception ; if ( isFound == 0 || priority [ 0 ] != VSDOCUMENTPRIORITY . DP_Standard && priority [ 0 ] != VSDOCUMENTPRIORITY . DP_Intrinsic ) return HierarchyId . Nil ; HierarchyId id = itemId ; Assumes . False ( id . IsNilOrEmpty ) ; return id ; }
Returns the  of the given document moniker, or
if the document moniker is not part of the project.
Returns the of the given document moniker or if the document moniker is not part of the project .
// We only return items that are actually part of the project. CPS returns non-member from this API.
IVsProject
this
documentMoniker
string