@@ -113,12 +113,13 @@ public static SolutionCompilationStateChecksums Deserialize(ObjectReader reader)
113113 return result ;
114114 }
115115
116- public async Task FindAsync (
116+ public async Task FindAsync < TArg > (
117117 SolutionCompilationState compilationState ,
118118 ProjectCone ? projectCone ,
119119 AssetPath assetPath ,
120120 HashSet < Checksum > searchingChecksumsLeft ,
121- Action < Checksum , object > onAssetFound ,
121+ Action < Checksum , object , TArg > onAssetFound ,
122+ TArg arg ,
122123 CancellationToken cancellationToken )
123124 {
124125 cancellationToken . ThrowIfCancellationRequested ( ) ;
@@ -128,10 +129,10 @@ public async Task FindAsync(
128129 if ( assetPath . IncludeSolutionCompilationState )
129130 {
130131 if ( assetPath . IncludeSolutionCompilationStateChecksums && searchingChecksumsLeft . Remove ( this . Checksum ) )
131- onAssetFound ( this . Checksum , this ) ;
132+ onAssetFound ( this . Checksum , this , arg ) ;
132133
133134 if ( assetPath . IncludeSolutionSourceGeneratorExecutionVersionMap && searchingChecksumsLeft . Remove ( this . SourceGeneratorExecutionVersionMap ) )
134- onAssetFound ( this . SourceGeneratorExecutionVersionMap , compilationState . SourceGeneratorExecutionVersionMap ) ;
135+ onAssetFound ( this . SourceGeneratorExecutionVersionMap , compilationState . SourceGeneratorExecutionVersionMap , arg ) ;
135136
136137 if ( compilationState . FrozenSourceGeneratedDocumentStates != null )
137138 {
@@ -143,7 +144,7 @@ public async Task FindAsync(
143144 {
144145 await ChecksumCollection . FindAsync (
145146 new AssetPath ( AssetPathKind . DocumentText , assetPath . ProjectId , assetPath . DocumentId ) ,
146- compilationState . FrozenSourceGeneratedDocumentStates , searchingChecksumsLeft , onAssetFound , cancellationToken ) . ConfigureAwait ( false ) ;
147+ compilationState . FrozenSourceGeneratedDocumentStates , searchingChecksumsLeft , onAssetFound , arg , cancellationToken ) . ConfigureAwait ( false ) ;
147148 }
148149
149150 // ... or one of the identities. In this case, we'll use the fact that there's a 1:1 correspondence between the
@@ -161,7 +162,7 @@ await ChecksumCollection.FindAsync(
161162 if ( searchingChecksumsLeft . Remove ( identityChecksum ) )
162163 {
163164 Contract . ThrowIfFalse ( compilationState . FrozenSourceGeneratedDocumentStates . TryGetState ( documentId , out var state ) ) ;
164- onAssetFound ( identityChecksum , state . Identity ) ;
165+ onAssetFound ( identityChecksum , state . Identity , arg ) ;
165166 }
166167 }
167168 }
@@ -175,7 +176,7 @@ await ChecksumCollection.FindAsync(
175176 {
176177 var id = FrozenSourceGeneratedDocuments . Value . Ids [ i ] ;
177178 Contract . ThrowIfFalse ( compilationState . FrozenSourceGeneratedDocumentStates . TryGetState ( id , out var state ) ) ;
178- onAssetFound ( identityChecksum , state . Identity ) ;
179+ onAssetFound ( identityChecksum , state . Identity , arg ) ;
179180 }
180181 }
181182 }
@@ -189,13 +190,13 @@ await ChecksumCollection.FindAsync(
189190 // If we're not in a project cone, start the search at the top most state-checksum corresponding to the
190191 // entire solution.
191192 Contract . ThrowIfFalse ( solutionState . TryGetStateChecksums ( out var solutionChecksums ) ) ;
192- await solutionChecksums . FindAsync ( solutionState , projectCone , assetPath , searchingChecksumsLeft , onAssetFound , cancellationToken ) . ConfigureAwait ( false ) ;
193+ await solutionChecksums . FindAsync ( solutionState , projectCone , assetPath , searchingChecksumsLeft , onAssetFound , arg , cancellationToken ) . ConfigureAwait ( false ) ;
193194 }
194195 else
195196 {
196197 // Otherwise, grab the top-most state checksum for this cone and search within that.
197198 Contract . ThrowIfFalse ( solutionState . TryGetStateChecksums ( projectCone . RootProjectId , out var solutionChecksums ) ) ;
198- await solutionChecksums . FindAsync ( solutionState , projectCone , assetPath , searchingChecksumsLeft , onAssetFound , cancellationToken ) . ConfigureAwait ( false ) ;
199+ await solutionChecksums . FindAsync ( solutionState , projectCone , assetPath , searchingChecksumsLeft , onAssetFound , arg , cancellationToken ) . ConfigureAwait ( false ) ;
199200 }
200201 }
201202}
@@ -264,12 +265,13 @@ public static SolutionStateChecksums Deserialize(ObjectReader reader)
264265 return result ;
265266 }
266267
267- public async Task FindAsync (
268+ public async Task FindAsync < TArg > (
268269 SolutionState solution ,
269270 ProjectCone ? projectCone ,
270271 AssetPath assetPath ,
271272 HashSet < Checksum > searchingChecksumsLeft ,
272- Action < Checksum , object > onAssetFound ,
273+ Action < Checksum , object , TArg > onAssetFound ,
274+ TArg arg ,
273275 CancellationToken cancellationToken )
274276 {
275277 cancellationToken . ThrowIfCancellationRequested ( ) ;
@@ -279,13 +281,13 @@ public async Task FindAsync(
279281 if ( assetPath . IncludeSolutionState )
280282 {
281283 if ( assetPath . IncludeSolutionStateChecksums && searchingChecksumsLeft . Remove ( Checksum ) )
282- onAssetFound ( Checksum , this ) ;
284+ onAssetFound ( Checksum , this , arg ) ;
283285
284286 if ( assetPath . IncludeSolutionAttributes && searchingChecksumsLeft . Remove ( Attributes ) )
285- onAssetFound ( Attributes , solution . SolutionAttributes ) ;
287+ onAssetFound ( Attributes , solution . SolutionAttributes , arg ) ;
286288
287289 if ( assetPath . IncludeSolutionAnalyzerReferences )
288- ChecksumCollection . Find ( solution . AnalyzerReferences , AnalyzerReferences , searchingChecksumsLeft , onAssetFound , cancellationToken ) ;
290+ ChecksumCollection . Find ( solution . AnalyzerReferences , AnalyzerReferences , searchingChecksumsLeft , onAssetFound , arg , cancellationToken ) ;
289291 }
290292
291293 if ( searchingChecksumsLeft . Count == 0 )
@@ -304,7 +306,7 @@ public async Task FindAsync(
304306 if ( projectState != null &&
305307 projectState . TryGetStateChecksums ( out var projectStateChecksums ) )
306308 {
307- await projectStateChecksums . FindAsync ( projectState , assetPath , searchingChecksumsLeft , onAssetFound , cancellationToken ) . ConfigureAwait ( false ) ;
309+ await projectStateChecksums . FindAsync ( projectState , assetPath , searchingChecksumsLeft , onAssetFound , arg , cancellationToken ) . ConfigureAwait ( false ) ;
308310 }
309311 }
310312 else
@@ -327,7 +329,7 @@ public async Task FindAsync(
327329 if ( ! projectState . TryGetStateChecksums ( out var projectStateChecksums ) )
328330 continue ;
329331
330- await projectStateChecksums . FindAsync ( projectState , assetPath , searchingChecksumsLeft , onAssetFound , cancellationToken ) . ConfigureAwait ( false ) ;
332+ await projectStateChecksums . FindAsync ( projectState , assetPath , searchingChecksumsLeft , onAssetFound , arg , cancellationToken ) . ConfigureAwait ( false ) ;
331333 }
332334 }
333335 }
@@ -431,11 +433,12 @@ public static ProjectStateChecksums Deserialize(ObjectReader reader)
431433 return result ;
432434 }
433435
434- public async Task FindAsync (
436+ public async Task FindAsync < TArg > (
435437 ProjectState state ,
436438 AssetPath assetPath ,
437439 HashSet < Checksum > searchingChecksumsLeft ,
438- Action < Checksum , object > onAssetFound ,
440+ Action < Checksum , object , TArg > onAssetFound ,
441+ TArg arg ,
439442 CancellationToken cancellationToken )
440443 {
441444 cancellationToken . ThrowIfCancellationRequested ( ) ;
@@ -449,38 +452,38 @@ public async Task FindAsync(
449452 if ( assetPath . IncludeProjects )
450453 {
451454 if ( assetPath . IncludeProjectStateChecksums && searchingChecksumsLeft . Remove ( Checksum ) )
452- onAssetFound ( Checksum , this ) ;
455+ onAssetFound ( Checksum , this , arg ) ;
453456
454457 if ( assetPath . IncludeProjectAttributes && searchingChecksumsLeft . Remove ( Info ) )
455- onAssetFound ( Info , state . ProjectInfo . Attributes ) ;
458+ onAssetFound ( Info , state . ProjectInfo . Attributes , arg ) ;
456459
457460 if ( assetPath . IncludeProjectCompilationOptions && searchingChecksumsLeft . Remove ( CompilationOptions ) )
458461 {
459462 var compilationOptions = state . CompilationOptions ?? throw new InvalidOperationException ( "We should not be trying to serialize a project with no compilation options; RemoteSupportedLanguages.IsSupported should have filtered it out." ) ;
460- onAssetFound ( CompilationOptions , compilationOptions ) ;
463+ onAssetFound ( CompilationOptions , compilationOptions , arg ) ;
461464 }
462465
463466 if ( assetPath . IncludeProjectParseOptions && searchingChecksumsLeft . Remove ( ParseOptions ) )
464467 {
465468 var parseOptions = state . ParseOptions ?? throw new InvalidOperationException ( "We should not be trying to serialize a project with no parse options; RemoteSupportedLanguages.IsSupported should have filtered it out." ) ;
466- onAssetFound ( ParseOptions , parseOptions ) ;
469+ onAssetFound ( ParseOptions , parseOptions , arg ) ;
467470 }
468471
469472 if ( assetPath . IncludeProjectProjectReferences )
470- ChecksumCollection . Find ( state . ProjectReferences , ProjectReferences , searchingChecksumsLeft , onAssetFound , cancellationToken ) ;
473+ ChecksumCollection . Find ( state . ProjectReferences , ProjectReferences , searchingChecksumsLeft , onAssetFound , arg , cancellationToken ) ;
471474
472475 if ( assetPath . IncludeProjectMetadataReferences )
473- ChecksumCollection . Find ( state . MetadataReferences , MetadataReferences , searchingChecksumsLeft , onAssetFound , cancellationToken ) ;
476+ ChecksumCollection . Find ( state . MetadataReferences , MetadataReferences , searchingChecksumsLeft , onAssetFound , arg , cancellationToken ) ;
474477
475478 if ( assetPath . IncludeProjectAnalyzerReferences )
476- ChecksumCollection . Find ( state . AnalyzerReferences , AnalyzerReferences , searchingChecksumsLeft , onAssetFound , cancellationToken ) ;
479+ ChecksumCollection . Find ( state . AnalyzerReferences , AnalyzerReferences , searchingChecksumsLeft , onAssetFound , arg , cancellationToken ) ;
477480 }
478481
479482 if ( assetPath . IncludeDocuments )
480483 {
481- await ChecksumCollection . FindAsync ( assetPath , state . DocumentStates , searchingChecksumsLeft , onAssetFound , cancellationToken ) . ConfigureAwait ( false ) ;
482- await ChecksumCollection . FindAsync ( assetPath , state . AdditionalDocumentStates , searchingChecksumsLeft , onAssetFound , cancellationToken ) . ConfigureAwait ( false ) ;
483- await ChecksumCollection . FindAsync ( assetPath , state . AnalyzerConfigDocumentStates , searchingChecksumsLeft , onAssetFound , cancellationToken ) . ConfigureAwait ( false ) ;
484+ await ChecksumCollection . FindAsync ( assetPath , state . DocumentStates , searchingChecksumsLeft , onAssetFound , arg , cancellationToken ) . ConfigureAwait ( false ) ;
485+ await ChecksumCollection . FindAsync ( assetPath , state . AdditionalDocumentStates , searchingChecksumsLeft , onAssetFound , arg , cancellationToken ) . ConfigureAwait ( false ) ;
486+ await ChecksumCollection . FindAsync ( assetPath , state . AnalyzerConfigDocumentStates , searchingChecksumsLeft , onAssetFound , arg , cancellationToken ) . ConfigureAwait ( false ) ;
484487 }
485488 }
486489}
@@ -502,24 +505,25 @@ public void AddAllTo(HashSet<Checksum> checksums)
502505 checksums . AddIfNotNullChecksum ( this . Text ) ;
503506 }
504507
505- public async Task FindAsync (
508+ public async Task FindAsync < TArg > (
506509 AssetPath assetPath ,
507510 TextDocumentState state ,
508511 HashSet < Checksum > searchingChecksumsLeft ,
509- Action < Checksum , object > onAssetFound ,
512+ Action < Checksum , object , TArg > onAssetFound ,
513+ TArg arg ,
510514 CancellationToken cancellationToken )
511515 {
512516 Debug . Assert ( state . TryGetStateChecksums ( out var stateChecksum ) && this == stateChecksum ) ;
513517
514518 cancellationToken . ThrowIfCancellationRequested ( ) ;
515519
516520 if ( assetPath . IncludeDocumentAttributes && searchingChecksumsLeft . Remove ( Info ) )
517- onAssetFound ( Info , state . Attributes ) ;
521+ onAssetFound ( Info , state . Attributes , arg ) ;
518522
519523 if ( assetPath . IncludeDocumentText && searchingChecksumsLeft . Remove ( Text ) )
520524 {
521525 var text = await SerializableSourceText . FromTextDocumentStateAsync ( state , cancellationToken ) . ConfigureAwait ( false ) ;
522- onAssetFound ( Text , text ) ;
526+ onAssetFound ( Text , text , arg ) ;
523527 }
524528 }
525529}
0 commit comments