Skip to content

[Engineering task] Replace ConcurrentHashSet<T> with ConcurrentDictionary<T, byte> from the framework #5953

@gladjohn

Description

@gladjohn

Task type

Development

Description

ConcurrentHashSet (in src/client/Microsoft.Identity.Client/Utils/ConcurrentHashSet.cs) is copied from i3arnon/ConcurrentHashSet (https://github.com/i3arnon/ConcurrentHashSet) and carries ~400 lines of custom concurrent collection code that we maintain but don't own.

.NET provides ConcurrentDictionary<TKey, TValue> which can serve as a thread-safe set using ConcurrentDictionary<T, byte> with a dummy value.

Current usage — only one place:

  • AuthorityManager.s_validatedEnvironments (src/client/Microsoft.Identity.Client/Instance/AuthorityManager.cs:20)

Solution

  1. Replace ConcurrentHashSet with ConcurrentDictionary<string, byte> in AuthorityManager
  2. Map API calls: Add() → TryAdd(key, 0), Contains() → ContainsKey()
  3. Delete ConcurrentHashSet.cs (~400 lines)

Metadata

Metadata

Labels

internaluntriagedDo not delete. Needed for Automation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions