0

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.

3
  • Hi @jordanb, did you read the doc StandardTableKeyNames Class from package Microsoft.VisualStudio.Shell.Framework? Commented Aug 19, 2024 at 2:37
  • Glad to hear that this issue doesn't block you anymore. Happy coding :D Commented Aug 29, 2024 at 2:09
  • @DouXu-MSFT Thanks! If you have a moment I was wondering if it is possible to also populate the "Details" column? The documentation lists a DetailsExpander field but implementing this doesn't seem to populate that column Commented Aug 30, 2024 at 21:21

2 Answers 2

0

Try to use the following code:

errorListProvider.Tasks.Add(new ErrorTask { ErrorCategory = TaskErrorCategory.Warning, // Code field Code = error.ErrorCode, }); 

For more information, please read documents:

StandardTableKeyNames Fields

ErrorCode Field

Sign up to request clarification or add additional context in comments.

Comments

0

I accomplished this by making a class that implements ITableEntry and has a member variable errorCode

public bool TryGetValue(string keyName, out object content) { switch (keyName) { case StandardTableKeyNames.ErrorCode: content = errorCode; return true; default: content = ""; return false; } } public bool CanSetValue(string keyName) { switch (keyName) { case StandardTableKeyNames.ErrorCode: return true; default: return false; } } 
list.Add(new MyErrorListEntry() { errorCode = error.Code }); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.