4

I'm working on creating a Visual Studio VSPackage containing a Single File Generator (IVsSingleFileGenerator) and I want to be able to log events to the Visual Studio Error List (http://msdn.microsoft.com/en-us/library/33df3b7a(v=vs.110).aspx)

I am using the example base classes from Microsoft Visual Studio SDK (http://code.msdn.microsoft.com/windowsdesktop/Single-File-Generator-94d856d4). These classes have methods:

public class BaseCodeGenerator : IVsSingleFileGenerator
{
   void GeneratorError(uint level, string message, uint line, uint column);
   void GeneratorWarning(uint level, string message, uint line, uint column);
}

This lets me make errors and warnings, but not messages. The methods call IVsGeneratorProgress.GenerateError (http://msdn.microsoft.com/en-US/library/microsoft.visualstudio.shell.interop.ivsgeneratorprogress.generatorerror(v=vs.90).aspx). This method doesn't seem to let me wire up a 'message'.

I have tried trying to find a reference to the Error List window in Visual Studio so I could write directly to it, but I didn't see anything in VSConstants (http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.vsconstants(v=vs.80).aspx).

Anyone know how to log a Message to the Visual Studio Error List?

Philip Pittle
  • 11,821
  • 8
  • 59
  • 123
  • It doesn't look like you can do it from the existing methods that you have in that sample. You'll need create an ErrorListProvider and use it. You should be able to use the code presented towards the bottom of this forum entry to morph it into your solution: http://social.msdn.microsoft.com/forums/en-US/vsx/thread/a1d37fdf-09e0-41f9-a045-52a8109b8943/ – Jason Haley May 11 '13 at 19:54

2 Answers2

4

This just isn't appropriate, the Error List window can and should only display error and warning messages. The automation interfaces therefore don't help you do this.

If you want to generate additional chatter then you should write that to the Output window. Accessible through the IVsOutputWindowPane interface, this MSDN How-to topic shows sample source code in the LogAnnotationToOutputWindow() method.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • Thanks for the information. Although I still find it odd that the 'Error List' window displays 'Errors', 'Warnings' and 'Messages' but the API only gives you access to the first two. O well, I'll write to the Output window like you suggested. – Philip Pittle May 23 '13 at 12:22
2

Not a direct answer as I don't think I ever solved that either. I chose to create and write to a new output window. Should be of some help to you, see the WriteLine method at the bottom of this source: http://code.google.com/p/csharptest-net/source/browse/src/Tools/CmdTool/VsInterop/BaseCodeGeneratorWithSite.cs

I think OutputTaskItemString might even do what you are asking.

csharptest.net
  • 62,602
  • 11
  • 71
  • 89
  • Thanks for the response. Marked this one as correct because it included a link to source code, although both @hans and csharptest.net are right. – Philip Pittle May 23 '13 at 12:24