Repository: dotnet/roslyn
File: src/VisualStudio/Core/Impl/SolutionExplorer/SymbolTree/RootSymbolTreeItemSourceProvider.cs (C#)

Code before:
            {
                if (_filePathToCollectionSources.TryGetValue(filePath, out var pathSources))
                    sources.AddRange(pathSources);
            }
        }

        // Update all the affected documents in parallel.
        await Parallel.ForEachAsync(
            sources,
            cancellationToken,
            async (source, cancellationToken) =>
            {
                await source.UpdateIfEverBeenAskedToComputeAsync(cancellationToken)
                    .ReportNonFatalErrorUnlessCancelledAsync(cancellationToken)
                    .ConfigureAwait(false);
            }).ConfigureAwait(false);
    }

    protected override IAttachedCollectionSource? CreateCollectionSource(IVsHierarchyItem item, string relationshipName)
    {
        if (item == null ||
            item.IsDisposed ||
            item.HierarchyIdentity == null ||
            item.HierarchyIdentity.NestedHierarchy == null ||
            relationshipName != KnownRelationships.Contains)
        {
            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 the event doesn't
        // contain the old value).  
        if (item.CanonicalName is not string currentFilePath)
            return null;

        if (item.HierarchyIdentity.NestedHierarchy.GetGuidProperty(
                item.HierarchyIdentity.NestedItemID,
                (int)__VSHPROPID.VSHPROPID_TypeGuid,
                out var guid) != VSConstants.S_OK)
        {
            return null;
        }

        // 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);
        lock (_filePathToCollectionSources)

Review comment (suggestion):
This should be renamed IsEnabled... since it's very confusing with some of the double negatives going on here.

Code after:
        ImmutableSegmentedList<string> updatedFilePaths, CancellationToken cancellationToken)
    {
        using var _ = Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder<RootSymbolTreeItemCollectionSource>.GetInstance(out var sources);

        lock (_filePathToCollectionSources)
        {
            foreach (var filePath in updatedFilePaths)
            {
                if (_filePathToCollectionSources.TryGetValue(filePath, out var pathSources))
                    sources.AddRange(pathSources);
            }
        }

        // Update all the affected documents in parallel.
        await Parallel.ForEachAsync(
            sources,
            cancellationToken,
            async (source, cancellationToken) =>
            {
                await source.UpdateIfEverBeenAskedToComputeAsync(cancellationToken)
                    .ReportNonFatalErrorUnlessCancelledAsync(cancellationToken)
                    .ConfigureAwait(false);
            }).ConfigureAwait(false);
    }

    private bool IsDisabled
    {
        get
        {
            return _disabled ??= ComputeIsDisabled();

            bool ComputeIsDisabled()
            {
                try
                {
                    var settingsManager = RoslynServiceExtensions.GetService<SVsUnifiedSettingsManager, ISettingsManager>(
                        _serviceProvider, ThreadingContext.JoinableTaskFactory);

                    // Key provided by the Solution Explorer team.
                    var setting = settingsManager.GetReader().GetValue<bool>("projectsAndSolutions.general.showLanguageSymbolsInsideSolutionExplorerFiles");

                    // Only if we can actually read the value successfully, and it is false, are we disabled.
                    // In all other circumstances (value missing, error reading, value true), we are enabled.
                    return setting.Outcome == SettingRetrievalOutcome.Success && !setting.Value;
                }
                catch (Exception ex) when (FatalError.ReportAndCatch(ex))
                {
                    // On any error reading from unified settings, just assume we're not disabled.
                    return false;
                }
            }