I’m writing an extension for Visual Studio 2022 using the Community.VisualStudio.Toolkit
package and part of my extension writes errors to the Error List window. I’ve figured out how to populate all the other fields I want (Severity, Description, Project, and Line) but I can’t quite figure out how to write to the Code field.
I created an ErrorListProvider
object from the Microsoft.VisualStudio.Shell
package that I then add error messages to like so:
errorListProvider.Tasks.Add(new ErrorTask
{
ErrorCategory = TaskErrorCategory.Warning,
Text = error.Message,
Document = error.FileName,
Line = error.Line - 1, // error list uses 0 based indexing
Column = error.Column,
HierarchyItem = hierarchy, // populates the 'Project' field in the error list
});
The only other fields that I can modify on the ErrorTask
item are HelpKeyword
and Category
, which don’t seem to affect the Code field.
2
Answers
I accomplished this by making a class that implements
ITableEntry
and has a member variableerrorCode
Try to use the following code:
For more information, please read documents:
StandardTableKeyNames Fields
ErrorCode Field