提交 0f7dfb1f 编写于 作者: C CyrusNajmabadi 提交者: GitHub

Merge pull request #13939 from CyrusNajmabadi/remotePersistenceService

Properly handle null paths being passed to the RemotePersistenceService.
......@@ -5,14 +5,11 @@
using System.Collections.Immutable;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.Internal.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.LanguageServices.Remote;
using Microsoft.VisualStudio.Shell.Interop;
using Roslyn.Utilities;
......@@ -209,17 +206,20 @@ public string GetWorkingFolderPath(Solution solution)
public void RegisterWorkspaceHost(IVisualStudioWorkspaceHost host)
{
AssertIsForeground();
ExecuteOrScheduleForegroundAffinitizedAction(
() => RegisterWorkspaceHostOnForeground(host));
}
lock (_gate)
{
if (_workspaceHosts.Any(hostState => hostState.Host == host))
{
throw new ArgumentException("The workspace host is already registered.", nameof(host));
}
private void RegisterWorkspaceHostOnForeground(IVisualStudioWorkspaceHost host)
{
this.AssertIsForeground();
_workspaceHosts.Add(new WorkspaceHostState(this, host));
if (_workspaceHosts.Any(hostState => hostState.Host == host))
{
throw new ArgumentException("The workspace host is already registered.", nameof(host));
}
_workspaceHosts.Add(new WorkspaceHostState(this, host));
}
public void StartSendingEventsToWorkspaceHost(IVisualStudioWorkspaceHost host)
......
......@@ -33,8 +33,20 @@ public static void UpdateStorageLocation(SolutionId id, string storageLocation)
{
lock (_gate)
{
// Store the esent database in a different location for the out of proc server.
_idToStorageLocation[id] = Path.Combine(storageLocation, "Server");
// We can get null when the solution has no corresponding file location
// in the host process. This is not abnormal and can come around for
// many reasons. In that case, we simply do not store a storage location
// for this solution, indicating to all remote consumers that persistent
// storage is not available for this solution.
if (storageLocation == null)
{
_idToStorageLocation.Remove(id);
}
else
{
// Store the esent database in a different location for the out of proc server.
_idToStorageLocation[id] = Path.Combine(storageLocation, "Server");
}
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册