@@ -361,6 +361,9 @@ private void ParseAllInternal(object requestor, CancellationToken token)
361
361
removedModules . UnionWith ( ModulesInProjects ( removedProjects ) ) ;
362
362
token . ThrowIfCancellationRequested ( ) ;
363
363
364
+ var notRemovedDisposedProjects = NotRemovedDisposedProjects ( removedProjects ) ;
365
+ toParse . UnionWith ( ModulesInProjects ( notRemovedDisposedProjects ) ) ;
366
+
364
367
var toReResolveReferences = OtherModulesReferencingAnyNotToBeParsed ( removedModules . AsReadOnly ( ) , toParse . AsReadOnly ( ) ) ;
365
368
token . ThrowIfCancellationRequested ( ) ;
366
369
@@ -371,7 +374,10 @@ private void ParseAllInternal(object requestor, CancellationToken token)
371
374
token . ThrowIfCancellationRequested ( ) ;
372
375
373
376
//This must come after the component cleanup because of cache invalidation.
374
- CleanUpRemovedProjects ( removedProjects ) ;
377
+ CleanUpProjects ( removedProjects ) ;
378
+ token . ThrowIfCancellationRequested ( ) ;
379
+
380
+ CleanUpProjects ( notRemovedDisposedProjects ) ;
375
381
token . ThrowIfCancellationRequested ( ) ;
376
382
377
383
ExecuteCommonParseActivities ( toParse . AsReadOnly ( ) , toReResolveReferences , token ) ;
@@ -384,10 +390,10 @@ private IReadOnlyCollection<QualifiedModuleName> OtherModulesReferencingAnyNotTo
384
390
. ToHashSet ( ) . AsReadOnly ( ) ;
385
391
}
386
392
387
- private IEnumerable < QualifiedModuleName > ModulesInProjects ( IReadOnlyCollection < string > removedProjects )
393
+ private IEnumerable < QualifiedModuleName > ModulesInProjects ( IReadOnlyCollection < string > projectIds )
388
394
{
389
395
return State . DeclarationFinder . UserDeclarations ( DeclarationType . Module )
390
- . Where ( declaration => removedProjects . Contains ( declaration . ProjectId ) )
396
+ . Where ( declaration => projectIds . Contains ( declaration . ProjectId ) )
391
397
. Select ( declaration => declaration . QualifiedName . QualifiedModuleName ) ;
392
398
}
393
399
@@ -410,7 +416,7 @@ private void ClearStateCache(IEnumerable<QualifiedModuleName> modules)
410
416
}
411
417
}
412
418
413
- private void CleanUpRemovedProjects ( IReadOnlyCollection < string > removedProjectIds )
419
+ private void CleanUpProjects ( IReadOnlyCollection < string > removedProjectIds )
414
420
{
415
421
ClearStateCache ( removedProjectIds ) ;
416
422
}
@@ -439,6 +445,17 @@ private IReadOnlyCollection<string> RemovedProjects(IReadOnlyCollection<IVBProje
439
445
return removedProjects . Select ( tuple => tuple . Item1 ) . ToHashSet ( ) . AsReadOnly ( ) ;
440
446
}
441
447
448
+ private IReadOnlyCollection < string > NotRemovedDisposedProjects ( IEnumerable < string > removedProjects )
449
+ {
450
+ var disposedProjects = State . DeclarationFinder
451
+ . UserDeclarations ( DeclarationType . Project )
452
+ . OfType < ProjectDeclaration > ( )
453
+ . Where ( declaration => declaration . IsDisposed )
454
+ . Select ( declaration => declaration . ProjectId )
455
+ . ToHashSet ( ) ;
456
+ disposedProjects . ExceptWith ( removedProjects ) ;
457
+ return disposedProjects . AsReadOnly ( ) ;
458
+ }
442
459
443
460
public void Dispose ( )
444
461
{
0 commit comments