提交 9a557728 编写于 作者: J Jason Malinowski

Ensure we clean up RuleSetFiles when we close the solution

The VisualStudioRuleSetManager is a singleton that acts as a cache
of RuleSetFiles and also manages the lifetime of file watching. We
never cleaned that up when we shut down VS, so we leaked a bunch of
file watchers, which would throw during finalization asserting they
weren't cleaned up and bring down the process with it.
上级 281ac90b
......@@ -41,7 +41,7 @@ private void StopTrackingRuleSetFile(RuleSetFile ruleSetFile)
_ruleSetFileMap.Remove(ruleSetFile.FilePath);
}
public void Dispose()
public void ClearCachedRuleSetFiles()
{
foreach (var pair in _ruleSetFileMap)
{
......@@ -50,5 +50,10 @@ public void Dispose()
_ruleSetFileMap.Clear();
}
void IDisposable.Dispose()
{
ClearCachedRuleSetFiles();
}
}
}
......@@ -24,7 +24,7 @@
namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem
{
internal sealed partial class VisualStudioProjectTracker : ForegroundThreadAffinitizedObject, IDisposable, IVisualStudioHostProjectContainer
internal sealed partial class VisualStudioProjectTracker : ForegroundThreadAffinitizedObject, IVisualStudioHostProjectContainer
{
#region Readonly fields
private static readonly ConditionalWeakTable<SolutionId, string> s_workingFolderPathMap = new ConditionalWeakTable<SolutionId, string>();
......@@ -244,14 +244,6 @@ public void InitializeProviders(DocumentProvider documentProvider, VisualStudioM
public VisualStudioMetadataReferenceManager MetadataReferenceProvider { get; private set; }
public VisualStudioRuleSetManager RuleSetFileProvider { get; private set; }
public void Dispose()
{
if (this.RuleSetFileProvider != null)
{
this.RuleSetFileProvider.Dispose();
}
}
internal AbstractProject GetProject(ProjectId id)
{
lock (_gate)
......@@ -565,6 +557,8 @@ public void OnAfterCloseSolution()
_projectPathToIdMap.Clear();
}
RuleSetFileProvider.ClearCachedRuleSetFiles();
foreach (var workspaceHost in _workspaceHosts)
{
workspaceHost.SolutionClosed();
......
......@@ -87,8 +87,8 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim.Fr
project.Disconnect()
Next
_projectTracker.OnAfterCloseSolution()
_workspace.Dispose()
_projectTracker.Dispose()
For Each filePath In _projectFilePaths
File.Delete(filePath)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册