diff --git a/src/Workspaces/Core/Portable/TemporaryStorage/TemporaryStorageServiceFactory.cs b/src/Workspaces/Core/Portable/TemporaryStorage/TemporaryStorageServiceFactory.cs index d27d050dbc51d..ee128c5bff73d 100644 --- a/src/Workspaces/Core/Portable/TemporaryStorage/TemporaryStorageServiceFactory.cs +++ b/src/Workspaces/Core/Portable/TemporaryStorage/TemporaryStorageServiceFactory.cs @@ -35,7 +35,7 @@ public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) // MemoryMapped files which are used by the TemporaryStorageService are present in .NET Framework (including Mono) // and .NET Core Windows. For non-Windows .NET Core scenarios, we can return the TrivialTemporaryStorageService - // until https://github.com/dotnet/roslyn/issues/42178 is fixed. + // until https://github.com/dotnet/runtime/issues/30878 is fixed. return PlatformInformation.IsWindows || PlatformInformation.IsRunningOnMono ? (ITemporaryStorageService)new TemporaryStorageService(textFactory) : TrivialTemporaryStorageService.Instance; diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ValuesSources/WeaklyCachedRecoverableValueSource.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ValuesSources/WeaklyCachedRecoverableValueSource.cs index d546ba6f07495..4dd83fcbc63dd 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ValuesSources/WeaklyCachedRecoverableValueSource.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ValuesSources/WeaklyCachedRecoverableValueSource.cs @@ -128,7 +128,11 @@ private void ResetRecoverySource(Task saveTask, T instance) { using (Gate.DisposableWait(CancellationToken.None)) { - _recoverySource = new AsyncLazy(RecoverAsync, Recover, cacheResult: false); + // Only assume the instance is saved if the saveTask completed successfully. If the save did not + // complete, we can still rely on a constant value source to provide the instance. + _recoverySource = saveTask.Status == TaskStatus.RanToCompletion + ? new AsyncLazy(RecoverAsync, Recover, cacheResult: false) + : new ConstantValueSource(instance); // Need to keep instance alive until recovery source is updated. GC.KeepAlive(instance);