4 instantiations of ImmutableHashSet
System.Collections.Immutable (4)
4095 references to ImmutableHashSet
Analyzer.Utilities.UnitTests (1)
AnalyzerRunner (11)
Aspire.Dashboard (2)
Aspire.Hosting (2)
BuildActionTelemetryTable (1)
GenerateDocumentationAndConfigFiles (133)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\IDictionaryExtensions.cs (7)
100public static bool MultiAdd<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value, IEqualityComparer<TValue>? comparer = null)
103if (dictionary.TryGetValue(key, out var set))
105var updated = set.Add(value);
158public static ImmutableDictionary<TKey, ImmutableHashSet<TValue>> MultiRemove<TKey, TValue>(this ImmutableDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
161if (dictionary.TryGetValue(key, out var collection))
200public static void MultiRemove<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
IdeCoreBenchmarks (3)
Metrics (185)
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\ComputationalComplexityMetrics.cs (36)
25internal static readonly ComputationalComplexityMetrics Default = new(0, 0, 0, 0, 0, ImmutableHashSet<OperationKind>.Empty,
26ImmutableHashSet<BinaryOperatorKind>.Empty, ImmutableHashSet<UnaryOperatorKind>.Empty, ImmutableHashSet<CaseKind>.Empty, ImmutableHashSet<ISymbol>.Empty, ImmutableHashSet<object>.Empty);
30private readonly ImmutableHashSet<OperationKind> _distinctOperatorKinds;
31private readonly ImmutableHashSet<BinaryOperatorKind> _distinctBinaryOperatorKinds;
32private readonly ImmutableHashSet<UnaryOperatorKind> _distinctUnaryOperatorKinds;
33private readonly ImmutableHashSet<CaseKind> _distinctCaseKinds;
34private readonly ImmutableHashSet<ISymbol> _distinctReferencedSymbols;
35private readonly ImmutableHashSet<object> _distinctReferencedConstants;
43ImmutableHashSet<OperationKind> distinctOperatorKinds,
44ImmutableHashSet<BinaryOperatorKind> distinctBinaryOperatorKinds,
45ImmutableHashSet<UnaryOperatorKind> distinctUnaryOperatorKinds,
46ImmutableHashSet<CaseKind> distinctCaseKinds,
47ImmutableHashSet<ISymbol> distinctReferencedSymbols,
48ImmutableHashSet<object> distinctReferencedConstants)
69ImmutableHashSet<OperationKind> distinctOperatorKinds,
70ImmutableHashSet<BinaryOperatorKind> distinctBinaryOperatorKinds,
71ImmutableHashSet<UnaryOperatorKind> distinctUnaryOperatorKinds,
72ImmutableHashSet<CaseKind> distinctCaseKinds,
73ImmutableHashSet<ISymbol> distinctReferencedSymbols,
74ImmutableHashSet<object> distinctReferencedConstants)
95ImmutableHashSet<OperationKind>.Builder? distinctOperatorKindsBuilder = null;
96ImmutableHashSet<BinaryOperatorKind>.Builder? distinctBinaryOperatorKindsBuilder = null;
97ImmutableHashSet<UnaryOperatorKind>.Builder? distinctUnaryOperatorKindsBuilder = null;
98ImmutableHashSet<CaseKind>.Builder? distinctCaseKindsBuilder = null;
99ImmutableHashSet<ISymbol>.Builder? distinctReferencedSymbolsBuilder = null;
100ImmutableHashSet<object>.Builder? distinctReferencedConstantsBuilder = null;
290distinctOperatorKindsBuilder != null ? distinctOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<OperationKind>.Empty,
291distinctBinaryOperatorKindsBuilder != null ? distinctBinaryOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<BinaryOperatorKind>.Empty,
292distinctUnaryOperatorKindsBuilder != null ? distinctUnaryOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<UnaryOperatorKind>.Empty,
293distinctCaseKindsBuilder != null ? distinctCaseKindsBuilder.ToImmutable() : ImmutableHashSet<CaseKind>.Empty,
294distinctReferencedSymbolsBuilder != null ? distinctReferencedSymbolsBuilder.ToImmutable() : ImmutableHashSet<ISymbol>.Empty,
295distinctReferencedConstantsBuilder != null ? distinctReferencedConstantsBuilder.ToImmutable() : ImmutableHashSet<object>.Empty);
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (7)
39internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
40ImmutableHashSet<INamedTypeSymbol> coupledTypes)
48internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
54internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
195ImmutableHashSet<INamedTypeSymbol>.Builder builder,
349private static void AddCoupledNamedTypesCore(ImmutableHashSet<INamedTypeSymbol>.Builder builder, ITypeSymbol typeOpt,
400internal static void RemoveContainingTypes(ISymbol symbol, ImmutableHashSet<INamedTypeSymbol>.Builder coupledTypesBuilder)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\IDictionaryExtensions.cs (7)
100public static bool MultiAdd<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value, IEqualityComparer<TValue>? comparer = null)
103if (dictionary.TryGetValue(key, out var set))
105var updated = set.Add(value);
158public static ImmutableDictionary<TKey, ImmutableHashSet<TValue>> MultiRemove<TKey, TValue>(this ImmutableDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
161if (dictionary.TryGetValue(key, out var collection))
200public static void MultiRemove<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
Metrics.Legacy (185)
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\ComputationalComplexityMetrics.cs (36)
25internal static readonly ComputationalComplexityMetrics Default = new(0, 0, 0, 0, 0, ImmutableHashSet<OperationKind>.Empty,
26ImmutableHashSet<BinaryOperatorKind>.Empty, ImmutableHashSet<UnaryOperatorKind>.Empty, ImmutableHashSet<CaseKind>.Empty, ImmutableHashSet<ISymbol>.Empty, ImmutableHashSet<object>.Empty);
30private readonly ImmutableHashSet<OperationKind> _distinctOperatorKinds;
31private readonly ImmutableHashSet<BinaryOperatorKind> _distinctBinaryOperatorKinds;
32private readonly ImmutableHashSet<UnaryOperatorKind> _distinctUnaryOperatorKinds;
33private readonly ImmutableHashSet<CaseKind> _distinctCaseKinds;
34private readonly ImmutableHashSet<ISymbol> _distinctReferencedSymbols;
35private readonly ImmutableHashSet<object> _distinctReferencedConstants;
43ImmutableHashSet<OperationKind> distinctOperatorKinds,
44ImmutableHashSet<BinaryOperatorKind> distinctBinaryOperatorKinds,
45ImmutableHashSet<UnaryOperatorKind> distinctUnaryOperatorKinds,
46ImmutableHashSet<CaseKind> distinctCaseKinds,
47ImmutableHashSet<ISymbol> distinctReferencedSymbols,
48ImmutableHashSet<object> distinctReferencedConstants)
69ImmutableHashSet<OperationKind> distinctOperatorKinds,
70ImmutableHashSet<BinaryOperatorKind> distinctBinaryOperatorKinds,
71ImmutableHashSet<UnaryOperatorKind> distinctUnaryOperatorKinds,
72ImmutableHashSet<CaseKind> distinctCaseKinds,
73ImmutableHashSet<ISymbol> distinctReferencedSymbols,
74ImmutableHashSet<object> distinctReferencedConstants)
95ImmutableHashSet<OperationKind>.Builder? distinctOperatorKindsBuilder = null;
96ImmutableHashSet<BinaryOperatorKind>.Builder? distinctBinaryOperatorKindsBuilder = null;
97ImmutableHashSet<UnaryOperatorKind>.Builder? distinctUnaryOperatorKindsBuilder = null;
98ImmutableHashSet<CaseKind>.Builder? distinctCaseKindsBuilder = null;
99ImmutableHashSet<ISymbol>.Builder? distinctReferencedSymbolsBuilder = null;
100ImmutableHashSet<object>.Builder? distinctReferencedConstantsBuilder = null;
290distinctOperatorKindsBuilder != null ? distinctOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<OperationKind>.Empty,
291distinctBinaryOperatorKindsBuilder != null ? distinctBinaryOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<BinaryOperatorKind>.Empty,
292distinctUnaryOperatorKindsBuilder != null ? distinctUnaryOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<UnaryOperatorKind>.Empty,
293distinctCaseKindsBuilder != null ? distinctCaseKindsBuilder.ToImmutable() : ImmutableHashSet<CaseKind>.Empty,
294distinctReferencedSymbolsBuilder != null ? distinctReferencedSymbolsBuilder.ToImmutable() : ImmutableHashSet<ISymbol>.Empty,
295distinctReferencedConstantsBuilder != null ? distinctReferencedConstantsBuilder.ToImmutable() : ImmutableHashSet<object>.Empty);
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (7)
39internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
40ImmutableHashSet<INamedTypeSymbol> coupledTypes)
48internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
54internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
195ImmutableHashSet<INamedTypeSymbol>.Builder builder,
349private static void AddCoupledNamedTypesCore(ImmutableHashSet<INamedTypeSymbol>.Builder builder, ITypeSymbol typeOpt,
400internal static void RemoveContainingTypes(ISymbol symbol, ImmutableHashSet<INamedTypeSymbol>.Builder coupledTypesBuilder)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\IDictionaryExtensions.cs (7)
100public static bool MultiAdd<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value, IEqualityComparer<TValue>? comparer = null)
103if (dictionary.TryGetValue(key, out var set))
105var updated = set.Add(value);
158public static ImmutableDictionary<TKey, ImmutableHashSet<TValue>> MultiRemove<TKey, TValue>(this ImmutableDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
161if (dictionary.TryGetValue(key, out var collection))
200public static void MultiRemove<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
Microsoft.AspNetCore.Analyzers (1)
Microsoft.AspNetCore.App.Analyzers (2)
Microsoft.AspNetCore.Components.Endpoints (14)
Microsoft.AspNetCore.Components.Endpoints.Tests (5)
Binding\FormDataMapperTests.cs (5)
825var expected = ImmutableHashSet.CreateRange(new[] { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 });
826CanDeserialize_Collection<ImmutableHashSet<int>, ImmutableHashSet<int>, int>(expected);
865var expected = ImmutableHashSet.CreateRange(new[] { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 });
866CanDeserialize_Collection<IImmutableSet<int>, ImmutableHashSet<int>, int>(expected);
Microsoft.AspNetCore.Http.Extensions (14)
Microsoft.AspNetCore.Http.RequestDelegateGenerator (2)
Microsoft.CodeAnalysis (188)
Binding\UseSiteInfo.cs (21)
36public readonly ImmutableHashSet<TAssemblySymbol>? SecondaryDependencies;
43public UseSiteInfo(ImmutableHashSet<TAssemblySymbol>? secondaryDependencies) :
58public UseSiteInfo(DiagnosticInfo? diagnosticInfo, TAssemblySymbol? primaryDependency, ImmutableHashSet<TAssemblySymbol>? secondaryDependencies)
66SecondaryDependencies = secondaryDependencies ?? ImmutableHashSet<TAssemblySymbol>.Empty;
90public void MergeDependencies(ref TAssemblySymbol? primaryDependency, ref ImmutableHashSet<TAssemblySymbol>? secondaryDependencies)
92secondaryDependencies = (secondaryDependencies ?? ImmutableHashSet<TAssemblySymbol>.Empty).Union(SecondaryDependencies ?? ImmutableHashSet<TAssemblySymbol>.Empty);
456/// - dependencies as a <see cref="ImmutableHashSet{TAssemblySymbol}"/>, or
457/// - a <see cref="Boxed"/> tuple of a <see cref="DiagnosticInfo"/> and a <see cref="ImmutableHashSet{TAssemblySymbol}"/>.
475Initialize(diagnosticInfo, dependencies: ImmutableHashSet<TAssemblySymbol>.Empty);
483private static ImmutableHashSet<TAssemblySymbol> GetDependenciesToCache(TAssemblySymbol? primaryDependency, UseSiteInfo<TAssemblySymbol> useSiteInfo)
485var secondaryDependencies = useSiteInfo.SecondaryDependencies ?? ImmutableHashSet<TAssemblySymbol>.Empty;
498Expand(_info, out var diagnosticInfo, out var dependencies);
508private void Initialize(DiagnosticInfo? diagnosticInfo, ImmutableHashSet<TAssemblySymbol> dependencies)
513private static object? Compact(DiagnosticInfo? diagnosticInfo, ImmutableHashSet<TAssemblySymbol> dependencies)
557Expand(info, out var diagnosticInfo, out var dependencies);
561private static void Expand(object? info, out DiagnosticInfo? diagnosticInfo, out ImmutableHashSet<TAssemblySymbol>? dependencies)
575case ImmutableHashSet<TAssemblySymbol> a:
599public readonly ImmutableHashSet<TAssemblySymbol> Dependencies;
601public Boxed(DiagnosticInfo diagnosticInfo, ImmutableHashSet<TAssemblySymbol> dependencies)
DiagnosticAnalyzer\AnalyzerDriver.cs (41)
92private ImmutableHashSet<DiagnosticAnalyzer>? _lazyUnsuppressedAnalyzers;
97protected ImmutableHashSet<DiagnosticAnalyzer> UnsuppressedAnalyzers
132private ImmutableHashSet<DiagnosticAnalyzer>? _lazyCompilationEndAnalyzers;
133private ImmutableHashSet<DiagnosticAnalyzer> CompilationEndAnalyzers
184private ImmutableHashSet<DiagnosticAnalyzer>? _lazyNonConfigurableAndCustomConfigurableAnalyzers;
189private ImmutableHashSet<DiagnosticAnalyzer> NonConfigurableAndCustomConfigurableAnalyzers
198private ImmutableHashSet<DiagnosticAnalyzer>? _lazySymbolStartAnalyzers;
203private ImmutableHashSet<DiagnosticAnalyzer> SymbolStartAnalyzers
245private Dictionary<SyntaxTree, ImmutableHashSet<ISymbol>>? _lazyGeneratedCodeSymbolsForTreeMap;
250private Dictionary<SyntaxTree, ImmutableHashSet<ISymbol>> GeneratedCodeSymbolsForTreeMap
259private ConcurrentDictionary<SyntaxTree, ImmutableHashSet<DiagnosticAnalyzer>>? _lazySuppressedAnalyzersForTreeMap;
264private ConcurrentDictionary<SyntaxTree, ImmutableHashSet<DiagnosticAnalyzer>> SuppressedAnalyzersForTreeMap
417_lazyGeneratedCodeSymbolsForTreeMap = new Dictionary<SyntaxTree, ImmutableHashSet<ISymbol>>();
420_lazySuppressedAnalyzersForTreeMap = new ConcurrentDictionary<SyntaxTree, ImmutableHashSet<DiagnosticAnalyzer>>();
529private ImmutableHashSet<DiagnosticAnalyzer> ComputeNonConfigurableAndCustomConfigurableAnalyzers(ImmutableHashSet<DiagnosticAnalyzer> unsuppressedAnalyzers, CancellationToken cancellationToken)
548private ImmutableHashSet<DiagnosticAnalyzer> ComputeSymbolStartAnalyzers(ImmutableHashSet<DiagnosticAnalyzer> unsuppressedAnalyzers)
563ImmutableHashSet<DiagnosticAnalyzer> analyzers,
581private static bool ComputeShouldTreatAllCodeAsNonGeneratedCode(ImmutableHashSet<DiagnosticAnalyzer> analyzers, ImmutableSegmentedDictionary<DiagnosticAnalyzer, GeneratedCodeAnalysisFlags> generatedCodeAnalysisFlagsMap)
896var analyzersSuppressedForSomeTree = SuppressedAnalyzersForTreeMap.SelectMany(kvp => kvp.Value).ToImmutableHashSet();
929var effectiveSeverities = GetEffectiveSeverities(descriptor, AnalyzerExecutor.Compilation, AnalyzerExecutor.AnalyzerOptions, cancellationToken);
938static ImmutableHashSet<ReportDiagnostic> GetEffectiveSeverities(
1261var generatedCodeSymbolsInTree = getOrComputeGeneratedCodeSymbolsInTree(location.SourceTree, compilation, cancellationToken);
1285ImmutableHashSet<ISymbol> getOrComputeGeneratedCodeSymbolsInTree(SyntaxTree tree, Compilation compilation, CancellationToken cancellationToken)
1290ImmutableHashSet<ISymbol>? generatedCodeSymbols;
1303ImmutableHashSet<ISymbol>? existingGeneratedCodeSymbols;
1316static ImmutableHashSet<ISymbol> computeGeneratedCodeSymbolsInTree(SyntaxTree tree, Compilation compilation, INamedTypeSymbol generatedCodeAttribute, CancellationToken cancellationToken)
1322return ImmutableHashSet<ISymbol>.Empty;
1329ImmutableHashSet<ISymbol>.Builder? generatedSymbolsBuilder = null;
1342return generatedSymbolsBuilder != null ? generatedSymbolsBuilder.ToImmutable() : ImmutableHashSet<ISymbol>.Empty;
1355if (!SuppressedAnalyzersForTreeMap.TryGetValue(tree, out var suppressedAnalyzers))
1363private ImmutableHashSet<DiagnosticAnalyzer> ComputeSuppressedAnalyzersForTree(SyntaxTree tree, SyntaxTreeOptionsProvider? options, CancellationToken cancellationToken)
1367return ImmutableHashSet<DiagnosticAnalyzer>.Empty;
1370ImmutableHashSet<DiagnosticAnalyzer>.Builder? suppressedAnalyzersBuilder = null;
1419return suppressedAnalyzersBuilder != null ? suppressedAnalyzersBuilder.ToImmutable() : ImmutableHashSet<DiagnosticAnalyzer>.Empty;
1495private static ImmutableHashSet<DiagnosticAnalyzer> MakeCompilationEndAnalyzers(ImmutableArray<(DiagnosticAnalyzer, ImmutableArray<CompilationAnalyzerAction>)> compilationEndActionsByAnalyzer)
2021private static async Task<(AnalyzerActions actions, ImmutableHashSet<DiagnosticAnalyzer> unsuppressedAnalyzers)> GetAnalyzerActionsAsync(
2042var unsuppressedAnalyzers = unsuppressedAnalyzersBuilder.ToImmutableHashSet();
2223ImmutableHashSet<DiagnosticAnalyzer> analyzers,
2248ImmutableHashSet<DiagnosticAnalyzer> analyzers,
DiagnosticAnalyzer\AnalyzerFileReference.cs (12)
215internal ImmutableSortedDictionary<string, ImmutableHashSet<string>> GetAnalyzerTypeNameMap()
226private static ImmutableSortedDictionary<string, ImmutableHashSet<string>> GetAnalyzerTypeNameMap(string fullPath, Type attributeType, AttributeLanguagesFunc languagesFunc)
230Dictionary<string, ImmutableHashSet<string>.Builder> typeNameMap = new Dictionary<string, ImmutableHashSet<string>.Builder>(StringComparer.OrdinalIgnoreCase);
379private ImmutableSortedDictionary<string, ImmutableHashSet<string>>? _lazyExtensionTypeNameMap;
454internal ImmutableSortedDictionary<string, ImmutableHashSet<string>> GetExtensionTypeNameMap()
467ImmutableSortedDictionary<string, ImmutableHashSet<string>> analyzerTypeNameMap;
515ImmutableSortedDictionary<string, ImmutableHashSet<string>> analyzerTypeNameMap;
579private ImmutableArray<TExtension> GetLanguageSpecificAnalyzers(Assembly analyzerAssembly, ImmutableSortedDictionary<string, ImmutableHashSet<string>> analyzerTypeNameMap, string language, ref bool reportedError)
581ImmutableHashSet<string>? languageSpecificAnalyzerTypeNames;
589private ImmutableArray<TExtension> GetAnalyzersForTypeNames(Assembly analyzerAssembly, ImmutableHashSet<string> analyzerTypeNames, ref bool reportedError)
651static IEnumerable<string> shuffle(ImmutableHashSet<string> source)
Microsoft.CodeAnalysis.Analyzers (206)
MetaAnalyzers\ReportDiagnosticAnalyzer.cs (4)
105ImmutableHashSet<INamedTypeSymbol> contextTypes = ImmutableHashSet.Create(compilationEndAnalysisContext, codeBlockAnalysisContext,
111protected abstract ReportDiagnosticCompilationAnalyzer GetAnalyzer(ImmutableHashSet<INamedTypeSymbol> contextTypes, INamedTypeSymbol diagnosticType, INamedTypeSymbol diagnosticDescriptorType, INamedTypeSymbol diagnosticAnalyzer, INamedTypeSymbol diagnosticAnalyzerAttribute);
115private readonly ImmutableHashSet<INamedTypeSymbol> _contextTypes;
121protected ReportDiagnosticCompilationAnalyzer(ImmutableHashSet<INamedTypeSymbol> contextTypes, INamedTypeSymbol diagnosticType, INamedTypeSymbol diagnosticDescriptorType, INamedTypeSymbol diagnosticAnalyzer, INamedTypeSymbol diagnosticAnalyzerAttribute)
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\ComputationalComplexityMetrics.cs (36)
25internal static readonly ComputationalComplexityMetrics Default = new(0, 0, 0, 0, 0, ImmutableHashSet<OperationKind>.Empty,
26ImmutableHashSet<BinaryOperatorKind>.Empty, ImmutableHashSet<UnaryOperatorKind>.Empty, ImmutableHashSet<CaseKind>.Empty, ImmutableHashSet<ISymbol>.Empty, ImmutableHashSet<object>.Empty);
30private readonly ImmutableHashSet<OperationKind> _distinctOperatorKinds;
31private readonly ImmutableHashSet<BinaryOperatorKind> _distinctBinaryOperatorKinds;
32private readonly ImmutableHashSet<UnaryOperatorKind> _distinctUnaryOperatorKinds;
33private readonly ImmutableHashSet<CaseKind> _distinctCaseKinds;
34private readonly ImmutableHashSet<ISymbol> _distinctReferencedSymbols;
35private readonly ImmutableHashSet<object> _distinctReferencedConstants;
43ImmutableHashSet<OperationKind> distinctOperatorKinds,
44ImmutableHashSet<BinaryOperatorKind> distinctBinaryOperatorKinds,
45ImmutableHashSet<UnaryOperatorKind> distinctUnaryOperatorKinds,
46ImmutableHashSet<CaseKind> distinctCaseKinds,
47ImmutableHashSet<ISymbol> distinctReferencedSymbols,
48ImmutableHashSet<object> distinctReferencedConstants)
69ImmutableHashSet<OperationKind> distinctOperatorKinds,
70ImmutableHashSet<BinaryOperatorKind> distinctBinaryOperatorKinds,
71ImmutableHashSet<UnaryOperatorKind> distinctUnaryOperatorKinds,
72ImmutableHashSet<CaseKind> distinctCaseKinds,
73ImmutableHashSet<ISymbol> distinctReferencedSymbols,
74ImmutableHashSet<object> distinctReferencedConstants)
95ImmutableHashSet<OperationKind>.Builder? distinctOperatorKindsBuilder = null;
96ImmutableHashSet<BinaryOperatorKind>.Builder? distinctBinaryOperatorKindsBuilder = null;
97ImmutableHashSet<UnaryOperatorKind>.Builder? distinctUnaryOperatorKindsBuilder = null;
98ImmutableHashSet<CaseKind>.Builder? distinctCaseKindsBuilder = null;
99ImmutableHashSet<ISymbol>.Builder? distinctReferencedSymbolsBuilder = null;
100ImmutableHashSet<object>.Builder? distinctReferencedConstantsBuilder = null;
290distinctOperatorKindsBuilder != null ? distinctOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<OperationKind>.Empty,
291distinctBinaryOperatorKindsBuilder != null ? distinctBinaryOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<BinaryOperatorKind>.Empty,
292distinctUnaryOperatorKindsBuilder != null ? distinctUnaryOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<UnaryOperatorKind>.Empty,
293distinctCaseKindsBuilder != null ? distinctCaseKindsBuilder.ToImmutable() : ImmutableHashSet<CaseKind>.Empty,
294distinctReferencedSymbolsBuilder != null ? distinctReferencedSymbolsBuilder.ToImmutable() : ImmutableHashSet<ISymbol>.Empty,
295distinctReferencedConstantsBuilder != null ? distinctReferencedConstantsBuilder.ToImmutable() : ImmutableHashSet<object>.Empty);
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (7)
39internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
40ImmutableHashSet<INamedTypeSymbol> coupledTypes)
48internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
54internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
195ImmutableHashSet<INamedTypeSymbol>.Builder builder,
349private static void AddCoupledNamedTypesCore(ImmutableHashSet<INamedTypeSymbol>.Builder builder, ITypeSymbol typeOpt,
400internal static void RemoveContainingTypes(ISymbol symbol, ImmutableHashSet<INamedTypeSymbol>.Builder coupledTypesBuilder)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\IDictionaryExtensions.cs (7)
100public static bool MultiAdd<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value, IEqualityComparer<TValue>? comparer = null)
103if (dictionary.TryGetValue(key, out var set))
105var updated = set.Add(value);
158public static ImmutableDictionary<TKey, ImmutableHashSet<TValue>> MultiRemove<TKey, TValue>(this ImmutableDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
161if (dictionary.TryGetValue(key, out var collection))
200public static void MultiRemove<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
Microsoft.CodeAnalysis.AnalyzerUtilities (557)
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\ComputationalComplexityMetrics.cs (36)
25internal static readonly ComputationalComplexityMetrics Default = new(0, 0, 0, 0, 0, ImmutableHashSet<OperationKind>.Empty,
26ImmutableHashSet<BinaryOperatorKind>.Empty, ImmutableHashSet<UnaryOperatorKind>.Empty, ImmutableHashSet<CaseKind>.Empty, ImmutableHashSet<ISymbol>.Empty, ImmutableHashSet<object>.Empty);
30private readonly ImmutableHashSet<OperationKind> _distinctOperatorKinds;
31private readonly ImmutableHashSet<BinaryOperatorKind> _distinctBinaryOperatorKinds;
32private readonly ImmutableHashSet<UnaryOperatorKind> _distinctUnaryOperatorKinds;
33private readonly ImmutableHashSet<CaseKind> _distinctCaseKinds;
34private readonly ImmutableHashSet<ISymbol> _distinctReferencedSymbols;
35private readonly ImmutableHashSet<object> _distinctReferencedConstants;
43ImmutableHashSet<OperationKind> distinctOperatorKinds,
44ImmutableHashSet<BinaryOperatorKind> distinctBinaryOperatorKinds,
45ImmutableHashSet<UnaryOperatorKind> distinctUnaryOperatorKinds,
46ImmutableHashSet<CaseKind> distinctCaseKinds,
47ImmutableHashSet<ISymbol> distinctReferencedSymbols,
48ImmutableHashSet<object> distinctReferencedConstants)
69ImmutableHashSet<OperationKind> distinctOperatorKinds,
70ImmutableHashSet<BinaryOperatorKind> distinctBinaryOperatorKinds,
71ImmutableHashSet<UnaryOperatorKind> distinctUnaryOperatorKinds,
72ImmutableHashSet<CaseKind> distinctCaseKinds,
73ImmutableHashSet<ISymbol> distinctReferencedSymbols,
74ImmutableHashSet<object> distinctReferencedConstants)
95ImmutableHashSet<OperationKind>.Builder? distinctOperatorKindsBuilder = null;
96ImmutableHashSet<BinaryOperatorKind>.Builder? distinctBinaryOperatorKindsBuilder = null;
97ImmutableHashSet<UnaryOperatorKind>.Builder? distinctUnaryOperatorKindsBuilder = null;
98ImmutableHashSet<CaseKind>.Builder? distinctCaseKindsBuilder = null;
99ImmutableHashSet<ISymbol>.Builder? distinctReferencedSymbolsBuilder = null;
100ImmutableHashSet<object>.Builder? distinctReferencedConstantsBuilder = null;
290distinctOperatorKindsBuilder != null ? distinctOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<OperationKind>.Empty,
291distinctBinaryOperatorKindsBuilder != null ? distinctBinaryOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<BinaryOperatorKind>.Empty,
292distinctUnaryOperatorKindsBuilder != null ? distinctUnaryOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<UnaryOperatorKind>.Empty,
293distinctCaseKindsBuilder != null ? distinctCaseKindsBuilder.ToImmutable() : ImmutableHashSet<CaseKind>.Empty,
294distinctReferencedSymbolsBuilder != null ? distinctReferencedSymbolsBuilder.ToImmutable() : ImmutableHashSet<ISymbol>.Empty,
295distinctReferencedConstantsBuilder != null ? distinctReferencedConstantsBuilder.ToImmutable() : ImmutableHashSet<object>.Empty);
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (7)
39internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
40ImmutableHashSet<INamedTypeSymbol> coupledTypes)
48internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
54internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
195ImmutableHashSet<INamedTypeSymbol>.Builder builder,
349private static void AddCoupledNamedTypesCore(ImmutableHashSet<INamedTypeSymbol>.Builder builder, ITypeSymbol typeOpt,
400internal static void RemoveContainingTypes(ISymbol symbol, ImmutableHashSet<INamedTypeSymbol>.Builder coupledTypesBuilder)
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\GlobalFlowStateAnalysis\GlobalFlowStateAnalysisValueSet.cs (16)
21ImmutableHashSet<IAbstractAnalysisValue>.Empty, ImmutableHashSet<GlobalFlowStateAnalysisValueSet>.Empty, 0, GlobalFlowStateAnalysisValueSetKind.Unset);
23ImmutableHashSet<IAbstractAnalysisValue>.Empty, ImmutableHashSet<GlobalFlowStateAnalysisValueSet>.Empty, 0, GlobalFlowStateAnalysisValueSetKind.Empty);
25ImmutableHashSet<IAbstractAnalysisValue>.Empty, ImmutableHashSet<GlobalFlowStateAnalysisValueSet>.Empty, 0, GlobalFlowStateAnalysisValueSetKind.Unknown);
28ImmutableHashSet<IAbstractAnalysisValue> analysisValues,
29ImmutableHashSet<GlobalFlowStateAnalysisValueSet> parents,
47ImmutableHashSet<IAbstractAnalysisValue> analysisValues,
48ImmutableHashSet<GlobalFlowStateAnalysisValueSet> parents,
56=> new(ImmutableHashSet.Create(analysisValue), ImmutableHashSet<GlobalFlowStateAnalysisValueSet>.Empty, height: 0, GlobalFlowStateAnalysisValueSetKind.Known);
58public ImmutableHashSet<IAbstractAnalysisValue> AnalysisValues { get; }
59public ImmutableHashSet<GlobalFlowStateAnalysisValueSet> Parents { get; }
111var negatedAnalysisValues = ImmutableHashSet.Create(AnalysisValues.Single().GetNegatedValue());
140return GlobalFlowStateAnalysisValueSet.Create(ImmutableHashSet<IAbstractAnalysisValue>.Empty, parentsBuilder.ToImmutable(), height);
143static GlobalFlowStateAnalysisValueSet GetNegateValueFromParents(ImmutableHashSet<GlobalFlowStateAnalysisValueSet> parents)
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\PointsToAnalysis\PointsToAnalysis.PointsToDataFlowOperationVisitor.cs (17)
30private readonly PooledDictionary<IOperation, ImmutableHashSet<AbstractLocation>.Builder> _escapedOperationLocationsBuilder;
31private readonly PooledDictionary<IOperation, ImmutableHashSet<AbstractLocation>.Builder> _escapedReturnValueLocationsBuilder;
32private readonly PooledDictionary<AnalysisEntity, ImmutableHashSet<AbstractLocation>.Builder> _escapedEntityLocationsBuilder;
44_escapedOperationLocationsBuilder = PooledDictionary<IOperation, ImmutableHashSet<AbstractLocation>.Builder>.GetInstance();
45_escapedReturnValueLocationsBuilder = PooledDictionary<IOperation, ImmutableHashSet<AbstractLocation>.Builder>.GetInstance();
46_escapedEntityLocationsBuilder = PooledDictionary<AnalysisEntity, ImmutableHashSet<AbstractLocation>.Builder>.GetInstance();
53public ImmutableDictionary<IOperation, ImmutableHashSet<AbstractLocation>> GetEscapedLocationsThroughOperationsMap()
56public ImmutableDictionary<IOperation, ImmutableHashSet<AbstractLocation>> GetEscapedLocationsThroughReturnValuesMap()
59public ImmutableDictionary<AnalysisEntity, ImmutableHashSet<AbstractLocation>> GetEscapedLocationsThroughEntitiesMap()
62private static ImmutableDictionary<T, ImmutableHashSet<AbstractLocation>> GetEscapedAbstractLocationsMapAndFreeBuilder<T>(
63PooledDictionary<T, ImmutableHashSet<AbstractLocation>.Builder> escapedLocationsBuilder)
70return ImmutableDictionary<T, ImmutableHashSet<AbstractLocation>>.Empty;
73var builder = ImmutableDictionary.CreateBuilder<T, ImmutableHashSet<AbstractLocation>>();
632private void HandleEscapingOperation(IOperation escapingOperation, IOperation escapedInstance, PooledDictionary<IOperation, ImmutableHashSet<AbstractLocation>.Builder> builder)
651PooledDictionary<TKey, ImmutableHashSet<AbstractLocation>.Builder> escapedLocationsBuilder,
673PooledDictionary<TKey, ImmutableHashSet<AbstractLocation>.Builder> escapedLocationsBuilder,
703private void HandleEscapingLocations(PointsToAbstractValue pointsToValueOfEscapedInstance, ImmutableHashSet<AbstractLocation>.Builder builder)
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\PointsToAnalysis\PointsToAnalysisResult.cs (14)
14private readonly ImmutableDictionary<IOperation, ImmutableHashSet<AbstractLocation>> _escapedLocationsThroughOperationsMap;
15private readonly ImmutableDictionary<IOperation, ImmutableHashSet<AbstractLocation>> _escapedLocationsThroughReturnValuesMap;
16private readonly ImmutableDictionary<AnalysisEntity, ImmutableHashSet<AbstractLocation>> _escapedLocationsThroughEntitiesMap;
17private readonly ImmutableHashSet<AnalysisEntity> _trackedEntities;
18private readonly ImmutableHashSet<PointsToAbstractValue> _trackedPointsToValues;
22ImmutableDictionary<IOperation, ImmutableHashSet<AbstractLocation>> escapedLocationsThroughOperationsMap,
23ImmutableDictionary<IOperation, ImmutableHashSet<AbstractLocation>> escapedLocationsThroughReturnValuesMap,
24ImmutableDictionary<AnalysisEntity, ImmutableHashSet<AbstractLocation>> escapedLocationsThroughEntitiesMap,
37public ImmutableHashSet<AbstractLocation> GetEscapedAbstractLocations(IOperation operation)
42public ImmutableHashSet<AbstractLocation> GetEscapedAbstractLocations(AnalysisEntity analysisEntity)
45private static ImmutableHashSet<AbstractLocation> GetEscapedAbstractLocations<TKey>(
47ImmutableDictionary<TKey, ImmutableHashSet<AbstractLocation>> map)
50if (map.TryGetValue(key, out var escapedLocations))
55return ImmutableHashSet<AbstractLocation>.Empty;
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\TaintedDataAnalysis\PooledHashSetExtensions.cs (72)
50?? ImmutableHashSet<string>.Empty,
53?.Select(o => new KeyValuePair<string, ImmutableHashSet<string>>(o.Method, o.Parameters.ToImmutableHashSet()))
55?? ImmutableDictionary<string, ImmutableHashSet<string>>.Empty);
67taintedProperties: ImmutableHashSet<string>.Empty,
68transferProperties: ImmutableHashSet<string>.Empty,
72ImmutableHashSet<(MethodMatcher, ImmutableHashSet<string>)>.Empty,
74ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(PointsToCheck, string)>)>.Empty,
76ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(ValueContentCheck, string)>)>.Empty,
78ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(string, string)>)>.Empty,
94taintedProperties: ImmutableHashSet<string>.Empty,
95transferProperties: ImmutableHashSet<string>.Empty,
99ImmutableHashSet<(MethodMatcher, ImmutableHashSet<string>)>.Empty,
101ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(PointsToCheck, string)>)>.Empty,
103ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(ValueContentCheck, string)>)>.Empty,
105ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(string, string)>)>.Empty,
123?? ImmutableHashSet<string>.Empty,
124transferProperties: ImmutableHashSet<string>.Empty,
126ImmutableHashSet<ParameterMatcher>.Empty,
129?.Select<string, (MethodMatcher, ImmutableHashSet<string>)>(o =>
132ImmutableHashSet<string>.Empty.Add(TaintedTargetValue.Return)
135?? ImmutableHashSet<(MethodMatcher, ImmutableHashSet<string>)>.Empty,
137ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(PointsToCheck, string)>)>.Empty,
139ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(ValueContentCheck, string)>)>.Empty,
141ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(string, string)>)>.Empty,
173?? ImmutableHashSet<string>.Empty,
175?? ImmutableHashSet<string>.Empty,
177ImmutableHashSet<ParameterMatcher>.Empty,
179ImmutableHashSet<(MethodMatcher, ImmutableHashSet<string>)>.Empty,
185?? ImmutableHashSet<(PointsToCheck, string)>.Empty
188?? ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(PointsToCheck, string)>)>.Empty,
194?? ImmutableHashSet<(ValueContentCheck, string)>.Empty
197?? ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(ValueContentCheck, string)>)>.Empty,
205?? ImmutableHashSet<(string, string)>.Empty))
207?? ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(string, string)>)>.Empty,
230?? ImmutableHashSet<string>.Empty,
231transferProperties: ImmutableHashSet<string>.Empty,
233ImmutableHashSet<ParameterMatcher>.Empty,
235ImmutableHashSet<(MethodMatcher, ImmutableHashSet<string>)>.Empty,
243?? ImmutableHashSet<(PointsToCheck, string)>.Empty
246?? ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(PointsToCheck, string)>)>.Empty,
254?? ImmutableHashSet<(ValueContentCheck, string)>.Empty
257?? ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(ValueContentCheck, string)>)>.Empty,
259ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(string, string)>)>.Empty,
280?.Select<string, (MethodMatcher, ImmutableHashSet<(string, string)>)>(o =>
283ImmutableHashSet<(string, string)>.Empty))
285?? ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(string, string)>)>.Empty,
287?? ImmutableHashSet<string>.Empty);
310?? ImmutableHashSet<(string, string)>.Empty))
312?? ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(string, string)>)>.Empty,
314?? ImmutableHashSet<string>.Empty);
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\TaintedDataAnalysis\SourceInfo.cs (22)
42ImmutableHashSet<string> taintedProperties,
43ImmutableHashSet<ParameterMatcher> taintedArguments,
44ImmutableHashSet<(MethodMatcher, ImmutableHashSet<string>)> taintedMethods,
45ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(PointsToCheck, string)>)> taintedMethodsNeedsPointsToAnalysis,
46ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(ValueContentCheck, string)>)> taintedMethodsNeedsValueContentAnalysis,
47ImmutableHashSet<string> transferProperties,
48ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(string, string)>)> transferMethods,
90public ImmutableHashSet<string> TransferProperties { get; }
95public ImmutableHashSet<string> TaintedProperties { get; }
101public ImmutableHashSet<(MethodMatcher MethodMatcher, ImmutableHashSet<string> TaintedTargets)> TaintedMethods { get; }
106public ImmutableHashSet<ParameterMatcher> TaintedArguments { get; }
129public ImmutableHashSet<(MethodMatcher MethodMatcher, ImmutableHashSet<(PointsToCheck PointsToCheck, string TaintedTarget)>)> TaintedMethodsNeedsPointsToAnalysis { get; }
152public ImmutableHashSet<(MethodMatcher MethodMatcher, ImmutableHashSet<(ValueContentCheck ValueContentCheck, string TaintedTarget)>)> TaintedMethodsNeedsValueContentAnalysis { get; }
171public ImmutableHashSet<(MethodMatcher MethodMatcher, ImmutableHashSet<(string IfTaintedParameter, string ThenTaintedTarget)>)> TransferMethods { get; }
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\TaintedDataAnalysis\TaintedDataAnalysis.TaintedDataOperationVisitor.cs (10)
35private Dictionary<SymbolAccess, (ImmutableHashSet<SinkKind>.Builder SinkKinds, ImmutableHashSet<SymbolAccess>.Builder SourceOrigins)> TaintedSourcesBySink { get; }
47foreach (KeyValuePair<SymbolAccess, (ImmutableHashSet<SinkKind>.Builder SinkKinds, ImmutableHashSet<SymbolAccess>.Builder SourceOrigins)> kvp in this.TaintedSourcesBySink)
542if (!this.TaintedSourcesBySink.TryGetValue(sink, out (ImmutableHashSet<SinkKind>.Builder SinkKinds, ImmutableHashSet<SymbolAccess>.Builder SourceOrigins) data))
586out (ImmutableHashSet<SinkKind>.Builder SinkKinds, ImmutableHashSet<SymbolAccess>.Builder SourceOrigins) data))
645foreach ((MethodMatcher methodMatcher, ImmutableHashSet<(string source, string end)> sourceToEnds) in sanitizerInfo.SanitizingMethods)
701else if (sinkInfo.SinkMethodParameters.TryGetValue(method.MetadataName, out var sinkParameters)
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\TaintedDataAnalysis\TaintedDataConfig.cs (28)
33private static ImmutableDictionary<SinkKind, ImmutableHashSet<SourceInfo>> s_sinkKindToSourceInfo
34= ImmutableDictionary.Create<SinkKind, ImmutableHashSet<SourceInfo>>();
39private static ImmutableDictionary<SinkKind, ImmutableHashSet<SanitizerInfo>> s_sinkKindToSanitizerInfo
40= ImmutableDictionary.Create<SinkKind, ImmutableHashSet<SanitizerInfo>>();
105PooledDictionary<ImmutableHashSet<SourceInfo>, Lazy<TaintedDataSymbolMap<SourceInfo>>>.GetInstance(out var sourcesToSymbolMap);
107PooledDictionary<ImmutableHashSet<SanitizerInfo>, Lazy<TaintedDataSymbolMap<SanitizerInfo>>>.GetInstance(out var sanitizersToSymbolMap);
111PooledDictionary<(ImmutableHashSet<SourceInfo> SourceInfos, ImmutableHashSet<SanitizerInfo> SanitizerInfos), (ImmutableHashSet<SinkKind>.Builder SinkKinds, ImmutableHashSet<SinkInfo>.Builder SinkInfos)>.GetInstance(out var sourceSanitizersToSinks);
116ImmutableHashSet<SourceInfo> sources = GetSourceInfos(sinkKind);
127ImmutableHashSet<SanitizerInfo> sanitizers = GetSanitizerInfos(sinkKind);
138ImmutableHashSet<SinkInfo> sinks = GetSinkInfos(sinkKind);
139if (!sourceSanitizersToSinks.TryGetValue((sources, sanitizers), out (ImmutableHashSet<SinkKind>.Builder SinkKinds, ImmutableHashSet<SinkInfo>.Builder SinkInfos) sinksPair))
149foreach (KeyValuePair<(ImmutableHashSet<SourceInfo> SourceInfos, ImmutableHashSet<SanitizerInfo> SanitizerInfos), (ImmutableHashSet<SinkKind>.Builder SinkKinds, ImmutableHashSet<SinkInfo>.Builder SinkInfos)> kvp in sourceSanitizersToSinks)
151ImmutableHashSet<SinkInfo> sinks = kvp.Value.SinkInfos.ToImmutable();
205private static ImmutableHashSet<SourceInfo> GetSourceInfos(SinkKind sinkKind)
207if (s_sinkKindToSourceInfo.TryGetValue(sinkKind, out var sourceInfo))
252return ImmutableHashSet<SourceInfo>.Empty;
258private static ImmutableHashSet<SanitizerInfo> GetSanitizerInfos(SinkKind sinkKind)
260if (s_sinkKindToSanitizerInfo.TryGetValue(sinkKind, out var sanitizerInfo))
308return ImmutableHashSet<SanitizerInfo>.Empty;
314private static ImmutableHashSet<SinkInfo> GetSinkInfos(SinkKind sinkKind)
363return ImmutableHashSet<SinkInfo>.Empty;
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Framework\DataFlow\SetAbstractDomain.cs (14)
11public class SetAbstractDomain<T> : AbstractDomain<ImmutableHashSet<T>>
17public override ImmutableHashSet<T> Bottom => ImmutableHashSet<T>.Empty;
19public override int Compare(ImmutableHashSet<T> oldValue, ImmutableHashSet<T> newValue, bool assertMonotonicity)
51public override ImmutableHashSet<T> Merge(ImmutableHashSet<T> value1, ImmutableHashSet<T> value2) => MergeOrIntersect(value1, value2, merge: true);
53public ImmutableHashSet<T> Intersect(ImmutableHashSet<T> value1, ImmutableHashSet<T> value2) => MergeOrIntersect(value1, value2, merge: false);
55private static ImmutableHashSet<T> MergeOrIntersect(ImmutableHashSet<T> value1, ImmutableHashSet<T> value2, bool merge)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\IDictionaryExtensions.cs (7)
100public static bool MultiAdd<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value, IEqualityComparer<TValue>? comparer = null)
103if (dictionary.TryGetValue(key, out var set))
105var updated = set.Add(value);
158public static ImmutableDictionary<TKey, ImmutableHashSet<TValue>> MultiRemove<TKey, TValue>(this ImmutableDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
161if (dictionary.TryGetValue(key, out var collection))
200public static void MultiRemove<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
Microsoft.CodeAnalysis.BannedApiAnalyzers (186)
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\ComputationalComplexityMetrics.cs (36)
25internal static readonly ComputationalComplexityMetrics Default = new(0, 0, 0, 0, 0, ImmutableHashSet<OperationKind>.Empty,
26ImmutableHashSet<BinaryOperatorKind>.Empty, ImmutableHashSet<UnaryOperatorKind>.Empty, ImmutableHashSet<CaseKind>.Empty, ImmutableHashSet<ISymbol>.Empty, ImmutableHashSet<object>.Empty);
30private readonly ImmutableHashSet<OperationKind> _distinctOperatorKinds;
31private readonly ImmutableHashSet<BinaryOperatorKind> _distinctBinaryOperatorKinds;
32private readonly ImmutableHashSet<UnaryOperatorKind> _distinctUnaryOperatorKinds;
33private readonly ImmutableHashSet<CaseKind> _distinctCaseKinds;
34private readonly ImmutableHashSet<ISymbol> _distinctReferencedSymbols;
35private readonly ImmutableHashSet<object> _distinctReferencedConstants;
43ImmutableHashSet<OperationKind> distinctOperatorKinds,
44ImmutableHashSet<BinaryOperatorKind> distinctBinaryOperatorKinds,
45ImmutableHashSet<UnaryOperatorKind> distinctUnaryOperatorKinds,
46ImmutableHashSet<CaseKind> distinctCaseKinds,
47ImmutableHashSet<ISymbol> distinctReferencedSymbols,
48ImmutableHashSet<object> distinctReferencedConstants)
69ImmutableHashSet<OperationKind> distinctOperatorKinds,
70ImmutableHashSet<BinaryOperatorKind> distinctBinaryOperatorKinds,
71ImmutableHashSet<UnaryOperatorKind> distinctUnaryOperatorKinds,
72ImmutableHashSet<CaseKind> distinctCaseKinds,
73ImmutableHashSet<ISymbol> distinctReferencedSymbols,
74ImmutableHashSet<object> distinctReferencedConstants)
95ImmutableHashSet<OperationKind>.Builder? distinctOperatorKindsBuilder = null;
96ImmutableHashSet<BinaryOperatorKind>.Builder? distinctBinaryOperatorKindsBuilder = null;
97ImmutableHashSet<UnaryOperatorKind>.Builder? distinctUnaryOperatorKindsBuilder = null;
98ImmutableHashSet<CaseKind>.Builder? distinctCaseKindsBuilder = null;
99ImmutableHashSet<ISymbol>.Builder? distinctReferencedSymbolsBuilder = null;
100ImmutableHashSet<object>.Builder? distinctReferencedConstantsBuilder = null;
290distinctOperatorKindsBuilder != null ? distinctOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<OperationKind>.Empty,
291distinctBinaryOperatorKindsBuilder != null ? distinctBinaryOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<BinaryOperatorKind>.Empty,
292distinctUnaryOperatorKindsBuilder != null ? distinctUnaryOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<UnaryOperatorKind>.Empty,
293distinctCaseKindsBuilder != null ? distinctCaseKindsBuilder.ToImmutable() : ImmutableHashSet<CaseKind>.Empty,
294distinctReferencedSymbolsBuilder != null ? distinctReferencedSymbolsBuilder.ToImmutable() : ImmutableHashSet<ISymbol>.Empty,
295distinctReferencedConstantsBuilder != null ? distinctReferencedConstantsBuilder.ToImmutable() : ImmutableHashSet<object>.Empty);
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (7)
39internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
40ImmutableHashSet<INamedTypeSymbol> coupledTypes)
48internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
54internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
195ImmutableHashSet<INamedTypeSymbol>.Builder builder,
349private static void AddCoupledNamedTypesCore(ImmutableHashSet<INamedTypeSymbol>.Builder builder, ITypeSymbol typeOpt,
400internal static void RemoveContainingTypes(ISymbol symbol, ImmutableHashSet<INamedTypeSymbol>.Builder coupledTypesBuilder)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\IDictionaryExtensions.cs (7)
100public static bool MultiAdd<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value, IEqualityComparer<TValue>? comparer = null)
103if (dictionary.TryGetValue(key, out var set))
105var updated = set.Add(value);
158public static ImmutableDictionary<TKey, ImmutableHashSet<TValue>> MultiRemove<TKey, TValue>(this ImmutableDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
161if (dictionary.TryGetValue(key, out var collection))
200public static void MultiRemove<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
Microsoft.CodeAnalysis.CodeStyle (123)
src\Analyzers\Core\Analyzers\IDEDiagnosticIdToOptionMappingHelper.cs (8)
22private static readonly ConcurrentDictionary<string, ImmutableHashSet<IOption2>> s_diagnosticIdToOptionMap = new();
23private static readonly ConcurrentDictionary<string, ConcurrentDictionary<string, ImmutableHashSet<IOption2>>> s_diagnosticIdToLanguageSpecificOptionsMap = new();
26public static bool TryGetMappedOptions(string diagnosticId, string language, [NotNullWhen(true)] out ImmutableHashSet<IOption2>? options)
38public static void AddOptionMapping(string diagnosticId, ImmutableHashSet<IOption2> options)
70var map = s_diagnosticIdToLanguageSpecificOptionsMap.GetOrAdd(language, _ => new ConcurrentDictionary<string, ImmutableHashSet<IOption2>>());
83private static void AddOptionMapping(ConcurrentDictionary<string, ImmutableHashSet<IOption2>> map, string diagnosticId, ImmutableHashSet<IOption2> options)
87Debug.Assert(!map.TryGetValue(diagnosticId, out var existingOptions) || options.SetEquals(existingOptions));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\IDictionaryExtensions.cs (7)
100public static bool MultiAdd<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value, IEqualityComparer<TValue>? comparer = null)
103if (dictionary.TryGetValue(key, out var set))
105var updated = set.Add(value);
158public static ImmutableDictionary<TKey, ImmutableHashSet<TValue>> MultiRemove<TKey, TValue>(this ImmutableDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
161if (dictionary.TryGetValue(key, out var collection))
200public static void MultiRemove<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
Microsoft.CodeAnalysis.CodeStyle.Fixes (2)
Microsoft.CodeAnalysis.Collections.Package (68)
Microsoft.CodeAnalysis.CSharp (130)
Microsoft.CodeAnalysis.CSharp.Analyzers (2)
Microsoft.CodeAnalysis.CSharp.CodeStyle (6)
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\CSharpUseCollectionExpressionForFluentDiagnosticAnalyzer.cs (1)
57nameof(ImmutableHashSet<>),
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (4)
Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests (2)
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (9)
Microsoft.CodeAnalysis.CSharp.Features (40)
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\CSharpUseCollectionExpressionForFluentDiagnosticAnalyzer.cs (1)
57nameof(ImmutableHashSet<>),
Microsoft.CodeAnalysis.CSharp.Features.UnitTests (2)
Microsoft.CodeAnalysis.CSharp.Workspaces (6)
Microsoft.CodeAnalysis.EditorFeatures (5)
Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities (1)
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (8)
Microsoft.CodeAnalysis.EditorFeatures2.UnitTests (26)
Microsoft.CodeAnalysis.ExpressionEvaluator.FunctionResolver (2)
Microsoft.CodeAnalysis.ExpressionEvaluator.FunctionResolver.UnitTests (2)
Microsoft.CodeAnalysis.Extensions.Package (68)
Microsoft.CodeAnalysis.ExternalAccess.FSharp (1)
Microsoft.CodeAnalysis.ExternalAccess.OmniSharp (3)
Microsoft.CodeAnalysis.Features (107)
Diagnostics\IDiagnosticAnalyzerService.cs (2)
56Task<ImmutableArray<DiagnosticData>> GetDiagnosticsForIdsAsync(Project project, DocumentId? documentId, ImmutableHashSet<string>? diagnosticIds, Func<DiagnosticAnalyzer, bool>? shouldIncludeAnalyzer, bool includeLocalDocumentDiagnostics, bool includeNonLocalDocumentDiagnostics, CancellationToken cancellationToken);
73Task<ImmutableArray<DiagnosticData>> GetProjectDiagnosticsForIdsAsync(Project project, ImmutableHashSet<string>? diagnosticIds, Func<DiagnosticAnalyzer, bool>? shouldIncludeAnalyzer, bool includeNonLocalDocumentDiagnostics, CancellationToken cancellationToken);
src\Analyzers\Core\Analyzers\IDEDiagnosticIdToOptionMappingHelper.cs (8)
22private static readonly ConcurrentDictionary<string, ImmutableHashSet<IOption2>> s_diagnosticIdToOptionMap = new();
23private static readonly ConcurrentDictionary<string, ConcurrentDictionary<string, ImmutableHashSet<IOption2>>> s_diagnosticIdToLanguageSpecificOptionsMap = new();
26public static bool TryGetMappedOptions(string diagnosticId, string language, [NotNullWhen(true)] out ImmutableHashSet<IOption2>? options)
38public static void AddOptionMapping(string diagnosticId, ImmutableHashSet<IOption2> options)
70var map = s_diagnosticIdToLanguageSpecificOptionsMap.GetOrAdd(language, _ => new ConcurrentDictionary<string, ImmutableHashSet<IOption2>>());
83private static void AddOptionMapping(ConcurrentDictionary<string, ImmutableHashSet<IOption2>> map, string diagnosticId, ImmutableHashSet<IOption2> options)
87Debug.Assert(!map.TryGetValue(diagnosticId, out var existingOptions) || options.SetEquals(existingOptions));
Microsoft.CodeAnalysis.InteractiveHost (68)
Microsoft.CodeAnalysis.LanguageServer.Protocol (1)
Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests (6)
Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers (186)
Microsoft.CodeAnalysis.PublicApiAnalyzers (185)
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\ComputationalComplexityMetrics.cs (36)
25internal static readonly ComputationalComplexityMetrics Default = new(0, 0, 0, 0, 0, ImmutableHashSet<OperationKind>.Empty,
26ImmutableHashSet<BinaryOperatorKind>.Empty, ImmutableHashSet<UnaryOperatorKind>.Empty, ImmutableHashSet<CaseKind>.Empty, ImmutableHashSet<ISymbol>.Empty, ImmutableHashSet<object>.Empty);
30private readonly ImmutableHashSet<OperationKind> _distinctOperatorKinds;
31private readonly ImmutableHashSet<BinaryOperatorKind> _distinctBinaryOperatorKinds;
32private readonly ImmutableHashSet<UnaryOperatorKind> _distinctUnaryOperatorKinds;
33private readonly ImmutableHashSet<CaseKind> _distinctCaseKinds;
34private readonly ImmutableHashSet<ISymbol> _distinctReferencedSymbols;
35private readonly ImmutableHashSet<object> _distinctReferencedConstants;
43ImmutableHashSet<OperationKind> distinctOperatorKinds,
44ImmutableHashSet<BinaryOperatorKind> distinctBinaryOperatorKinds,
45ImmutableHashSet<UnaryOperatorKind> distinctUnaryOperatorKinds,
46ImmutableHashSet<CaseKind> distinctCaseKinds,
47ImmutableHashSet<ISymbol> distinctReferencedSymbols,
48ImmutableHashSet<object> distinctReferencedConstants)
69ImmutableHashSet<OperationKind> distinctOperatorKinds,
70ImmutableHashSet<BinaryOperatorKind> distinctBinaryOperatorKinds,
71ImmutableHashSet<UnaryOperatorKind> distinctUnaryOperatorKinds,
72ImmutableHashSet<CaseKind> distinctCaseKinds,
73ImmutableHashSet<ISymbol> distinctReferencedSymbols,
74ImmutableHashSet<object> distinctReferencedConstants)
95ImmutableHashSet<OperationKind>.Builder? distinctOperatorKindsBuilder = null;
96ImmutableHashSet<BinaryOperatorKind>.Builder? distinctBinaryOperatorKindsBuilder = null;
97ImmutableHashSet<UnaryOperatorKind>.Builder? distinctUnaryOperatorKindsBuilder = null;
98ImmutableHashSet<CaseKind>.Builder? distinctCaseKindsBuilder = null;
99ImmutableHashSet<ISymbol>.Builder? distinctReferencedSymbolsBuilder = null;
100ImmutableHashSet<object>.Builder? distinctReferencedConstantsBuilder = null;
290distinctOperatorKindsBuilder != null ? distinctOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<OperationKind>.Empty,
291distinctBinaryOperatorKindsBuilder != null ? distinctBinaryOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<BinaryOperatorKind>.Empty,
292distinctUnaryOperatorKindsBuilder != null ? distinctUnaryOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<UnaryOperatorKind>.Empty,
293distinctCaseKindsBuilder != null ? distinctCaseKindsBuilder.ToImmutable() : ImmutableHashSet<CaseKind>.Empty,
294distinctReferencedSymbolsBuilder != null ? distinctReferencedSymbolsBuilder.ToImmutable() : ImmutableHashSet<ISymbol>.Empty,
295distinctReferencedConstantsBuilder != null ? distinctReferencedConstantsBuilder.ToImmutable() : ImmutableHashSet<object>.Empty);
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (7)
39internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
40ImmutableHashSet<INamedTypeSymbol> coupledTypes)
48internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
54internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
195ImmutableHashSet<INamedTypeSymbol>.Builder builder,
349private static void AddCoupledNamedTypesCore(ImmutableHashSet<INamedTypeSymbol>.Builder builder, ITypeSymbol typeOpt,
400internal static void RemoveContainingTypes(ISymbol symbol, ImmutableHashSet<INamedTypeSymbol>.Builder coupledTypesBuilder)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\IDictionaryExtensions.cs (7)
100public static bool MultiAdd<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value, IEqualityComparer<TValue>? comparer = null)
103if (dictionary.TryGetValue(key, out var set))
105var updated = set.Add(value);
158public static ImmutableDictionary<TKey, ImmutableHashSet<TValue>> MultiRemove<TKey, TValue>(this ImmutableDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
161if (dictionary.TryGetValue(key, out var collection))
200public static void MultiRemove<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
Microsoft.CodeAnalysis.PublicApiAnalyzers.CodeFixes (4)
Microsoft.CodeAnalysis.Remote.ServiceHub (3)
Microsoft.CodeAnalysis.ResxSourceGenerator (185)
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\ComputationalComplexityMetrics.cs (36)
25internal static readonly ComputationalComplexityMetrics Default = new(0, 0, 0, 0, 0, ImmutableHashSet<OperationKind>.Empty,
26ImmutableHashSet<BinaryOperatorKind>.Empty, ImmutableHashSet<UnaryOperatorKind>.Empty, ImmutableHashSet<CaseKind>.Empty, ImmutableHashSet<ISymbol>.Empty, ImmutableHashSet<object>.Empty);
30private readonly ImmutableHashSet<OperationKind> _distinctOperatorKinds;
31private readonly ImmutableHashSet<BinaryOperatorKind> _distinctBinaryOperatorKinds;
32private readonly ImmutableHashSet<UnaryOperatorKind> _distinctUnaryOperatorKinds;
33private readonly ImmutableHashSet<CaseKind> _distinctCaseKinds;
34private readonly ImmutableHashSet<ISymbol> _distinctReferencedSymbols;
35private readonly ImmutableHashSet<object> _distinctReferencedConstants;
43ImmutableHashSet<OperationKind> distinctOperatorKinds,
44ImmutableHashSet<BinaryOperatorKind> distinctBinaryOperatorKinds,
45ImmutableHashSet<UnaryOperatorKind> distinctUnaryOperatorKinds,
46ImmutableHashSet<CaseKind> distinctCaseKinds,
47ImmutableHashSet<ISymbol> distinctReferencedSymbols,
48ImmutableHashSet<object> distinctReferencedConstants)
69ImmutableHashSet<OperationKind> distinctOperatorKinds,
70ImmutableHashSet<BinaryOperatorKind> distinctBinaryOperatorKinds,
71ImmutableHashSet<UnaryOperatorKind> distinctUnaryOperatorKinds,
72ImmutableHashSet<CaseKind> distinctCaseKinds,
73ImmutableHashSet<ISymbol> distinctReferencedSymbols,
74ImmutableHashSet<object> distinctReferencedConstants)
95ImmutableHashSet<OperationKind>.Builder? distinctOperatorKindsBuilder = null;
96ImmutableHashSet<BinaryOperatorKind>.Builder? distinctBinaryOperatorKindsBuilder = null;
97ImmutableHashSet<UnaryOperatorKind>.Builder? distinctUnaryOperatorKindsBuilder = null;
98ImmutableHashSet<CaseKind>.Builder? distinctCaseKindsBuilder = null;
99ImmutableHashSet<ISymbol>.Builder? distinctReferencedSymbolsBuilder = null;
100ImmutableHashSet<object>.Builder? distinctReferencedConstantsBuilder = null;
290distinctOperatorKindsBuilder != null ? distinctOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<OperationKind>.Empty,
291distinctBinaryOperatorKindsBuilder != null ? distinctBinaryOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<BinaryOperatorKind>.Empty,
292distinctUnaryOperatorKindsBuilder != null ? distinctUnaryOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<UnaryOperatorKind>.Empty,
293distinctCaseKindsBuilder != null ? distinctCaseKindsBuilder.ToImmutable() : ImmutableHashSet<CaseKind>.Empty,
294distinctReferencedSymbolsBuilder != null ? distinctReferencedSymbolsBuilder.ToImmutable() : ImmutableHashSet<ISymbol>.Empty,
295distinctReferencedConstantsBuilder != null ? distinctReferencedConstantsBuilder.ToImmutable() : ImmutableHashSet<object>.Empty);
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (7)
39internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
40ImmutableHashSet<INamedTypeSymbol> coupledTypes)
48internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
54internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
195ImmutableHashSet<INamedTypeSymbol>.Builder builder,
349private static void AddCoupledNamedTypesCore(ImmutableHashSet<INamedTypeSymbol>.Builder builder, ITypeSymbol typeOpt,
400internal static void RemoveContainingTypes(ISymbol symbol, ImmutableHashSet<INamedTypeSymbol>.Builder coupledTypesBuilder)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\IDictionaryExtensions.cs (7)
100public static bool MultiAdd<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value, IEqualityComparer<TValue>? comparer = null)
103if (dictionary.TryGetValue(key, out var set))
105var updated = set.Add(value);
158public static ImmutableDictionary<TKey, ImmutableHashSet<TValue>> MultiRemove<TKey, TValue>(this ImmutableDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
161if (dictionary.TryGetValue(key, out var collection))
200public static void MultiRemove<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
Microsoft.CodeAnalysis.Test.Utilities (2)
Microsoft.CodeAnalysis.Threading.Package (68)
Microsoft.CodeAnalysis.UnitTests (3)
Microsoft.CodeAnalysis.VisualBasic (25)
Declarations\DeclarationTreeBuilder.vb (10)
115Private Function CreateImplicitClass(parent As VisualBasicSyntaxNode, memberNames As ImmutableHashSet(Of String), children As ImmutableArray(Of SingleTypeDeclaration), declFlags As SingleTypeDeclaration.TypeDeclarationFlags) As SingleNamespaceOrTypeDeclaration
131Private Function CreateScriptClass(parent As VisualBasicSyntaxNode, children As ImmutableArray(Of SingleTypeDeclaration), memberNames As ImmutableHashSet(Of String), declFlags As SingleTypeDeclaration.TypeDeclarationFlags) As SingleNamespaceOrTypeDeclaration
604Private Shared ReadOnly s_memberNameBuilderPool As New ObjectPool(Of ImmutableHashSet(Of String).Builder)(
607Private Shared Function ToImmutableAndFree(builder As ImmutableHashSet(Of String).Builder) As ImmutableHashSet(Of String)
614Private Function GetNonTypeMemberNames(members As SyntaxList(Of StatementSyntax), ByRef declFlags As SingleTypeDeclaration.TypeDeclarationFlags) As ImmutableHashSet(Of String)
707Private Function GetMemberNames(enumBlockSyntax As EnumBlockSyntax, ByRef declFlags As SingleTypeDeclaration.TypeDeclarationFlags) As ImmutableHashSet(Of String)
736Private Sub AddMemberNames(methodDecl As MethodBaseSyntax, results As ImmutableHashSet(Of String).Builder)
757memberNames:=ImmutableHashSet(Of String).Empty,
783memberNames:=ImmutableHashSet(Of String).Empty,
Microsoft.CodeAnalysis.VisualBasic.Analyzers (2)
Microsoft.CodeAnalysis.VisualBasic.CodeStyle (1)
Microsoft.CodeAnalysis.VisualBasic.Features (24)
Microsoft.CodeAnalysis.VisualBasic.Workspaces (5)
Microsoft.CodeAnalysis.Workspaces (226)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\IDictionaryExtensions.cs (7)
100public static bool MultiAdd<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value, IEqualityComparer<TValue>? comparer = null)
103if (dictionary.TryGetValue(key, out var set))
105var updated = set.Add(value);
158public static ImmutableDictionary<TKey, ImmutableHashSet<TValue>> MultiRemove<TKey, TValue>(this ImmutableDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
161if (dictionary.TryGetValue(key, out var collection))
200public static void MultiRemove<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
Workspace\Solution\ProjectDependencyGraph.cs (45)
35private readonly ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> _referencesMap;
45private ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>>? _lazyReverseReferencesMap;
56private ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> _transitiveReferencesMap;
57private ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> _reverseTransitiveReferencesMap;
60private static readonly ObjectPool<ImmutableHashSet<ProjectId>.Builder> s_reverseReferencesBuilderPool = new(static () => ImmutableHashSet.CreateBuilder<ProjectId>(), size: 256);
69ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>>.Empty,
71ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>>.Empty,
72ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>>.Empty,
77ImmutableHashSet<ProjectId> projectIds,
78ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> referencesMap)
83transitiveReferencesMap: ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>>.Empty,
84reverseTransitiveReferencesMap: ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>>.Empty,
92ImmutableHashSet<ProjectId> projectIds,
93ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> referencesMap,
94ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>>? reverseReferencesMap,
95ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> transitiveReferencesMap,
96ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> reverseTransitiveReferencesMap,
115internal ImmutableHashSet<ProjectId> ProjectIds { get; }
117private static ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> RemoveItemsWithEmptyValues(
118ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> map)
120ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>>.Builder? builder = null;
154var referencedProjectIds = projectReferences.IsEmpty() ? [] :
203private ImmutableHashSet<ProjectId> GetProjectsThatDirectlyDependOnThisProject_NoLock(ProjectId projectId)
214private ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> ComputeReverseReferencesMap()
216using var _1 = PooledDictionary<ProjectId, ImmutableHashSet<ProjectId>.Builder>.GetInstance(out var reverseReferencesMapBuilders);
232var reverseReferencesBuilder = ImmutableDictionary.CreateBuilder<ProjectId, ImmutableHashSet<ProjectId>>();
236var reverseReferencesForProject = builder.ToImmutableHashSet();
252internal ImmutableHashSet<ProjectId>? TryGetProjectsThatThisProjectTransitivelyDependsOn(ProjectId projectId)
259_transitiveReferencesMap.TryGetValue(projectId, out var projects);
275if (currentMap.TryGetValue(projectId, out var transitiveReferences))
288private ImmutableHashSet<ProjectId> GetProjectsThatThisProjectTransitivelyDependsOn_NoLock(ProjectId projectId)
290if (!_transitiveReferencesMap.TryGetValue(projectId, out var transitiveReferences))
327if (currentMap.TryGetValue(projectId, out var reverseTransitiveReferences))
340private ImmutableHashSet<ProjectId> GetProjectsThatTransitivelyDependOnThisProject_NoLock(ProjectId projectId)
342if (!_reverseTransitiveReferencesMap.TryGetValue(projectId, out var reverseTransitiveReferences))
357var otherProjects = this.GetProjectsThatDirectlyDependOnThisProject_NoLock(project);
410if (_referencesMap.TryGetValue(projectId, out var projectReferenceIds))
489ImmutableHashSet<ProjectId> projectIds,
490ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> referencesMap)
509ImmutableHashSet<ProjectId> projectIds,
510ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> forwardReferencesMap,
511ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>>? reverseReferencesMap)
549public ImmutableHashSet<ProjectId>? TryGetProjectsThatTransitivelyDependOnThisProject(ProjectId projectId)
556instance._reverseTransitiveReferencesMap.TryGetValue(projectId, out var projects);
568var forwardDependencies = TryGetProjectsThatThisProjectTransitivelyDependsOn(id);
Workspace\Solution\ProjectDependencyGraph_AddProjectReference.cs (13)
58private static ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> ComputeNewReferencesMapForAdditionalProjectReferences(
59ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> existingReferencesMap,
63if (existingReferencesMap.TryGetValue(projectId, out var existingReferences))
78private static ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>>? ComputeNewReverseReferencesMapForAdditionalProjectReferences(
79ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>>? existingReverseReferencesMap,
99private static ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> ComputeNewTransitiveReferencesMapForAdditionalProjectReferences(
100ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> existingTransitiveReferencesMap,
112if (existingTransitiveReferencesMap.TryGetValue(referencedProjectId, out var additionalTransitiveReferences))
128existingTransitiveReferencesMap.TryGetValue(projectIdToUpdate, out var existingTransitiveReferences);
155private static ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> ComputeNewReverseTransitiveReferencesMapForAdditionalProjectReferences(
156ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> existingReverseTransitiveReferencesMap,
164existingReverseTransitiveReferencesMap.TryGetValue(projectId, out var newReverseTranstiveReferences);
176existingReverseTransitiveReferencesMap.TryGetValue(projectIdToUpdate, out var existingReverseTransitiveReferences);
Workspace\Solution\ProjectDependencyGraph_RemoveAllProjectReferences.cs (12)
18if (!_referencesMap.TryGetValue(projectId, out var referencedProjectIds))
22var projectIds = ProjectIds;
40private static ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> ComputeNewReferencesMapForRemovedAllProjectReferences(
41ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> existingForwardReferencesMap,
58private static ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>>? ComputeNewReverseReferencesMapForRemovedAllProjectReferences(
59ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>>? existingReverseReferencesMap,
61ImmutableHashSet<ProjectId> referencedProjectIds)
77private static ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> ComputeNewTransitiveReferencesMapForRemovedAllProjectReferences(
78ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> existingTransitiveReferencesMap,
80ImmutableHashSet<ProjectId> referencedProjectIds)
104private static ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> ComputeNewReverseTransitiveReferencesMapForRemovedAllProjectReferences(
105ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> existingReverseTransitiveReferencesMap,
Workspace\Solution\ProjectDependencyGraph_RemoveProject.cs (13)
21var projectIds = projectIdsBuilder.ToImmutable();
55private static ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> ComputeNewReferencesMapForRemovedProject(
56ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> existingForwardReferencesMap,
57ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>>? existingReverseReferencesMap,
69if (existingReverseReferencesMap.TryGetValue(removedProjectId, out var referencingProjects))
99private static ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>>? ComputeNewReverseReferencesMapForRemovedProject(
100ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> existingForwardReferencesMap,
101ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>>? existingReverseReferencesMap,
113if (!existingForwardReferencesMap.TryGetValue(removedProjectId, out var forwardReferences))
133private static ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> ComputeNewTransitiveReferencesMapForRemovedProject(
134ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> existingTransitiveReferencesMap,
167private static ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> ComputeNewReverseTransitiveReferencesMapForRemovedProject(
168ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> existingReverseTransitiveReferencesMap,
Workspace\Solution\ProjectDependencyGraph_RemoveProjectReference.cs (9)
20var projectIds = ProjectIds;
38private static ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> ComputeNewReferencesMapForRemovedProjectReference(
39ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> existingForwardReferencesMap,
55private static ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>>? ComputeNewReverseReferencesMapForRemovedProjectReference(
56ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>>? existingReverseReferencesMap,
68private static ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> ComputeNewTransitiveReferencesMapForRemovedProjectReference(
69ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> existingTransitiveReferencesMap,
95private static ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> ComputeNewReverseTransitiveReferencesMapForRemovedProjectReference(
96ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> existingReverseTransitiveReferencesMap,
Microsoft.CodeAnalysis.Workspaces.MSBuild (8)
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost (78)
Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests (1)
Microsoft.CodeAnalysis.Workspaces.Test.Utilities (13)
Microsoft.Extensions.Logging.Generators (1)
Microsoft.Gen.Logging (1)
Microsoft.Interop.SourceGeneration (12)
TypeSymbolExtensions.cs (6)
37static bool IsConsideredBlittableWorker(ITypeSymbol t, ImmutableHashSet<ITypeSymbol> seenTypes, Compilation compilation)
62static unsafe bool IsStrictlyBlittableWorker(ITypeSymbol t, ImmutableHashSet<ITypeSymbol> seenTypes, Compilation compilation)
100private static unsafe bool IsBlittableWorker(this ITypeSymbol type, ImmutableHashSet<ITypeSymbol> seenTypes, Compilation compilation, delegate*<ITypeSymbol, ImmutableHashSet<ITypeSymbol>, Compilation, bool> isBlittable)
147private static unsafe bool HasOnlyBlittableFields(this ITypeSymbol type, ImmutableHashSet<ITypeSymbol> seenTypes, Compilation compilation, delegate*<ITypeSymbol, ImmutableHashSet<ITypeSymbol>, Compilation, bool> isBlittable)
Microsoft.VisualStudio.LanguageServices (29)
Microsoft.VisualStudio.LanguageServices.CSharp (1)
Microsoft.VisualStudio.LanguageServices.LiveShare (4)
Microsoft.VisualStudio.LanguageServices.UnitTests (2)
Diagnostics\ExternalDiagnosticUpdateSourceTests.vb (2)
322Public Function GetDiagnosticsForIdsAsync(project As Project, documentId As DocumentId, diagnosticIds As ImmutableHashSet(Of String), shouldIncludeAnalyzer As Func(Of DiagnosticAnalyzer, Boolean), includeLocalDocumentDiagnostics As Boolean, includeNonLocalDocumentDiagnostics As Boolean, cancellationToken As CancellationToken) As Task(Of ImmutableArray(Of DiagnosticData)) Implements IDiagnosticAnalyzerService.GetDiagnosticsForIdsAsync
326Public Function GetProjectDiagnosticsForIdsAsync(project As Project, diagnosticIds As ImmutableHashSet(Of String), shouldIncludeAnalyzer As Func(Of DiagnosticAnalyzer, Boolean), includeNonLocalDocumentDiagnostics As Boolean, cancellationToken As CancellationToken) As Task(Of ImmutableArray(Of DiagnosticData)) Implements IDiagnosticAnalyzerService.GetProjectDiagnosticsForIdsAsync
Microsoft.VisualStudio.LanguageServices.VisualBasic (2)
Roslyn.Diagnostics.Analyzers (187)
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\ComputationalComplexityMetrics.cs (36)
25internal static readonly ComputationalComplexityMetrics Default = new(0, 0, 0, 0, 0, ImmutableHashSet<OperationKind>.Empty,
26ImmutableHashSet<BinaryOperatorKind>.Empty, ImmutableHashSet<UnaryOperatorKind>.Empty, ImmutableHashSet<CaseKind>.Empty, ImmutableHashSet<ISymbol>.Empty, ImmutableHashSet<object>.Empty);
30private readonly ImmutableHashSet<OperationKind> _distinctOperatorKinds;
31private readonly ImmutableHashSet<BinaryOperatorKind> _distinctBinaryOperatorKinds;
32private readonly ImmutableHashSet<UnaryOperatorKind> _distinctUnaryOperatorKinds;
33private readonly ImmutableHashSet<CaseKind> _distinctCaseKinds;
34private readonly ImmutableHashSet<ISymbol> _distinctReferencedSymbols;
35private readonly ImmutableHashSet<object> _distinctReferencedConstants;
43ImmutableHashSet<OperationKind> distinctOperatorKinds,
44ImmutableHashSet<BinaryOperatorKind> distinctBinaryOperatorKinds,
45ImmutableHashSet<UnaryOperatorKind> distinctUnaryOperatorKinds,
46ImmutableHashSet<CaseKind> distinctCaseKinds,
47ImmutableHashSet<ISymbol> distinctReferencedSymbols,
48ImmutableHashSet<object> distinctReferencedConstants)
69ImmutableHashSet<OperationKind> distinctOperatorKinds,
70ImmutableHashSet<BinaryOperatorKind> distinctBinaryOperatorKinds,
71ImmutableHashSet<UnaryOperatorKind> distinctUnaryOperatorKinds,
72ImmutableHashSet<CaseKind> distinctCaseKinds,
73ImmutableHashSet<ISymbol> distinctReferencedSymbols,
74ImmutableHashSet<object> distinctReferencedConstants)
95ImmutableHashSet<OperationKind>.Builder? distinctOperatorKindsBuilder = null;
96ImmutableHashSet<BinaryOperatorKind>.Builder? distinctBinaryOperatorKindsBuilder = null;
97ImmutableHashSet<UnaryOperatorKind>.Builder? distinctUnaryOperatorKindsBuilder = null;
98ImmutableHashSet<CaseKind>.Builder? distinctCaseKindsBuilder = null;
99ImmutableHashSet<ISymbol>.Builder? distinctReferencedSymbolsBuilder = null;
100ImmutableHashSet<object>.Builder? distinctReferencedConstantsBuilder = null;
290distinctOperatorKindsBuilder != null ? distinctOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<OperationKind>.Empty,
291distinctBinaryOperatorKindsBuilder != null ? distinctBinaryOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<BinaryOperatorKind>.Empty,
292distinctUnaryOperatorKindsBuilder != null ? distinctUnaryOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<UnaryOperatorKind>.Empty,
293distinctCaseKindsBuilder != null ? distinctCaseKindsBuilder.ToImmutable() : ImmutableHashSet<CaseKind>.Empty,
294distinctReferencedSymbolsBuilder != null ? distinctReferencedSymbolsBuilder.ToImmutable() : ImmutableHashSet<ISymbol>.Empty,
295distinctReferencedConstantsBuilder != null ? distinctReferencedConstantsBuilder.ToImmutable() : ImmutableHashSet<object>.Empty);
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (7)
39internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
40ImmutableHashSet<INamedTypeSymbol> coupledTypes)
48internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
54internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
195ImmutableHashSet<INamedTypeSymbol>.Builder builder,
349private static void AddCoupledNamedTypesCore(ImmutableHashSet<INamedTypeSymbol>.Builder builder, ITypeSymbol typeOpt,
400internal static void RemoveContainingTypes(ISymbol symbol, ImmutableHashSet<INamedTypeSymbol>.Builder coupledTypesBuilder)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\IDictionaryExtensions.cs (7)
100public static bool MultiAdd<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value, IEqualityComparer<TValue>? comparer = null)
103if (dictionary.TryGetValue(key, out var set))
105var updated = set.Add(value);
158public static ImmutableDictionary<TKey, ImmutableHashSet<TValue>> MultiRemove<TKey, TValue>(this ImmutableDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
161if (dictionary.TryGetValue(key, out var collection))
200public static void MultiRemove<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
Roslyn.Diagnostics.CSharp.Analyzers (7)
Roslyn.Diagnostics.VisualBasic.Analyzers (3)
RunTests (1)
System.Collections.Immutable (116)
System\Collections\Immutable\ImmutableHashSet_1.Builder.cs (27)
11/// Contains the inner <see cref="ImmutableHashSet{T}.Builder"/> class.
21/// While <see cref="ImmutableHashSet{T}.Union(IEnumerable{T})"/> and other bulk change methods
56private ImmutableHashSet<T>? _immutable;
64/// Initializes a new instance of the <see cref="ImmutableHashSet{T}.Builder"/> class.
67internal Builder(ImmutableHashSet<T> set)
118ImmutableHashSet<T>.MutationResult result = Union(this, new MutationInput(SortedInt32KeyNode<HashBucket>.EmptyNode, value, _hashBucketEqualityComparer, 0));
192public ImmutableHashSet<T> ToImmutable()
197return _immutable ??= ImmutableHashSet<T>.Wrap(_root, _equalityComparer, _count);
229ImmutableHashSet<T>.MutationResult result = ImmutableHashSet<T>.Add(item, this.Origin);
244ImmutableHashSet<T>.MutationResult result = ImmutableHashSet<T>.Remove(item, this.Origin);
258return ImmutableHashSet<T>.Contains(item, this.Origin);
277ImmutableHashSet<T>.MutationResult result = ImmutableHashSet<T>.Except(other, _equalityComparer, _hashBucketEqualityComparer, _root);
287ImmutableHashSet<T>.MutationResult result = ImmutableHashSet<T>.Intersect(other, this.Origin);
298return ImmutableHashSet<T>.IsProperSubsetOf(other, this.Origin);
308return ImmutableHashSet<T>.IsProperSupersetOf(other, this.Origin);
318return ImmutableHashSet<T>.IsSubsetOf(other, this.Origin);
328return ImmutableHashSet<T>.IsSupersetOf(other, this.Origin);
338return ImmutableHashSet<T>.Overlaps(other, this.Origin);
353return ImmutableHashSet<T>.SetEquals(other, this.Origin);
362ImmutableHashSet<T>.MutationResult result = ImmutableHashSet<T>.SymmetricExcept(other, this.Origin);
372ImmutableHashSet<T>.MutationResult result = ImmutableHashSet<T>.Union(other, this.Origin);
System\Collections\Immutable\ImmutableHashSet_1.cs (41)
19public sealed partial class ImmutableHashSet<T> : IImmutableSet<T>, IReadOnlyCollection<T>, ICollection<T>, ISet<T>, IReadOnlySet<T>, ICollection, IStrongEnumerable<T, ImmutableHashSet<T>.Enumerator>
27public static readonly ImmutableHashSet<T> Empty = new ImmutableHashSet<T>(SortedInt32KeyNode<HashBucket>.EmptyNode, EqualityComparer<T>.Default, 0);
55/// Initializes a new instance of the <see cref="ImmutableHashSet{T}"/> class.
64/// Initializes a new instance of the <see cref="ImmutableHashSet{T}"/> class.
84public ImmutableHashSet<T> Clear()
86return this.IsEmpty ? this : ImmutableHashSet<T>.Empty.WithComparer(_equalityComparer);
181public ImmutableHashSet<T> Add(T item)
183ImmutableHashSet<T>.MutationResult result = Add(item, this.Origin);
190public ImmutableHashSet<T> Remove(T item)
192ImmutableHashSet<T>.MutationResult result = Remove(item, this.Origin);
224public ImmutableHashSet<T> Union(IEnumerable<T> other)
234internal ImmutableHashSet<T> Union(ReadOnlySpan<T> other)
242public ImmutableHashSet<T> Intersect(IEnumerable<T> other)
246ImmutableHashSet<T>.MutationResult result = Intersect(other, this.Origin);
253public ImmutableHashSet<T> Except(IEnumerable<T> other)
257ImmutableHashSet<T>.MutationResult result = Except(other, _equalityComparer, _hashBucketEqualityComparer, _root);
266public ImmutableHashSet<T> SymmetricExcept(IEnumerable<T> other)
270ImmutableHashSet<T>.MutationResult result = SymmetricExcept(other, this.Origin);
416public ImmutableHashSet<T> WithComparer(IEqualityComparer<T>? equalityComparer)
426var result = new ImmutableHashSet<T>(equalityComparer);
619ImmutableHashSet<T>.HashBucket newBucket = bucket.Add(item, origin.EqualityComparer, out result);
625SortedInt32KeyNode<ImmutableHashSet<T>.HashBucket> newRoot = UpdateRoot(origin.Root, hashCode, origin.HashBucketEqualityComparer, newBucket);
635ImmutableHashSet<T>.OperationResult result = OperationResult.NoChangeRequired;
638SortedInt32KeyNode<ImmutableHashSet<T>.HashBucket> newRoot = origin.Root;
641ImmutableHashSet<T>.HashBucket newBucket = bucket.Remove(item, origin.EqualityComparer, out result);
676SortedInt32KeyNode<ImmutableHashSet<T>.HashBucket> newRoot = origin.Root;
682ImmutableHashSet<T>.HashBucket newBucket = bucket.Add(item, origin.EqualityComparer, out result);
699SortedInt32KeyNode<ImmutableHashSet<T>.HashBucket> newRoot = origin.Root;
705ImmutableHashSet<T>.HashBucket newBucket = bucket.Add(item, origin.EqualityComparer, out result);
784SortedInt32KeyNode<ImmutableHashSet<T>.HashBucket> newSet = SortedInt32KeyNode<HashBucket>.EmptyNode;
790ImmutableHashSet<T>.MutationResult result = Add(item, new MutationInput(newSet, origin.EqualityComparer, origin.HashBucketEqualityComparer, count));
809SortedInt32KeyNode<ImmutableHashSet<T>.HashBucket> newRoot = root;
836ImmutableHashSet<T> otherAsSet = ImmutableHashSet.CreateRange(origin.EqualityComparer, other);
839SortedInt32KeyNode<ImmutableHashSet<T>.HashBucket> result = SortedInt32KeyNode<HashBucket>.EmptyNode;
844ImmutableHashSet<T>.MutationResult mutationResult = Add(item, new MutationInput(result, origin.EqualityComparer, origin.HashBucketEqualityComparer, count));
854ImmutableHashSet<T>.MutationResult mutationResult = Add(item, new MutationInput(result, origin.EqualityComparer, origin.HashBucketEqualityComparer, count));
978private static ImmutableHashSet<T> Wrap(SortedInt32KeyNode<HashBucket> root, IEqualityComparer<T> equalityComparer, int count)
1013private ImmutableHashSet<T> Wrap(SortedInt32KeyNode<HashBucket> root, int adjustedCountIfDifferentRoot)
1023private ImmutableHashSet<T> Union(IEnumerable<T> items, bool avoidWithComparer)
1032if (items is ImmutableHashSet<T> other)
1038ImmutableHashSet<T>.MutationResult result = Union(items, this.Origin);
System.Text.Json.SourceGeneration (1)
System.Windows.Forms.Tests (1)
Test.Utilities (130)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\IDictionaryExtensions.cs (7)
100public static bool MultiAdd<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value, IEqualityComparer<TValue>? comparer = null)
103if (dictionary.TryGetValue(key, out var set))
105var updated = set.Add(value);
158public static ImmutableDictionary<TKey, ImmutableHashSet<TValue>> MultiRemove<TKey, TValue>(this ImmutableDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
161if (dictionary.TryGetValue(key, out var collection))
200public static void MultiRemove<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
Text.Analyzers (186)
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\ComputationalComplexityMetrics.cs (36)
25internal static readonly ComputationalComplexityMetrics Default = new(0, 0, 0, 0, 0, ImmutableHashSet<OperationKind>.Empty,
26ImmutableHashSet<BinaryOperatorKind>.Empty, ImmutableHashSet<UnaryOperatorKind>.Empty, ImmutableHashSet<CaseKind>.Empty, ImmutableHashSet<ISymbol>.Empty, ImmutableHashSet<object>.Empty);
30private readonly ImmutableHashSet<OperationKind> _distinctOperatorKinds;
31private readonly ImmutableHashSet<BinaryOperatorKind> _distinctBinaryOperatorKinds;
32private readonly ImmutableHashSet<UnaryOperatorKind> _distinctUnaryOperatorKinds;
33private readonly ImmutableHashSet<CaseKind> _distinctCaseKinds;
34private readonly ImmutableHashSet<ISymbol> _distinctReferencedSymbols;
35private readonly ImmutableHashSet<object> _distinctReferencedConstants;
43ImmutableHashSet<OperationKind> distinctOperatorKinds,
44ImmutableHashSet<BinaryOperatorKind> distinctBinaryOperatorKinds,
45ImmutableHashSet<UnaryOperatorKind> distinctUnaryOperatorKinds,
46ImmutableHashSet<CaseKind> distinctCaseKinds,
47ImmutableHashSet<ISymbol> distinctReferencedSymbols,
48ImmutableHashSet<object> distinctReferencedConstants)
69ImmutableHashSet<OperationKind> distinctOperatorKinds,
70ImmutableHashSet<BinaryOperatorKind> distinctBinaryOperatorKinds,
71ImmutableHashSet<UnaryOperatorKind> distinctUnaryOperatorKinds,
72ImmutableHashSet<CaseKind> distinctCaseKinds,
73ImmutableHashSet<ISymbol> distinctReferencedSymbols,
74ImmutableHashSet<object> distinctReferencedConstants)
95ImmutableHashSet<OperationKind>.Builder? distinctOperatorKindsBuilder = null;
96ImmutableHashSet<BinaryOperatorKind>.Builder? distinctBinaryOperatorKindsBuilder = null;
97ImmutableHashSet<UnaryOperatorKind>.Builder? distinctUnaryOperatorKindsBuilder = null;
98ImmutableHashSet<CaseKind>.Builder? distinctCaseKindsBuilder = null;
99ImmutableHashSet<ISymbol>.Builder? distinctReferencedSymbolsBuilder = null;
100ImmutableHashSet<object>.Builder? distinctReferencedConstantsBuilder = null;
290distinctOperatorKindsBuilder != null ? distinctOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<OperationKind>.Empty,
291distinctBinaryOperatorKindsBuilder != null ? distinctBinaryOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<BinaryOperatorKind>.Empty,
292distinctUnaryOperatorKindsBuilder != null ? distinctUnaryOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<UnaryOperatorKind>.Empty,
293distinctCaseKindsBuilder != null ? distinctCaseKindsBuilder.ToImmutable() : ImmutableHashSet<CaseKind>.Empty,
294distinctReferencedSymbolsBuilder != null ? distinctReferencedSymbolsBuilder.ToImmutable() : ImmutableHashSet<ISymbol>.Empty,
295distinctReferencedConstantsBuilder != null ? distinctReferencedConstantsBuilder.ToImmutable() : ImmutableHashSet<object>.Empty);
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (7)
39internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
40ImmutableHashSet<INamedTypeSymbol> coupledTypes)
48internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
54internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
195ImmutableHashSet<INamedTypeSymbol>.Builder builder,
349private static void AddCoupledNamedTypesCore(ImmutableHashSet<INamedTypeSymbol>.Builder builder, ITypeSymbol typeOpt,
400internal static void RemoveContainingTypes(ISymbol symbol, ImmutableHashSet<INamedTypeSymbol>.Builder coupledTypesBuilder)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\IDictionaryExtensions.cs (7)
100public static bool MultiAdd<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value, IEqualityComparer<TValue>? comparer = null)
103if (dictionary.TryGetValue(key, out var set))
105var updated = set.Add(value);
158public static ImmutableDictionary<TKey, ImmutableHashSet<TValue>> MultiRemove<TKey, TValue>(this ImmutableDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
161if (dictionary.TryGetValue(key, out var collection))
200public static void MultiRemove<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
xunit.assert (2)