public async Task <GraphBuilder> GetGraphAsync(Solution solution, IGraphContext context, CancellationToken cancellationToken)
        {
            using (Logger.LogBlock(FunctionId.GraphQuery_Overrides, KeyValueLogMessage.Create(LogType.UserAction), cancellationToken))
            {
                var graphBuilder = await GraphBuilder.CreateForInputNodesAsync(solution, context.InputNodes, cancellationToken).ConfigureAwait(false);

                foreach (var node in context.InputNodes)
                {
                    var symbol = graphBuilder.GetSymbol(node);
                    if (symbol is IMethodSymbol ||
                        symbol is IPropertySymbol ||
                        symbol is IEventSymbol)
                    {
                        var overrides = await SymbolFinder.FindOverridesAsync(symbol, solution, cancellationToken : cancellationToken).ConfigureAwait(false);

                        foreach (var o in overrides)
                        {
                            var symbolNode = await graphBuilder.AddNodeAsync(o, relatedNode : node).ConfigureAwait(false);

                            graphBuilder.AddLink(symbolNode, RoslynGraphCategories.Overrides, node);
                        }
                    }
                }

                return(graphBuilder);
            }
        }
示例#2
0
        public async Task <GraphBuilder> GetGraphAsync(Solution solution, IGraphContext context, CancellationToken cancellationToken)
        {
            using (Logger.LogBlock(FunctionId.GraphQuery_Implements, KeyValueLogMessage.Create(LogType.UserAction), cancellationToken))
            {
                var graphBuilder = await GraphBuilder.CreateForInputNodesAsync(solution, context.InputNodes, cancellationToken).ConfigureAwait(false);

                foreach (var node in context.InputNodes)
                {
                    var symbol = graphBuilder.GetSymbol(node);
                    if (symbol is INamedTypeSymbol namedType)
                    {
                        var implementedSymbols = namedType.AllInterfaces;

                        await AddImplementedSymbolsAsync(graphBuilder, node, implementedSymbols).ConfigureAwait(false);
                    }
                    else if (symbol is IMethodSymbol || symbol is IPropertySymbol || symbol is IEventSymbol)
                    {
                        var implements = await SymbolFinder.FindImplementedInterfaceMembersAsync(symbol, solution, cancellationToken : cancellationToken).ConfigureAwait(false);
                        await AddImplementedSymbolsAsync(graphBuilder, node, implements).ConfigureAwait(false);
                    }
                }

                return(graphBuilder);
            }
        }
示例#3
0
        public async Task <GraphBuilder> GetGraphAsync(Solution solution, IGraphContext context, CancellationToken cancellationToken)
        {
            using (Logger.LogBlock(FunctionId.GraphQuery_ImplementedBy, KeyValueLogMessage.Create(LogType.UserAction), cancellationToken))
            {
                var graphBuilder = await GraphBuilder.CreateForInputNodesAsync(solution, context.InputNodes, cancellationToken).ConfigureAwait(false);

                foreach (var node in context.InputNodes)
                {
                    var symbol = graphBuilder.GetSymbolAndProjectId(node);
                    if (symbol.Symbol is INamedTypeSymbol ||
                        symbol.Symbol is IMethodSymbol ||
                        symbol.Symbol is IPropertySymbol ||
                        symbol.Symbol is IEventSymbol)
                    {
                        var implementations = await SymbolFinder.FindImplementationsAsync(symbol, solution, cancellationToken : cancellationToken).ConfigureAwait(false);

                        foreach (var implementation in implementations)
                        {
                            var symbolNode = await graphBuilder.AddNodeAsync(implementation, relatedNode : node).ConfigureAwait(false);

                            graphBuilder.AddLink(symbolNode, CodeLinkCategories.Implements, node);
                        }
                    }
                }

                return(graphBuilder);
            }
        }
示例#4
0
        public async Task <GraphBuilder> GetGraphAsync(Solution solution, IGraphContext context, CancellationToken cancellationToken)
        {
            using (Logger.LogBlock(FunctionId.GraphQuery_IsCalledBy, KeyValueLogMessage.Create(LogType.UserAction), cancellationToken))
            {
                var graphBuilder = await GraphBuilder.CreateForInputNodesAsync(solution, context.InputNodes, cancellationToken).ConfigureAwait(false);

                foreach (var node in context.InputNodes)
                {
                    var symbol = graphBuilder.GetSymbol(node);
                    if (symbol != null)
                    {
                        var callers = await SymbolFinder.FindCallersAsync(symbol, solution, cancellationToken).ConfigureAwait(false);

                        foreach (var caller in callers.Where(c => c.IsDirect))
                        {
                            var callerNode = await graphBuilder.AddNodeForSymbolAsync(caller.CallingSymbol, relatedNode : node).ConfigureAwait(false);

                            graphBuilder.AddLink(callerNode, CodeLinkCategories.Calls, node);
                        }
                    }
                }

                return(graphBuilder);
            }
        }
示例#5
0
        public async Task <GraphBuilder> GetGraphAsync(
            Solution solution,
            IGraphContext context,
            CancellationToken cancellationToken
            )
        {
            var graphBuilder = await GraphBuilder
                               .CreateForInputNodesAsync(solution, context.InputNodes, cancellationToken)
                               .ConfigureAwait(false);

            foreach (var node in context.InputNodes)
            {
                var symbol = graphBuilder.GetSymbol(node);
                if (symbol != null)
                {
                    var overriddenMember = symbol.GetOverriddenMember();
                    if (overriddenMember != null)
                    {
                        var symbolNode = await graphBuilder
                                         .AddNodeAsync(overriddenMember, relatedNode : node)
                                         .ConfigureAwait(false);

                        graphBuilder.AddLink(node, RoslynGraphCategories.Overrides, symbolNode);
                    }
                }
            }

            return(graphBuilder);
        }
示例#6
0
        public async Task <GraphBuilder> GetGraphAsync(Solution solution, IGraphContext context, CancellationToken cancellationToken)
        {
            using (Logger.LogBlock(FunctionId.GraphQuery_IsUsedBy, KeyValueLogMessage.Create(LogType.UserAction), cancellationToken))
            {
                var graphBuilder = await GraphBuilder.CreateForInputNodesAsync(solution, context.InputNodes, cancellationToken).ConfigureAwait(false);

                foreach (var node in context.InputNodes)
                {
                    var symbol     = graphBuilder.GetSymbol(node, cancellationToken);
                    var references = await SymbolFinder.FindReferencesAsync(symbol, solution, cancellationToken).ConfigureAwait(false);

                    foreach (var reference in references)
                    {
                        var referencedSymbol = reference.Definition;
                        var projectId        = graphBuilder.GetContextProject(node, cancellationToken).Id;

                        var allLocations = referencedSymbol.Locations.Concat(reference.Locations.Select(r => r.Location))
                                           .Where(l => l != null && l.IsInSource);

                        foreach (var location in allLocations)
                        {
                            var locationNode = GetLocationNode(location, context, projectId, cancellationToken);
                            graphBuilder.AddLink(node, CodeLinkCategories.SourceReferences, locationNode, cancellationToken);
                        }
                    }
                }

                return(graphBuilder);
            }
        }
        public async Task <GraphBuilder> GetGraphAsync(Solution solution, IGraphContext context, CancellationToken cancellationToken)
        {
            var graphBuilder = await GraphBuilder.CreateForInputNodesAsync(solution, context.InputNodes, cancellationToken).ConfigureAwait(false);

            foreach (var node in context.InputNodes)
            {
                if (!cancellationToken.IsCancellationRequested)
                {
                    var symbol = graphBuilder.GetSymbol(node);

                    if (symbol != null)
                    {
                        bool containsChildren = SymbolContainment.GetContainedSymbols(symbol).Any();
                        graphBuilder.AddDeferredPropertySet(node, DgmlNodeProperties.ContainsChildren, containsChildren);
                    }
                    else if (node.HasCategory(CodeNodeCategories.File))
                    {
                        var document = graphBuilder.GetContextDocument(node);

                        if (document != null)
                        {
                            var childNodes = await SymbolContainment.GetContainedSyntaxNodesAsync(document, cancellationToken).ConfigureAwait(false);

                            graphBuilder.AddDeferredPropertySet(node, DgmlNodeProperties.ContainsChildren, childNodes.Any());
                        }
                        else
                        {
                            var uri = node.Id.GetNestedValueByName <Uri>(CodeGraphNodeIdName.File);

                            if (uri != null)
                            {
                                // Since a solution load is not yet completed, there is no document available to answer this query.
                                // The solution explorer presumes that if somebody doesn't answer for a file, they never will.
                                // See Providers\GraphContextAttachedCollectionSource.cs for more. Therefore we should answer by setting
                                // ContainsChildren property to either true or false, so any following updates will be tractable.
                                // We will set it to false since the solution explorer assumes the default for this query response is 'false'.

                                // Todo: we may need fallback to check if this node actually represents a C# or VB language
                                // even when its extension fails to say so. One option would be to call DTEWrapper.IsRegisteredForLangService,
                                // which may not be called here however since deadlock could happen.

                                // The Uri returned by `GetNestedValueByName()` above isn't necessarily absolute and the `OriginalString` is
                                // the only property that doesn't throw if the UriKind is relative, so `OriginalString` must be used instead
                                // of `AbsolutePath`.
                                string ext = Path.GetExtension(uri.OriginalString);
                                if (ext.Equals(".cs", StringComparison.OrdinalIgnoreCase) || ext.Equals(".vb", StringComparison.OrdinalIgnoreCase))
                                {
                                    graphBuilder.AddDeferredPropertySet(node, DgmlNodeProperties.ContainsChildren, false);
                                }
                            }
                        }
                    }
                }
            }

            return(graphBuilder);
        }
示例#8
0
        public async Task <GraphBuilder> GetGraphAsync(Solution solution, IGraphContext context, CancellationToken cancellationToken)
        {
            var graphBuilder = await GraphBuilder.CreateForInputNodesAsync(solution, context.InputNodes, cancellationToken).ConfigureAwait(false);

            var searchTasks = solution.Projects.Select(p => ProcessProjectAsync(p, graphBuilder, cancellationToken)).ToArray();
            await Task.WhenAll(searchTasks).ConfigureAwait(false);

            return(graphBuilder);
        }
示例#9
0
        private async Task <GraphBuilder> SearchUsingSymbolsAsync(Solution solution, IGraphContext context, CancellationToken cancellationToken)
        {
            var graphBuilder = await GraphBuilder.CreateForInputNodesAsync(solution, context.InputNodes, cancellationToken).ConfigureAwait(false);

            var searchTasks = solution.Projects
                              .Where(p => p.FilePath != null)
                              .Select(p => ProcessProjectAsync(p, graphBuilder, cancellationToken))
                              .ToArray();
            await Task.WhenAll(searchTasks).ConfigureAwait(false);

            return(graphBuilder);
        }
示例#10
0
        public async Task <GraphBuilder> GetGraphAsync(Solution solution, IGraphContext context, CancellationToken cancellationToken)
        {
            var graphBuilder = await GraphBuilder.CreateForInputNodesAsync(solution, context.InputNodes, cancellationToken).ConfigureAwait(false);

            var nodesToProcess = context.InputNodes;

            for (var depth = 0; depth < context.LinkDepth; depth++)
            {
                // This is the list of nodes we created and will process
                var newNodes = new HashSet <GraphNode>();

                foreach (var node in nodesToProcess)
                {
                    cancellationToken.ThrowIfCancellationRequested();

                    var symbol = graphBuilder.GetSymbol(node);

                    if (symbol != null)
                    {
                        foreach (var newSymbol in SymbolContainment.GetContainedSymbols(symbol))
                        {
                            cancellationToken.ThrowIfCancellationRequested();

                            var newNode = await graphBuilder.AddNodeForSymbolAsync(newSymbol, relatedNode : node).ConfigureAwait(false);

                            graphBuilder.AddLink(node, GraphCommonSchema.Contains, newNode);
                        }
                    }
                    else if (node.HasCategory(CodeNodeCategories.File))
                    {
                        var document = graphBuilder.GetContextDocument(node);

                        if (document != null)
                        {
                            foreach (var newSymbol in await SymbolContainment.GetContainedSymbolsAsync(document, cancellationToken).ConfigureAwait(false))
                            {
                                cancellationToken.ThrowIfCancellationRequested();

                                var newNode = await graphBuilder.AddNodeForSymbolAsync(newSymbol, relatedNode : node).ConfigureAwait(false);

                                graphBuilder.AddLink(node, GraphCommonSchema.Contains, newNode);
                            }
                        }
                    }
                }

                nodesToProcess = newNodes;
            }

            return(graphBuilder);
        }
示例#11
0
        public async Task <GraphBuilder> GetGraphAsync(Solution solution, IGraphContext context, CancellationToken cancellationToken)
        {
            var graphBuilder = await GraphBuilder.CreateForInputNodesAsync(solution, context.InputNodes, cancellationToken).ConfigureAwait(false);

            var callback = new ProgressionNavigateToSearchCallback(context, graphBuilder);
            var searcher = NavigateToSearcher.Create(
                solution,
                _asyncListener,
                callback,
                _searchPattern,
                NavigateToUtilities.GetKindsProvided(solution),
                _threadingContext.DisposalToken);

            await searcher.SearchAsync(searchCurrentDocument : false, cancellationToken).ConfigureAwait(false);

            return(graphBuilder);
        }
示例#12
0
        public async Task <GraphBuilder> GetGraphAsync(Solution solution, IGraphContext context, CancellationToken cancellationToken)
        {
            var graphBuilder = await GraphBuilder.CreateForInputNodesAsync(solution, context.InputNodes, cancellationToken).ConfigureAwait(false);

            foreach (var node in context.InputNodes)
            {
                var symbol = graphBuilder.GetSymbol(node, cancellationToken);
                if (symbol is not INamedTypeSymbol namedType)
                {
                    continue;
                }

                if (namedType.TypeKind == TypeKind.Class)
                {
                    var derivedTypes = await SymbolFinder.FindDerivedClassesArrayAsync(
                        namedType, solution, transitive : false, cancellationToken : cancellationToken).ConfigureAwait(false);

                    foreach (var derivedType in derivedTypes)
                    {
                        var symbolNode = await graphBuilder.AddNodeAsync(
                            derivedType, relatedNode : node, cancellationToken).ConfigureAwait(false);

                        graphBuilder.AddLink(symbolNode, CodeLinkCategories.InheritsFrom, node, cancellationToken);
                    }
                }
                else if (namedType.TypeKind == TypeKind.Interface)
                {
                    var implementingClassesAndStructs = await SymbolFinder.FindImplementationsArrayAsync(
                        namedType, solution, transitive : false, cancellationToken : cancellationToken).ConfigureAwait(false);

                    var derivedInterfaces = await SymbolFinder.FindDerivedInterfacesArrayAsync(
                        namedType, solution, transitive : false, cancellationToken : cancellationToken).ConfigureAwait(false);

                    foreach (var derivedType in implementingClassesAndStructs.Concat(derivedInterfaces))
                    {
                        var symbolNode = await graphBuilder.AddNodeAsync(
                            derivedType, relatedNode : node, cancellationToken).ConfigureAwait(false);

                        graphBuilder.AddLink(symbolNode, CodeLinkCategories.InheritsFrom, node, cancellationToken);
                    }
                }
            }

            return(graphBuilder);
        }
示例#13
0
        public async Task <GraphBuilder> GetGraphAsync(Solution solution, IGraphContext context, CancellationToken cancellationToken)
        {
            var graphBuilder = await GraphBuilder.CreateForInputNodesAsync(solution, context.InputNodes, cancellationToken).ConfigureAwait(false);

            var nodesToProcess = context.InputNodes;

            for (var depth = 0; depth < context.LinkDepth; depth++)
            {
                // This is the list of nodes we created and will process
                var newNodes = new HashSet <GraphNode>();

                foreach (var node in nodesToProcess)
                {
                    var symbol = graphBuilder.GetSymbol(node, cancellationToken);
                    if (symbol is INamedTypeSymbol namedType)
                    {
                        if (namedType.BaseType != null)
                        {
                            var baseTypeNode = await graphBuilder.AddNodeAsync(
                                namedType.BaseType, relatedNode : node, cancellationToken).ConfigureAwait(false);

                            newNodes.Add(baseTypeNode);
                            graphBuilder.AddLink(node, CodeLinkCategories.InheritsFrom, baseTypeNode, cancellationToken);
                        }
                        else if (namedType.TypeKind == TypeKind.Interface && !namedType.OriginalDefinition.AllInterfaces.IsEmpty)
                        {
                            foreach (var baseNode in namedType.OriginalDefinition.AllInterfaces.Distinct())
                            {
                                var baseTypeNode = await graphBuilder.AddNodeAsync(
                                    baseNode, relatedNode : node, cancellationToken).ConfigureAwait(false);

                                newNodes.Add(baseTypeNode);
                                graphBuilder.AddLink(node, CodeLinkCategories.InheritsFrom, baseTypeNode, cancellationToken);
                            }
                        }
                    }
                }

                nodesToProcess = newNodes;
            }

            return(graphBuilder);
        }
        public async Task <GraphBuilder> GetGraphAsync(Solution solution, IGraphContext context, CancellationToken cancellationToken)
        {
            var graphBuilder = await GraphBuilder.CreateForInputNodesAsync(solution, context.InputNodes, cancellationToken).ConfigureAwait(false);

            foreach (var node in context.InputNodes)
            {
                var symbol = graphBuilder.GetSymbol(node);
                if (!(symbol is INamedTypeSymbol namedType))
                {
                    continue;
                }

                if (namedType.TypeKind == TypeKind.Class)
                {
                    var derivedTypes = await DependentTypeFinder.FindImmediatelyDerivedClassesAsync(
                        namedType, solution, cancellationToken).ConfigureAwait(false);

                    foreach (var derivedType in derivedTypes)
                    {
                        var symbolNode = await graphBuilder.AddNodeAsync(
                            derivedType, relatedNode : node).ConfigureAwait(false);

                        graphBuilder.AddLink(symbolNode, CodeLinkCategories.InheritsFrom, node);
                    }
                }
                else if (namedType.TypeKind == TypeKind.Interface)
                {
                    var derivedTypes = await DependentTypeFinder.FindImmediatelyDerivedAndImplementingTypesAsync(
                        namedType, solution, cancellationToken).ConfigureAwait(false);

                    foreach (var derivedType in derivedTypes)
                    {
                        var symbolNode = await graphBuilder.AddNodeAsync(
                            derivedType, relatedNode : node).ConfigureAwait(false);

                        graphBuilder.AddLink(symbolNode, CodeLinkCategories.InheritsFrom, node);
                    }
                }
            }

            return(graphBuilder);
        }
示例#15
0
        public async Task <GraphBuilder> GetGraphAsync(Solution solution, IGraphContext context, CancellationToken cancellationToken)
        {
            var graphBuilder = await GraphBuilder.CreateForInputNodesAsync(solution, context.InputNodes, cancellationToken).ConfigureAwait(false);

            foreach (var node in context.InputNodes)
            {
                var symbol = graphBuilder.GetSymbol(node);
                if (symbol is INamedTypeSymbol || symbol is IMethodSymbol || symbol is IPropertySymbol || symbol is IEventSymbol)
                {
                    var implementations = await SymbolFinder.FindImplementationsAsync(symbol, solution, cancellationToken : cancellationToken).ConfigureAwait(false);

                    foreach (var implementation in implementations)
                    {
                        var symbolNode = await graphBuilder.AddNodeForSymbolAsync(implementation, relatedNode : node).ConfigureAwait(false);

                        graphBuilder.AddLink(symbolNode, CodeLinkCategories.Implements, node);
                    }
                }
            }

            return(graphBuilder);
        }
示例#16
0
        public async Task <GraphBuilder> GetGraphAsync(Solution solution, IGraphContext context, CancellationToken cancellationToken)
        {
            var graphBuilder = await GraphBuilder.CreateForInputNodesAsync(solution, context.InputNodes, cancellationToken).ConfigureAwait(false);

            foreach (var node in context.InputNodes)
            {
                var symbol = graphBuilder.GetSymbol(node);
                if (symbol is IMethodSymbol || symbol is IPropertySymbol || symbol is IEventSymbol)
                {
                    var overrides = await SymbolFinder.FindOverridesAsync(symbol, solution, cancellationToken : cancellationToken).ConfigureAwait(false);

                    foreach (var o in overrides)
                    {
                        var symbolNode = await graphBuilder.AddNodeForSymbolAsync(o, relatedNode : node).ConfigureAwait(false);

                        graphBuilder.AddLink(symbolNode, RoslynGraphCategories.Overrides, node);
                    }
                }
            }

            return(graphBuilder);
        }
示例#17
0
        public async Task <GraphBuilder> GetGraphAsync(Solution solution, IGraphContext context, CancellationToken cancellationToken)
        {
            var graphBuilder = await GraphBuilder.CreateForInputNodesAsync(solution, context.InputNodes, cancellationToken).ConfigureAwait(false);

            foreach (var node in context.InputNodes)
            {
                var symbol = graphBuilder.GetSymbol(node);
                if (symbol != null)
                {
                    var callers = await SymbolFinder.FindCallersAsync(symbol, solution, cancellationToken).ConfigureAwait(false);

                    foreach (var caller in callers.Where(c => c.IsDirect))
                    {
                        var callerNode = await graphBuilder.AddNodeForSymbolAsync(caller.CallingSymbol, relatedNode : node).ConfigureAwait(false);

                        graphBuilder.AddLink(callerNode, CodeLinkCategories.Calls, node);
                    }
                }
            }

            return(graphBuilder);
        }
示例#18
0
        public async Task <GraphBuilder> GetGraphAsync(Solution solution, IGraphContext context, CancellationToken cancellationToken)
        {
            var graphBuilder = await GraphBuilder.CreateForInputNodesAsync(solution, context.InputNodes, cancellationToken).ConfigureAwait(false);

            foreach (var node in context.InputNodes)
            {
                var symbol = graphBuilder.GetSymbol(node);
                if (symbol != null)
                {
                    foreach (var newSymbol in await GetCalledMethodSymbolsAsync(symbol, solution, cancellationToken).ConfigureAwait(false))
                    {
                        cancellationToken.ThrowIfCancellationRequested();

                        var newNode = await graphBuilder.AddNodeForSymbolAsync(newSymbol, relatedNode : node).ConfigureAwait(false);

                        graphBuilder.AddLink(node, CodeLinkCategories.Calls, newNode);
                    }
                }
            }

            return(graphBuilder);
        }
示例#19
0
        public async Task <GraphBuilder> GetGraphAsync(Solution solution, IGraphContext context, CancellationToken cancellationToken)
        {
            var graphBuilder = await GraphBuilder.CreateForInputNodesAsync(solution, context.InputNodes, cancellationToken).ConfigureAwait(false);

            foreach (var node in context.InputNodes)
            {
                var symbol = graphBuilder.GetSymbol(node);
                if (symbol is INamedTypeSymbol)
                {
                    var namedType          = (INamedTypeSymbol)symbol;
                    var implementedSymbols = namedType.AllInterfaces;

                    await AddImplementedSymbols(graphBuilder, node, implementedSymbols).ConfigureAwait(false);
                }
                else if (symbol is IMethodSymbol || symbol is IPropertySymbol || symbol is IEventSymbol)
                {
                    var implements = await SymbolFinder.FindImplementedInterfaceMembersAsync(symbol, solution, cancellationToken : cancellationToken).ConfigureAwait(false);
                    await AddImplementedSymbols(graphBuilder, node, implements).ConfigureAwait(false);
                }
            }

            return(graphBuilder);
        }
示例#20
0
        public async Task <GraphBuilder> GetGraphAsync(Solution solution, IGraphContext context, CancellationToken cancellationToken)
        {
            var graphBuilder = await GraphBuilder.CreateForInputNodesAsync(solution, context.InputNodes, cancellationToken).ConfigureAwait(false);

            foreach (var node in context.InputNodes)
            {
                if (!cancellationToken.IsCancellationRequested)
                {
                    var symbol = graphBuilder.GetSymbol(node);

                    if (symbol != null)
                    {
                        var containsChildren = SymbolContainment.GetContainedSymbols(symbol).Any();
                        graphBuilder.AddDeferredPropertySet(node, DgmlNodeProperties.ContainsChildren, containsChildren);
                    }
                    else if (node.HasCategory(CodeNodeCategories.File))
                    {
                        var document = graphBuilder.GetContextDocument(node);

                        if (document != null)
                        {
                            var childNodes = await SymbolContainment.GetContainedSyntaxNodesAsync(document, cancellationToken).ConfigureAwait(false);

                            graphBuilder.AddDeferredPropertySet(node, DgmlNodeProperties.ContainsChildren, childNodes.Any());
                        }
                        else
                        {
                            var uri = node.Id.GetNestedValueByName <Uri>(CodeGraphNodeIdName.File);
                            if (uri != null)
                            {
                                // Since a solution load is not yet completed, there is no document available to answer this query.
                                // The solution explorer presumes that if somebody doesn't answer for a file, they never will.
                                // See Providers\GraphContextAttachedCollectionSource.cs for more. Therefore we should answer by setting
                                // ContainsChildren property to either true or false, so any following updates will be tractable.
                                // We will set it to false since the solution explorer assumes the default for this query response is 'false'.

                                // Todo: we may need fallback to check if this node actually represents a C# or VB language
                                // even when its extension fails to say so. One option would be to call DTEWrapper.IsRegisteredForLangService,
                                // which may not be called here however since deadlock could happen.

                                // The Uri returned by `GetNestedValueByName()` above isn't necessarily absolute and the `OriginalString` is
                                // the only property that doesn't throw if the UriKind is relative, so `OriginalString` must be used instead
                                // of `AbsolutePath`.
                                var path = uri.OriginalString;

                                // Recorded in https://github.com/dotnet/roslyn/issues/27805, we
                                // have seen crashes because the URI in the graph node has the
                                // following form, including the quotes (which are invalid path
                                // characters):
                                //     C:\path\to\"some path\App.config"
                                // So we avoid calling Path.GetExtension here. Alternatively, we
                                // could check for illegal path characters directly first, but then
                                // that check would actually happen twice because GetExtension will
                                // also perform the check.
                                if (path.EndsWith(".cs", StringComparison.OrdinalIgnoreCase) || path.EndsWith(".vb", StringComparison.OrdinalIgnoreCase))
                                {
                                    graphBuilder.AddDeferredPropertySet(node, DgmlNodeProperties.ContainsChildren, false);
                                }
                            }
                        }
                    }
                }
            }

            return(graphBuilder);
        }