提交 f86e6a1d 编写于 作者: K Kevin Pilch 提交者: GitHub

Merge pull request #18360 from Pilchie/dpl-cleanup-netcore

Don't create deferred projects for things that opt-out of DPL
using System;
using System.Runtime.InteropServices;
namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.Interop
{
[ComImport]
[Guid("D32B0C42-8AEE-4772-B5C3-04565CDA5A47")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IVsSolution7
{
void OpenFolder([MarshalAs(UnmanagedType.LPWStr)]string folderPath);
void CloseFolder([MarshalAs(UnmanagedType.LPWStr)]string folderPath);
bool IsSolutionLoadDeferred();
}
}
......@@ -539,9 +539,7 @@ public void OnAfterCloseSolution()
if (_deferredLoadWasEnabledForLastSolution)
{
// Copy to avoid modifying the collection while enumerating
var loadedProjects = ImmutableProjects.ToList();
foreach (var p in loadedProjects)
foreach (var p in ImmutableProjects)
{
p.Disconnect();
}
......@@ -690,6 +688,12 @@ private void OutputToOutputWindow(string message)
return null;
}
var solution7 = (IVsSolution7)_vsSolution;
if (!solution7.IsDeferredProjectLoadAllowed(projectFilename))
{
return null;
}
var commandLineParser = _workspaceServices.GetLanguageServices(languageName).GetService<ICommandLineParserService>();
var projectDirectory = PathUtilities.GetDirectoryName(projectFilename);
var commandLineArguments = commandLineParser.Parse(
......@@ -698,7 +702,7 @@ private void OutputToOutputWindow(string message)
isInteractive: false,
sdkDirectory: RuntimeEnvironment.GetRuntimeDirectory());
// TODO: Should come from sln file?
// TODO: Should come from .sln file?
var projectName = PathUtilities.GetFileName(projectFilename, includeExtension: false);
// `AbstractProject` only sets the filename if it actually exists. Since we want
......
......@@ -90,13 +90,18 @@ int IVsSolutionEvents.OnAfterCloseSolution(object pUnkReserved)
return VSConstants.S_OK;
}
/// <summary>
/// Returns whether the solution overall has Lightweight solution load enabled, either
/// through the global option in Tools\Options, or the .suo specific option.
///
/// NOTE: Does *NOT* mean that all projects in the solution are deferred. Project types
/// can opt out. Use <see cref="IVsSolution7.IsDeferredProjectLoadAllowed(string)"/> to
/// see if a specific project can be deferred.
/// </summary>
internal static bool IsDeferredSolutionLoadEnabled(IServiceProvider serviceProvider)
{
// NOTE: It is expected that the "as" will fail on Dev14, as IVsSolution7 was
// introduced in Dev15. Be sure to handle the null result here.
var solution7 = serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution7;
return solution7?.IsSolutionLoadDeferred() == true;
var solution7 = (IVsSolution7)serviceProvider.GetService(typeof(SVsSolution));
return solution7.IsSolutionLoadDeferred();
}
}
}
......@@ -96,7 +96,6 @@
<Compile Include="Implementation\Preview\ReferenceChange.cs" />
<Compile Include="Implementation\ProjectSystem\CPS\ICodeModelFactory.cs" />
<Compile Include="Implementation\ProjectSystem\IDeferredProjectWorkspaceService.cs" />
<Compile Include="Implementation\ProjectSystem\Interop\IVsSolution7.cs" />
<Compile Include="Implementation\ProjectSystem\Legacy\AbstractLegacyProject_ICompilerOptionsHostObject.cs" />
<Compile Include="Implementation\ProjectSystem\Legacy\AbstractLegacyProject_IIntellisenseBuildTarget.cs" />
<Compile Include="Implementation\ProjectSystem\CPS\IWorkspaceProjectContextFactory.cs" />
......
......@@ -11,8 +11,9 @@
"Microsoft.VisualStudio.Shell.Interop.10.0": "10.0.30319",
"Microsoft.VisualStudio.Shell.Interop.11.0": "11.0.61030",
"Microsoft.VisualStudio.Shell.Interop.12.1.DesignTime": "12.1.30328",
"Microsoft.VisualStudio.Shell.15.0": "15.0.26201-alpha",
"Microsoft.VisualStudio.Shell.Interop.14.0.DesignTime": "14.3.25407",
"Microsoft.VisualStudio.Shell.Interop.15.0.DesignTime": "15.0.26201-alpha",
"Microsoft.VisualStudio.Shell.15.0": "15.0.26201-alpha",
"Microsoft.VisualStudio.Shell.Framework": "15.0.26201-alpha",
"Microsoft.VisualStudio.Shell.Immutable.10.0": "15.0.26201-alpha",
"Microsoft.VisualStudio.Editor": "15.0.26201-alpha",
......
......@@ -18,7 +18,6 @@
"Microsoft.VisualStudio.Imaging.Interop.14.0.DesignTime": "14.3.25407",
"Microsoft.ServiceHub.Client": "1.0.177-rc-g56d40a8a02",
"Newtonsoft.Json": "8.0.3",
"Microsoft.VisualStudio.Shell.Interop.15.0.DesignTime": "15.0.26201-alpha",
"RoslynDependencies.Microsoft.VisualStudio.Workspace": "14.0.983-pre-ge167e81694",
"System.Collections.Immutable": "1.3.1",
"Microsoft.Tpl.Dataflow": "4.5.24",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册