[英]How do I add to the MESSAGES list in the Visual Studio Error List window?
#error shows in errors, #warning in warnings. #error显示错误,#warning警告。 How can I make a line of text appear in the messages filter of the Error List window? 如何在“错误列表”窗口的消息过滤器中显示一行文本?
To clarify: 澄清:
If I place the following line within a C# code file, it will generate an error on build, and that error will appear in the Error List window if I switch the errors on (like tabs above the list, there are buttons to toggle Errors , Warnings , and Messages ). 如果我将以下行放在C#代码文件中,它将在构建时生成错误,如果我打开错误,该错误将出现在错误列表窗口中(如列表上方的选项卡,有按钮切换错误 , 警告和消息 )。
#error This will cause a divide by zero
The same can be done to inject warnings into the build output: 将警告注入构建输出也可以这样做:
#warning This might produce a NullReference exception
What would I place in the C# code file to have a message like that appear in the Messages list? 我将在C#代码文件中放置哪些消息,以便在消息列表中显示?
You may use TasksList. 您可以使用TasksList。 On the View menu, point to Other Windows and then click Task List. 在“视图”菜单上,指向“其他Windows”,然后单击“任务列表”。 The Task List is displayed. 将显示“任务列表”。 In the Categories list, click Comments. 在“类别”列表中,单击“注释”。 The Comments list displays the comment text and appears there whenever you open and edit the code file. 注释列表显示注释文本,并在您打开和编辑代码文件时显示。 You can click any Task List comment to activate the file in the Code Editor and jump to the line of code that the comment marks. 您可以单击任何任务列表注释以在代码编辑器中激活该文件,并跳转到注释标记的代码行。 You may use //TODO, //HACK, //UNDONE or you specified custom comments. 您可以使用// TODO,// HACK,// UNDONE或指定自定义注释。
The short answer: You can't. 简短的回答:你做不到。
If you want to communicate with the builder of your code, use warnings or errors as these appear in all builds, not just in Visual Studio. 如果要与代码的构建器进行通信,请使用警告或错误,因为它们出现在所有构建中,而不仅仅是在Visual Studio中。
I think this is what you are looking for: http://www.mztools.com/articles/2008/MZ2008022.aspx 我想这就是你要找的东西: http : //www.mztools.com/articles/2008/MZ2008022.aspx
I stopped by this question because I was searching to do the same from my AddIn written in C# for Visual Studio 2010. 我停止了这个问题,因为我正在寻找从C#for Visual Studio 2010编写的AddIn中做同样的事情。
After a couple of minutes I finally got the answer in that link! 几分钟后,我终于得到了该链接的答案!
Unsure what you are asking? 不确定你在问什么? You basically want to see those errors and warnings displayed? 你基本上想看到那些错误和警告显示?
This may sound very basic but: 1) Make sure your Error List is displayed fully by making the window bigger so you see the headers Description, File, Line... 2) Click on the # Errors and # Warnings buttons at the top. 这可能听起来非常基本但是:1)确保通过使窗口更大来完全显示您的错误列表,以便您看到标题说明,文件,行... 2)单击顶部的#错误和#Warnings按钮。
We tend to do what necrostaz suggested. 我们倾向于做necrostaz建议的。 We've defined our own INFO tag so we can put // INFO This is a message.
我们已经定义了自己的INFO标签,因此我们可以放置// INFO This is a message.
It would be good to find a way to generate an informational message, though. 不过,最好找到一种生成信息性消息的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.