Search code examples
c#visual-studiovisual-studio-package

Visual Studio VSPackage / Single File Generator - Log Message to Error List


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?


Solution

  • 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.