本文整理汇总了C#中Microsoft.VisualStudioTools.VisualStudioApp.AttachToProcess方法的典型用法代码示例。如果您正苦于以下问题:C# VisualStudioApp.AttachToProcess方法的具体用法?C# VisualStudioApp.AttachToProcess怎么用?C# VisualStudioApp.AttachToProcess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.VisualStudioTools.VisualStudioApp
的用法示例。
在下文中一共展示了VisualStudioApp.AttachToProcess方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunTestCase
private void RunTestCase(VisualStudioApp app, IFrameworkHandle frameworkHandle, IRunContext runContext, TestCase test, Dictionary<string, NodejsProjectSettings> sourceToSettings) {
var testResult = new TestResult(test);
frameworkHandle.RecordStart(test);
testResult.StartTime = DateTimeOffset.Now;
NodejsProjectSettings settings;
if (!sourceToSettings.TryGetValue(test.Source, out settings)) {
sourceToSettings[test.Source] = settings = LoadProjectSettings(test.Source);
}
if (settings == null) {
frameworkHandle.SendMessage(
TestMessageLevel.Error,
"Unable to determine interpreter to use for " + test.Source);
RecordEnd(
frameworkHandle,
test,
testResult,
null,
"Unable to determine interpreter to use for " + test.Source,
TestOutcome.Failed);
return;
}
NodejsTestInfo testInfo = new NodejsTestInfo(test.FullyQualifiedName);
List<string> args = new List<string>();
int port = 0;
if (runContext.IsBeingDebugged && app != null) {
app.GetDTE().Debugger.DetachAll();
args.AddRange(GetDebugArgs(settings, out port));
}
var workingDir = Path.GetDirectoryName(CommonUtils.GetAbsoluteFilePath(settings.WorkingDir, testInfo.ModulePath));
args.AddRange(GetInterpreterArgs(test, workingDir, settings.ProjectRootDir));
//Debug.Fail("attach debugger");
if (!File.Exists(settings.NodeExePath)) {
frameworkHandle.SendMessage(TestMessageLevel.Error, "Interpreter path does not exist: " + settings.NodeExePath);
return;
}
lock (_syncObject) {
_nodeProcess = ProcessOutput.Run(
settings.NodeExePath,
args,
workingDir,
null,
false,
null,
false);
#if DEBUG
frameworkHandle.SendMessage(TestMessageLevel.Informational, "cd " + workingDir);
frameworkHandle.SendMessage(TestMessageLevel.Informational, _nodeProcess.Arguments);
#endif
_nodeProcess.Wait(TimeSpan.FromMilliseconds(500));
if (runContext.IsBeingDebugged && app != null) {
try {
//the '#ping=0' is a special flag to tell VS node debugger not to connect to the port,
//because a connection carries the consequence of setting off --debug-brk, and breakpoints will be missed.
string qualifierUri = string.Format("tcp://localhost:{0}#ping=0", port);
while (!app.AttachToProcess(_nodeProcess, NodejsRemoteDebugPortSupplierUnsecuredId, qualifierUri)) {
if (_nodeProcess.Wait(TimeSpan.FromMilliseconds(500))) {
break;
}
}
#if DEBUG
} catch (COMException ex) {
frameworkHandle.SendMessage(TestMessageLevel.Error, "Error occurred connecting to debuggee.");
frameworkHandle.SendMessage(TestMessageLevel.Error, ex.ToString());
KillNodeProcess();
}
#else
} catch (COMException) {
frameworkHandle.SendMessage(TestMessageLevel.Error, "Error occurred connecting to debuggee.");
KillNodeProcess();
}
#endif
}
}