How to get selected items from Visual studio error window? I tried below code
DTE2 dte2 = Package.GetGlobalService(typeof(DTE)) as DTE2;
dte2.ExecuteCommand("View.ErrorList", " ");
IList<string> errors = new List<string>();
// Can get complete list.
ErrorList errorList = dte2.ToolWindows.ErrorList;
// Below line does not work and always returns null.
var item = dte2.ToolWindows.ErrorList.SelectedItems;
Is there any other way to get the selected items?
You can use the following code:
if (await this.package.GetServiceAsync(typeof(SVsErrorList)) is IVsTaskList2 tasks)
{
tasks.EnumSelectedItems(out IVsEnumTaskItems itemsEnum);
Copied from Matt Lacey's ErrorHelper extension.