Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2015 extension - Get selected items in Error list

I'm trying to make an extension for Visual Studio 2015 that depends on the selected items in the Error List view.

I'm retrieving the list with the following code:

var errorList = this.dte2.ToolWindows.ErrorList as IVsTaskList2;
IVsEnumTaskItems items;
errorList.EnumSelectedItems(out items);

But my problem is now that i'm able to get the description (Text) but not the error code (HelpKeyword). The description do i get this way:

 IVsTaskItem[] item = new IVsTaskItem[1];
 while (items.Next(1, item, null) == 0)
 {
    string description;
    item.get_Text(out description);
 }

Hope someone can helped me on this as i'm quiet frustrated at the moment.

like image 549
Ztick Avatar asked Dec 06 '25 06:12

Ztick


1 Answers

I was able to get this using a completely different approach:

            var errorList = dte.ToolWindows.ErrorList as IErrorList;
            var selected = errorList.TableControl.SelectedEntry;
            if (selected != null)
            {
                object content;
                if (selected.TryGetValue("errorcode", out content))
                {
                    return (string)content;
                }
            }   

This accesses the error window selected item as a table and just gets the correct column (the text column has key "text", BTW).

It certainly wasn't easy to figure this out. Thank you Microsoft for: 1) the almost total lack of documentation for any of this stuff, 2) completely breaking the interfaces that worked in VS2013, and 3) not simply adding the code as a property for ErrorItem.

like image 93
Charles Avatar answered Dec 09 '25 21:12

Charles



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!