views:

1381

answers:

11

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.

What do I need to do to get the output to show up in the Messages pane of the Error List? 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.

Thanks.

UPDATE: 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?

A: 

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!

scootdawg
Looks like that is only for managed code. Definitely a good lead if that was what I am using, but i'm doing unmanaged C++.
Aaron
yeah, I wasn't sure if you had it available for your situation but I thought I'd at least give you a head start! :)
scootdawg
A: 

I'm not sure how to do what you're asking, but I found this website that tells how to solve a similar problem.

Visual Studio Web Applications—Error List and Task List

Sorry if this doesn't help you any.

Aaron Smith
This site? http://en.csharp-online.net/Visual_Studio_Web_Applications—Error_List_and_Task_ListThat doesn't really help with this question.. Part of the impetus behind doing it this way is to put the feedback in a place developers see. They spend much time with errors, but not on the task list.
Aaron
A: 

MSDN says there is a straight forward answer, and gives it here:

Error List Window
http://msdn.microsoft.com/en-us/library/33df3b7a(VS.80).aspx
How to: Create Task List Comments
http://msdn.microsoft.com/en-us/library/zce12xx2(VS.80).aspx
How to: Create Cusom Comment Tokens
http://msdn.microsoft.com/en-us/library/ekwz6akh(VS.80).aspx

Sadly, it doesn't appear to work - in any version of Visual Studio.

I don't have an answer, just thought I'd share the nuggets I've found on my search for the answer to the same question.

-Jesse Chisholm

Thanks for the answer. I've been around those same pages and I've still not found a way to do it. A coworker suggested writing a custome plugin to parse the output list and make calls directly to the error pane to put them in the messages list. Not sure if that is viable, but if I get it working, I'll post the code. =D
Aaron
A: 

Just a follow up. Still not an answer.

I just learned that in VS 2008 at least, there is BOTH an "Error List" and a "Task List".

Over in the Task List, in the section called "Comments" were all those promised // TODO messages MS was talking about.

Sigh.

I still don't know what tag to put in file(line): tag: message to get it to show up in the "Error List" in the "Messages" category.

-Jesse Chisholm

A: 

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.

ChrisBD
I'm interested in the Messages Pane of the Error List, not the output window.I appreciate your having answered, but it doesn't address the question.
Aaron
+1  A: 

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.

ChrisBD
A: 

I have used the call to OutputDebugString(...), which will print a given string to the output window.

bn
I'm interested in the Messages Pane of the Error List, not the output window. I appreciate your having answered, but it doesn't address the question.
Aaron
+1  A: 

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

Andrey
A: 

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)

Grant Peters
My coworker has said much the same. You and he are probably right. Said coworker told me that VS 2010 doesn't even have a messages pane. Thanks for the answer!
Aaron
A: 

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.

Assaf Lavie
I'm not actually interested in the task list. I'm interested in the messages pane of the error list.Thanks for the answer.
Aaron
A: 

Followup (still not an answer):

For all you very helpful people who don't seem to understand the question. I'll try restating it, with code examples.

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?

We are looking for an unmanaged C++ way to do this. We do not want to extend VS with hooks.

We know that this works:

// to put an entry in the "Errors" tab of the "Error List" window.
CString msg;
msg.Format(_T("%hs(%d): error: entry in the Error tab of the Error List window.\n"),
    __FILE__, __LINE__);
OutputDebugString(msg);

// to put an entry in the "Warnings" tab of the "Error List" window.
msg.Format(_T("%hs(%d): warning: entry in the Warning tab of the Error List window.\n"),
    __FILE__, __LINE__);
OutputDebugString(msg);

// TODO: to put an entry to in the "Task List" window, in the TODO category.

// But we don't know the format that puts it in the "Messages" tab of the "Error List"
// none of these three "tags" seem to work.
// What does?
//
char* tags[]= {"info","message","note"};
for(int i=0; i<3; ++i)
msg.Format(_T("%hs(%d): %hs: entry in the Messages tab of the Error List window?\n"),
    tags[i], __FILE__, __LINE__);
OutputDebugString(msg);

Thank you for all the continued effort in answering this convenience question.

-Jesse

Thanks Jesse, that is EXACTLY what I want to find out with this question.
Aaron