简体   繁体   中英

How do I get output to show up in the Messages pane of the Error List for Visual Studio 2005?

I have a header file like this:

#ifndef __GEN_NOTE_MARKERS_TO_DEVELOPERS_HPP__
#define __GEN_NOTE_MARKERS_TO_DEVELOPERS_HPP__

  #ifdef _DEBUG

    // macros for turning a number into a string
    #define STRING2(x)  #x
    #define STRING(x)  STRING2(x)

    #ifdef TRIAGE_MESG_AS_WARNING
      #define TRIAGE_TODO_TAG(description)    __pragma(message(__FILE__"("STRING(__LINE__)") : warning : TRIAGE TO-DO: " STRING(description) ))
      #define TRIAGE_FIXTHIS_TAG(description) __pragma(message(__FILE__"("STRING(__LINE__)") : warning : TRIAGE FIXTHIS: " STRING(description) ))
    #else
      #define TRIAGE_TODO_TAG(description)    __pragma(message(__FILE__"("STRING(__LINE__)") : message : TRIAGE TO-DO: " STRING(description) ))
      #define TRIAGE_FIXTHIS_TAG(description) __pragma(message(__FILE__"("STRING(__LINE__)") : message : TRIAGE FIXTHIS: " STRING(description) ))
    #endif
  #else
    #define TRIAGE_TODO_TAG(description)
    #define TRIAGE_FIXTHIS_TAG(description)
  #endif

#endif // __GEN_NOTE_MARKERS_TO_DEVELOPERS_HPP__

Which outputs notes to the output pane in Visual Studio 2005. When 'TRIAGE_MESG_AS_WARNING' is defined, Visual Studio will harvest these messages and list them as warnings in the Error List. It does this because the text format matches a warning. However, I don't want them to show up as warnings all the time, I would rather they show up in the Messages pane of the Error List.

How do you format lines you put in the "Output Window" so that Visual Studio will auto-magically show them in the "Messages" tab of the "Error List" window?

The format I have setup for messages in the above code looks like a message from other output, but does not get harvested in the same way.

A co-worker suggested to me that I might need to write a 'custom automation object' to write to the Messages pane. That seems like a pain, especially since it is trivial to end-up with entries in the Error pane and Warning pane simply by proper formating. Is this a possible avenue?

We're using unmanaged C++, so we can't rely on managed (.NET) only tooling. We do not want to extend VS with hooks.

I believe they just forgot about adding additional category: info. At least it is not specified in output format for external tools.

Citation: "Category must be either ' error ' or ' warning '. Case does not matter. Like origin, category must not be localized."

Link: http://blogs.msdn.com/msbuild/archive/2006/11/03/msbuild-visual-studio-aware-error-messages-and-message-formats.aspx

Okay I've had a hunt around and it looks as if you can do this if you have the Visual Studio SDK installed.

I found this link here

You'll need to be using the Microsoft.VisualStudio.Shell namespace I believe.

Snippets of code from the above link are as follows:

//Get the "Error List Window"

ErrorListProvider errorProvider = new ErrorListProvider(this);
Task newError = new Task();
newError.ErrorCategory = TaskErrorCategory.Error; // or TaskErrorCategory.Warning for warnings
newError.Category = TaskCategory.BuildCompile;
newError.Text = "Some Error Text";
errorProvider.Tasks.Add(newError);

I haven't tried this yet, so if you're successful could you post back here for future reference please.

I've attempted to get this to work as well, and as far as i can tell, its impossible unless you actually write your own plug-in for VS that parses output and generates tasks. This would be a really handy feature to have, and i just hope they add it at some point in the future (can't be bothered writing a plug-in myself, too many other little projects going on to spare the time :L)

In the end, i've just opted to output it as a warning, which isn't too bad, seeing how i try to fix all warnings (or if they are intentional, turn the warning off for that little bit of code and comment if its not obvious why the warning is being ignored)

I may not be understanding your question correctly but I'll give it a shot anyway.

Have you looked at the TraceSwitch implentation? You can implement different listeners and output the info to various sources like text, console, etc.

It might be what you need.

Good luck!

Have you tried customizing the Task List keywords?

This page suggests it's possible to do so. I suggest you read on from there, in case you haven't already.

Could you not use "Trace" command within your code? This will just place whatever text that you tell it within the Output window. So for placing of error messages you'll need to format them first probably.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM