@@ -23,7 +23,14 @@ namespace Microsoft.VisualStudio.Razor.Discovery;
2323[ Export ( typeof ( IRazorStartupService ) ) ]
2424internal partial class ProjectStateChangeDetector : IRazorStartupService , IDisposable
2525{
26- private readonly record struct Work ( ProjectKey Key , ProjectId ? Id ) ;
26+ private readonly record struct Work ( ProjectKey Key , ProjectId ? Id )
27+ {
28+ public bool Equals ( Work other )
29+ => Key . Equals ( other . Key ) ;
30+
31+ public override int GetHashCode ( )
32+ => Key . GetHashCode ( ) ;
33+ }
2734
2835 private static readonly TimeSpan s_delay = TimeSpan . FromSeconds ( 1 ) ;
2936
@@ -34,6 +41,7 @@ internal partial class ProjectStateChangeDetector : IRazorStartupService, IDispo
3441
3542 private readonly CancellationTokenSource _disposeTokenSource ;
3643 private readonly AsyncBatchingWorkQueue < Work > _workQueue ;
44+ private readonly HashSet < Work > _workerSet ;
3745
3846 /// <summary>
3947 /// A map of assembly path strings to ProjectKeys. This will be cleared when the solution is closed.
@@ -63,6 +71,7 @@ public ProjectStateChangeDetector(
6371 _projectManager = projectManager ;
6472 _options = options ;
6573
74+ _workerSet = [ ] ;
6675 _disposeTokenSource = new ( ) ;
6776 _workQueue = new AsyncBatchingWorkQueue < Work > (
6877 delay ,
@@ -95,7 +104,9 @@ public void Dispose()
95104
96105 private ValueTask ProcessBatchAsync ( ImmutableArray < Work > items , CancellationToken token )
97106 {
98- foreach ( var ( projectKey , projectId ) in items . GetMostRecentUniqueItems ( Comparer . Instance ) )
107+ _workerSet . Clear ( ) ;
108+
109+ foreach ( var ( projectKey , projectId ) in items . GetMostRecentUniqueItems ( _workerSet ) )
99110 {
100111 if ( token . IsCancellationRequested )
101112 {
0 commit comments