Skip to content

Commit 1c02088

Browse files
authored
Merge pull request #1581 from paulvanbrenk/15.3rollup
15.3 rollup
2 parents 0d5fab7 + eb4fa84 commit 1c02088

File tree

6 files changed

+90
-22
lines changed

6 files changed

+90
-22
lines changed

Nodejs/Product/Nodejs/Debugger/DebugEngine/AD7Thread.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ internal NodeThread GetDebuggedThread()
4040
// NOTE: VS2013 and earlier do not use the result to disable the "set next statement" command
4141
int IDebugThread2.CanSetNextStatement(IDebugStackFrame2 stackFrame, IDebugCodeContext2 codeContext)
4242
{
43-
throw new NotSupportedException("Set Next Statement is not supported by Node.js.");
43+
return VSConstants.E_NOTIMPL;
4444
}
4545

4646
// Retrieves a list of the stack frames for this thread.

Nodejs/Product/Nodejs/Debugger/NodeDebugProvider.cs

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33
using System;
44
using System.ComponentModel.Composition;
5+
using System.IO;
6+
using Microsoft.NodejsTools.Project;
7+
using Microsoft.VisualStudio.Setup.Configuration;
58
using Microsoft.VisualStudio.Shell.Interop;
69
using Microsoft.VisualStudio.Workspace;
710
using Microsoft.VisualStudio.Workspace.Debug;
811
using Microsoft.VisualStudio.Workspace.Extensions.VS.Debug;
12+
using Newtonsoft.Json.Linq;
913

1014
namespace Microsoft.NodejsTools.Debugger
1115
{
@@ -42,9 +46,24 @@ internal class NodeJsDebugLaunchProvider : IVsDebugLaunchTargetProvider
4246
}";
4347

4448
public void SetupDebugTargetInfo(ref VsDebugTargetInfo vsDebugTargetInfo, DebugLaunchActionContext debugLaunchContext)
49+
{
50+
var nodeExe = debugLaunchContext.LaunchConfiguration.GetValue<string>(NodeExeKey, defaultValue: Nodejs.GetPathToNodeExecutableFromEnvironment());
51+
52+
var nodeVersion = Nodejs.GetNodeVersion(nodeExe);
53+
if (nodeVersion >= new Version(8, 0) || NodejsProjectLauncher.CheckDebugProtocolOption())
54+
{
55+
SetupDebugTargetInfoForWebkitV2Protocol(ref vsDebugTargetInfo, debugLaunchContext, nodeExe);
56+
}
57+
else
58+
{
59+
this.SetupDebugTargetInfoForNodeProtocol(ref vsDebugTargetInfo, debugLaunchContext, nodeExe);
60+
}
61+
}
62+
63+
private void SetupDebugTargetInfoForNodeProtocol(ref VsDebugTargetInfo vsDebugTargetInfo, DebugLaunchActionContext debugLaunchContext, string nodeExe)
4564
{
4665
var target = vsDebugTargetInfo.bstrExe;
47-
vsDebugTargetInfo.bstrExe = debugLaunchContext.LaunchConfiguration.GetValue<string>(NodeExeKey, Nodejs.GetPathToNodeExecutableFromEnvironment());
66+
vsDebugTargetInfo.bstrExe = nodeExe;
4867
var nodeJsArgs = vsDebugTargetInfo.bstrArg;
4968
vsDebugTargetInfo.bstrArg = "\"" + target + "\"";
5069
if (!string.IsNullOrEmpty(nodeJsArgs))
@@ -58,6 +77,61 @@ public void SetupDebugTargetInfo(ref VsDebugTargetInfo vsDebugTargetInfo, DebugL
5877
vsDebugTargetInfo.grfLaunch = (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_StopDebuggingOnEnd;
5978
}
6079

80+
private void SetupDebugTargetInfoForWebkitV2Protocol(ref VsDebugTargetInfo vsDebugTargetInfo, DebugLaunchActionContext debugLaunchContext, string nodeExe)
81+
{
82+
// todo: refactor the debugging and process starting so we can re-use
83+
84+
var setupConfiguration = new SetupConfiguration();
85+
var setupInstance = setupConfiguration.GetInstanceForCurrentProcess();
86+
var visualStudioInstallationInstanceID = setupInstance.GetInstanceId();
87+
88+
// The Node2Adapter depends on features only in Node v6+, so the old v5.4 version of node will not suffice for this scenario
89+
// This node.exe will be the one used by the node2 debug adapter, not the one used to host the user code.
90+
var pathToNodeExe = Path.Combine(setupInstance.GetInstallationPath(), "JavaScript\\Node.JS\\v6.4.0_x86\\Node.exe");
91+
92+
// We check the registry to see if any parameters for the node.exe invocation have been specified (like "--inspect"), and append them if we find them.
93+
var nodeParams = NodejsProjectLauncher.CheckForRegistrySpecifiedNodeParams();
94+
if (!string.IsNullOrEmpty(nodeParams))
95+
{
96+
pathToNodeExe = pathToNodeExe + " " + nodeParams;
97+
}
98+
99+
var pathToNode2DebugAdapterRuntime = Environment.ExpandEnvironmentVariables(@"""%ALLUSERSPROFILE%\" +
100+
$@"Microsoft\VisualStudio\NodeAdapter\{visualStudioInstallationInstanceID}\extension\out\src\nodeDebug.js""");
101+
102+
string trimmedPathToNode2DebugAdapter = pathToNode2DebugAdapterRuntime.Replace("\"", "");
103+
if (!File.Exists(trimmedPathToNode2DebugAdapter))
104+
{
105+
pathToNode2DebugAdapterRuntime = Environment.ExpandEnvironmentVariables(@"""%ALLUSERSPROFILE%\" +
106+
$@"Microsoft\VisualStudio\NodeAdapter\{visualStudioInstallationInstanceID}\out\src\nodeDebug.js""");
107+
}
108+
109+
var target = vsDebugTargetInfo.bstrExe;
110+
var cwd = Path.GetDirectoryName(target); // Current working directory
111+
112+
var configuration = new JObject(
113+
new JProperty("name", "Debug Node.js program from Visual Studio"),
114+
new JProperty("type", "node2"),
115+
new JProperty("request", "launch"),
116+
new JProperty("program", target),
117+
new JProperty("runtimeExecutable", nodeExe),
118+
new JProperty("cwd", cwd),
119+
new JProperty("console", "externalTerminal"),
120+
new JProperty("diagnosticLogging", NodejsProjectLauncher.CheckEnableDiagnosticLoggingOption()),
121+
new JProperty("sourceMaps", true),
122+
new JProperty("stopOnEntry", true),
123+
new JProperty("$adapter", pathToNodeExe),
124+
new JProperty("$adapterArgs", pathToNode2DebugAdapterRuntime));
125+
126+
var jsonContent = configuration.ToString();
127+
128+
vsDebugTargetInfo.dlo = DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
129+
vsDebugTargetInfo.clsidCustom = NodejsProjectLauncher.WebKitDebuggerV2Guid;
130+
vsDebugTargetInfo.bstrExe = target;
131+
vsDebugTargetInfo.bstrOptions = jsonContent;
132+
vsDebugTargetInfo.grfLaunch = (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_StopDebuggingOnEnd;
133+
}
134+
61135
[ExportLaunchConfigurationProvider(LaunchConfigurationProviderType, new[] { ".js" }, "nodejs", NodeJsSchema)]
62136
public class LaunchConfigurationProvider : ILaunchConfigurationProvider
63137
{

Nodejs/Product/Nodejs/NodejsPackage.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,8 @@ namespace Microsoft.NodejsTools
5454
[ProvideProjectFactory(typeof(NodejsProjectFactory), null, null, null, null, ".\\NullPath", LanguageVsTemplate = NodejsConstants.Nodejs, SortPriority = 0x17)] // outer flavor, no file extension
5555
[ProvideDebugPortSupplier("Node remote debugging", typeof(NodeRemoteDebugPortSupplier), NodeRemoteDebugPortSupplier.PortSupplierId)]
5656
[ProvideMenuResource("Menus.ctmenu", 1)] // This attribute is needed to let the shell know that this package exposes some menus.
57-
[WebSiteProject("JavaScript", "JavaScript")]
5857
[ProvideLanguageTemplates("{349C5851-65DF-11DA-9384-00065B846F21}", NodejsConstants.JavaScript, Guids.NodejsPackageString, "Web", "Node.js Project Templates", "{" + Guids.NodejsBaseProjectFactoryString + "}", ".js", NodejsConstants.Nodejs, "{" + Guids.NodejsBaseProjectFactoryString + "}")]
5958
[ProvideProjectItem(typeof(BaseNodeProjectFactory), NodejsConstants.Nodejs, "FileTemplates\\NewItem", 0)]
60-
[ProvideTextEditorAutomation(NodejsConstants.Nodejs, 106, 102, ProfileMigrationType.PassThrough)]
6159
[ProvideLanguageService(typeof(JadeLanguageInfo), JadeContentTypeDefinition.JadeLanguageName, 3041, RequestStockColors = true, ShowSmartIndent = false, ShowCompletion = false, DefaultToInsertSpaces = true, HideAdvancedMembersByDefault = false, EnableAdvancedMembersOption = false, ShowDropDownOptions = false)]
6260
[ProvideEditorExtension2(typeof(JadeEditorFactory), JadeContentTypeDefinition.JadeFileExtension, 50, __VSPHYSICALVIEWATTRIBUTES.PVA_SupportsPreview, "*:1", ProjectGuid = VSConstants.CLSID.MiscellaneousFilesProject_string, NameResourceID = 3041, EditorNameResourceId = 3045)]
6361
[ProvideEditorExtension2(typeof(JadeEditorFactory), JadeContentTypeDefinition.PugFileExtension, 50, __VSPHYSICALVIEWATTRIBUTES.PVA_SupportsPreview, "*:1", ProjectGuid = VSConstants.CLSID.MiscellaneousFilesProject_string, NameResourceID = 3041, EditorNameResourceId = 3045)]

Nodejs/Product/Nodejs/NpmUI/NpmWorker.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public NpmWorker(INpmController controller)
4141

4242
private void QueueCommand(QueuedNpmCommandInfo info)
4343
{
44-
if (!this.commandQueue.IsAddingCompleted
44+
if (this.commandQueue.IsAddingCompleted
4545
|| this.commandQueue.Contains(info)
4646
|| info.Equals(this.currentCommand))
4747
{
@@ -88,9 +88,9 @@ private void Run()
8888
// The Take method will block the worker thread when there are no items left in the queue
8989
// and the thread will be signalled when new items are items to the queue, or the queue is
9090
// marked completed.
91-
this.currentCommand = this.commandQueue.Take();
92-
if (this.currentCommand != null)
91+
if (this.commandQueue.TryTake(out var command, Timeout.Infinite) && command != null)
9392
{
93+
this.currentCommand = command;
9494
Execute(this.currentCommand);
9595
}
9696
}

Nodejs/Product/Nodejs/Project/NodejsProjectLauncher.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ internal class NodejsProjectLauncher : IProjectLauncher
3232
private readonly NodejsProjectNode _project;
3333
private int? _testServerPort;
3434

35-
private static readonly Guid WebkitDebuggerGuid = Guid.Parse("4cc6df14-0ab5-4a91-8bb4-eb0bf233d0fe");
36-
private static readonly Guid WebkitPortSupplierGuid = Guid.Parse("4103f338-2255-40c0-acf5-7380e2bea13d");
37-
private static readonly Guid WebKitDebuggerV2Guid = Guid.Parse("30d423cc-6d0b-4713-b92d-6b2a374c3d89");
35+
public static readonly Guid WebkitDebuggerGuid = Guid.Parse("4cc6df14-0ab5-4a91-8bb4-eb0bf233d0fe");
36+
public static readonly Guid WebkitPortSupplierGuid = Guid.Parse("4103f338-2255-40c0-acf5-7380e2bea13d");
37+
internal static readonly Guid WebKitDebuggerV2Guid = Guid.Parse("30d423cc-6d0b-4713-b92d-6b2a374c3d89");
3838

3939
public NodejsProjectLauncher(NodejsProjectNode project)
4040
{
@@ -97,28 +97,28 @@ private int Start(string file, bool debug)
9797
return VSConstants.S_OK;
9898
}
9999

100-
private static bool CheckUseNewChromeDebugProtocolOption()
100+
internal static bool CheckUseNewChromeDebugProtocolOption()
101101
{
102102
var optionString = NodejsDialogPage.LoadString(name: "WebKitVersion", cat: "Debugging");
103103

104104
return !StringComparer.OrdinalIgnoreCase.Equals(optionString, "V1");
105105
}
106106

107-
private static bool CheckDebugProtocolOption()
107+
internal static bool CheckDebugProtocolOption()
108108
{
109109
var optionString = NodejsDialogPage.LoadString(name: "DebugProtocol", cat: "Debugging");
110110

111111
return StringComparer.OrdinalIgnoreCase.Equals(optionString, "chrome");
112112
}
113113

114-
private static bool CheckEnableDiagnosticLoggingOption()
114+
internal static bool CheckEnableDiagnosticLoggingOption()
115115
{
116116
var optionString = NodejsDialogPage.LoadString(name: "DiagnosticLogging", cat: "Debugging");
117117

118118
return StringComparer.OrdinalIgnoreCase.Equals(optionString, "true");
119119
}
120120

121-
private static string CheckForRegistrySpecifiedNodeParams()
121+
internal static string CheckForRegistrySpecifiedNodeParams()
122122
{
123123
var paramString = NodejsDialogPage.LoadString(name: "NodeCmdParams", cat: "Debugging");
124124

@@ -372,7 +372,7 @@ private void StartWithDebugger(string startupFile)
372372
}
373373
}
374374

375-
private void StartWithChromeV2Debugger(string program, string nodeRuntimeExecutable, bool startBrowser)
375+
private void StartWithChromeV2Debugger(string file, string nodePath, bool startBrowser)
376376
{
377377
var serviceProvider = _project.Site;
378378

@@ -412,8 +412,8 @@ private void StartWithChromeV2Debugger(string program, string nodeRuntimeExecuta
412412
new JProperty("name", "Debug Node.js program from Visual Studio"),
413413
new JProperty("type", "node2"),
414414
new JProperty("request", "launch"),
415-
new JProperty("program", program),
416-
new JProperty("runtimeExecutable", nodeRuntimeExecutable),
415+
new JProperty("program", file),
416+
new JProperty("runtimeExecutable", nodePath),
417417
new JProperty("cwd", cwd),
418418
new JProperty("console", "externalTerminal"),
419419
new JProperty("env", JObject.FromObject(envVars)),
@@ -429,7 +429,7 @@ private void StartWithChromeV2Debugger(string program, string nodeRuntimeExecuta
429429
new VsDebugTargetInfo4() {
430430
dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess,
431431
guidLaunchDebugEngine = WebKitDebuggerV2Guid,
432-
bstrExe = program,
432+
bstrExe = file,
433433
bstrOptions = jsonContent
434434
}
435435
};

Nodejs/Product/Nodejs/source.extension.vsixmanifest

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,5 @@
3030
<Asset Type="Microsoft.VisualStudio.Assembly" d:Source="Project" d:ProjectName="ProjectWizard" Path="|ProjectWizard|" AssemblyName="|ProjectWizard;AssemblyName|" />
3131
<Asset Type="Microsoft.VisualStudio.ProjectTemplate" d:Source="Project" d:ProjectName="%CurrentProject%" d:TargetPath="|%CurrentProject%;TemplateProjectOutputGroup|" Path="ProjectTemplates" d:VsixSubPath="ProjectTemplates" />
3232
<Asset Type="Microsoft.VisualStudio.ItemTemplate" d:Source="Project" d:ProjectName="%CurrentProject%" d:TargetPath="|%CurrentProject%;TemplateProjectOutputGroup|" Path="ItemTemplates" d:VsixSubPath="ItemTemplates" />
33-
<Asset Type="Microsoft.VisualStudio.Assembly" d:Source="File" Path="Newtonsoft.Json.dll" AssemblyName="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" />
34-
<Asset Type="Microsoft.VisualStudio.Assembly" d:Source="File" Path="Microsoft.VisualStudio.Shell.Interop.dll" AssemblyName="Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
35-
<Asset Type="Microsoft.VisualStudio.Assembly" d:Source="File" Path="Microsoft.VisualStudio.Shell.Interop.8.0.dll" AssemblyName="Microsoft.VisualStudio.Shell.Interop.8.0" />
36-
<Asset Type="Microsoft.VisualStudio.Assembly" d:Source="File" Path="envdte.dll" AssemblyName="envdte, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
3733
</Assets>
3834
</PackageManifest>

0 commit comments

Comments
 (0)