Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usage of Linq from analyzer driver #76732

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using Microsoft.CodeAnalysis.Collections;

namespace Microsoft.CodeAnalysis.Diagnostics
Expand All @@ -16,6 +15,9 @@ private sealed class GroupedAnalyzerActionsForAnalyzer
private readonly DiagnosticAnalyzer _analyzer;
private readonly bool _analyzerActionsNeedFiltering;

/// <summary>
/// Represented as a dictionary
/// </summary>
CyrusNajmabadi marked this conversation as resolved.
Show resolved Hide resolved
private ImmutableSegmentedDictionary<TLanguageKindEnum, ImmutableArray<SyntaxNodeAnalyzerAction<TLanguageKindEnum>>> _lazyNodeActionsByKind;
private ImmutableSegmentedDictionary<OperationKind, ImmutableArray<OperationAnalyzerAction>> _lazyOperationActionsByKind;
private ImmutableArray<CodeBlockStartAnalyzerAction<TLanguageKindEnum>> _lazyCodeBlockStartActions;
Expand Down Expand Up @@ -74,9 +76,9 @@ public ImmutableSegmentedDictionary<TLanguageKindEnum, ImmutableArray<SyntaxNode
AnalyzerActions.GetSyntaxNodeActions<TLanguageKindEnum>(_analyzer) :
AnalyzerActions.GetSyntaxNodeActions<TLanguageKindEnum>();
VerifyActions(nodeActions, _analyzer);
var analyzerActionsByKind = !nodeActions.IsEmpty ?
AnalyzerExecutor.GetNodeActionsByKind(nodeActions) :
ImmutableSegmentedDictionary<TLanguageKindEnum, ImmutableArray<SyntaxNodeAnalyzerAction<TLanguageKindEnum>>>.Empty;
var analyzerActionsByKind = !nodeActions.IsEmpty
? AnalyzerExecutor.GetNodeActionsByKind(nodeActions)
: ImmutableSegmentedDictionary<TLanguageKindEnum, ImmutableArray<SyntaxNodeAnalyzerAction<TLanguageKindEnum>>>.Empty;
RoslynImmutableInterlocked.InterlockedInitialize(ref _lazyNodeActionsByKind, analyzerActionsByKind);
}

Expand All @@ -92,9 +94,9 @@ public ImmutableSegmentedDictionary<OperationKind, ImmutableArray<OperationAnaly
{
var operationActions = GetFilteredActions(AnalyzerActions.OperationActions);
VerifyActions(operationActions, _analyzer);
var analyzerActionsByKind = operationActions.Any() ?
AnalyzerExecutor.GetOperationActionsByKind(operationActions) :
ImmutableSegmentedDictionary<OperationKind, ImmutableArray<OperationAnalyzerAction>>.Empty;
var analyzerActionsByKind = operationActions.Length > 0
? AnalyzerExecutor.GetOperationActionsByKind(operationActions)
: ImmutableSegmentedDictionary<OperationKind, ImmutableArray<OperationAnalyzerAction>>.Empty;
RoslynImmutableInterlocked.InterlockedInitialize(ref _lazyOperationActionsByKind, analyzerActionsByKind);
}

Expand Down
Loading