You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
XAML server: in-flight project loads can cache a pre-invalidation graph #215
completed entries whose Result.ContainsProject(key) is true.
The gap: a load for a different root that is still in flight cannot be tested with ContainsProject, because the project graph does not exist until the load completes. If that pending load turns out to reference the invalidated project, it is cached afterwards with a pre-invalidation graph and is never evicted. In practice this can leave IntelliSense stale until the next edit to that project.
An attempted fix — adding || !pair.Value.IsCompleted to the predicate — was reverted, because it is not scoped to key and therefore evicts every in-flight load across all roots. That caused worse problems: DisposeWhenComplete would dispose a RoslynProjectWorkspace that other callers were already awaiting in ResolveAsync, plus duplicated MSBuild design-time loads, plus a possible no-progress loop where saves during a cold load repeatedly restart it.
Suggested work:
Record each pending load's candidate project set (e.g. the project paths known at load kickoff) so pending entries can be tested against key without waiting.
Alternatively, re-check ContainsProject on completion and self-evict, rather than eviction at invalidate time.
Either way, do not dispose a cached workspace task that active ResolveAsync callers may still be awaiting — that hazard exists today even for the same-key path.
Fixed in PR #50 (commits d684a72, 1709b23). One correction to the record, since it affects future work here.
The core report is accurate and is what got fixed: an in-flight load for a different root cannot be tested with ContainsProject, so it could be cached with a pre-invalidation graph and never evicted. Invalidate now records the key on the pending entry and OnLoadCompleted re-tests it against the finished graph and self-evicts. Verified by reverting the recording line and confirming the regression test fails.
The third suggested-work bullet is incorrect and should not be acted on. It states:
do not dispose a cached workspace task that active ResolveAsync callers may still be awaiting -- that hazard exists today even for the same-key path.
I implemented a lease for this before testing the premise. It does not hold. RoslynProjectWorkspace captures an immutable Roslyn Project snapshot in its constructor and serves every read from it (GetCompilationAsync, GetFrameworkCompilation, ContainsProject, XamlFiles, ApplicationDefinitionPath). Only LoadDiagnostics touches the MSBuildWorkspace that Dispose() shuts down. Disposing an evicted workspace therefore cannot break a resolve already in flight.
Two experiments confirmed it: removing the lease broke no test, and a direct test disposing a workspace and then reading its compilation passes. The lease was removed in 1709b23, and DisposedWorkspaceStillServesCompilationReads now pins the premise so it fails loudly if a read ever starts depending on the live workspace.
Remaining limitation: there is no multi-threaded stress test covering concurrent resolves against concurrent invalidations. The _gate discipline is reviewed, not empirically proven under contention.
Activity
Correct regressions found in the review-fix pass
Replay pending-load invalidations and defer workspace disposal
Drop the unnecessary workspace lease from XamlProjectResolver
chiaramooney commentedon Sep 8, 2026
Fixed in PR #50 (commits
d684a72,1709b23). One correction to the record, since it affects future work here.The core report is accurate and is what got fixed: an in-flight load for a different root cannot be tested with
ContainsProject, so it could be cached with a pre-invalidation graph and never evicted.Invalidatenow records the key on the pending entry andOnLoadCompletedre-tests it against the finished graph and self-evicts. Verified by reverting the recording line and confirming the regression test fails.The third suggested-work bullet is incorrect and should not be acted on. It states:
I implemented a lease for this before testing the premise. It does not hold.
RoslynProjectWorkspacecaptures an immutable RoslynProjectsnapshot in its constructor and serves every read from it (GetCompilationAsync,GetFrameworkCompilation,ContainsProject,XamlFiles,ApplicationDefinitionPath). OnlyLoadDiagnosticstouches theMSBuildWorkspacethatDispose()shuts down. Disposing an evicted workspace therefore cannot break a resolve already in flight.Two experiments confirmed it: removing the lease broke no test, and a direct test disposing a workspace and then reading its compilation passes. The lease was removed in
1709b23, andDisposedWorkspaceStillServesCompilationReadsnow pins the premise so it fails loudly if a read ever starts depending on the live workspace.Remaining limitation: there is no multi-threaded stress test covering concurrent resolves against concurrent invalidations. The
_gatediscipline is reviewed, not empirically proven under contention.