public static void WriteError(string message, string fileName, int lineNumber = 0, int columnNumber = 0, string helpKeyword = null, TaskCategory taskCategory = TaskCategory.User, string projectFile = null, bool allowOpenFile = false, bool activatePane = true) { SimpleVsHierarchy hierarchyItem = projectFile != null ? new SimpleVsHierarchy(projectFile) : null; ErrorTask task = new ErrorTask { HierarchyItem = hierarchyItem, Category = taskCategory, Document = fileName, Line = lineNumber, ErrorCategory = TaskErrorCategory.Error, Text = message, Column = columnNumber, HelpKeyword = helpKeyword }; if (allowOpenFile) { task.Navigate += (sender, args) => VisualStudioDTE.TryOpenFile(fileName, lineNumber, hierarchyItem); } AddTask(task, activatePane); }
private KeyValuePair <TestRun, List <MsTestError> > OpenTestResultFileAndGetResults(Project project, string fileName) { if (File.Exists(fileName)) { VisualStudioDTE.TryOpenFile(fileName); var run = TestRun.LoadFromFile(fileName); List <MsTestError> failedTests = MsTestError.FromTestRun(run).ToList(); foreach (var error in failedTests) { Output.WriteError($"{error.TestName}={error.ErrorMessage}", error.TestPath, error.Line, 0, null, TaskCategory.User, project.FullPath, File.Exists(error.TestPath), false); } SetTestRunOnResultsWindowToIndex(1); // Alle läufe in einem ergebis fenster zeigen return(new KeyValuePair <TestRun, List <MsTestError> >(run, failedTests)); } return(new KeyValuePair <TestRun, List <MsTestError> >(null, new List <MsTestError>())); }
private void Control_OnMouseDoubleClick(object sender, MouseButtonEventArgs e) { var lb = (sender) as ListBox; if (lb != null) { var task = lb.SelectedItem as ErrorTask; if (task != null) { VisualStudioDTE.TryOpenFile(task.Document, task.Line, task.HierarchyItem as SimpleVsHierarchy); } // var invoker = ReflectionHelper.GetEventInvoker(task, "Navigate"); // if (invoker != null) // { // invoker.Invoke(task, new object[] { task, null }); // } } }