简体   繁体   English

如何添加到Visual Studio错误列表窗口中的MESSAGES列表?

[英]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.

相关问题 Visual Studio错误列表窗口在生成中打开 - Visual Studio Error List Window Opens on Build 为Visual Studio实用地清除“错误列表”窗口 - Clear Error List window Pragmatically for Visual Studio 如何设计看起来像Visual Studio错误列表的C#视觉主题 - How do I design a C# visual motif that looks like visual studio error list 如何防止 Visual Studio 在错误列表中复制错误? - How do I prevent Visual Studio from duplicating errors in the error list? 如何在 Visual Studio 中获取已连接的 TFS 项目的列表? - How do I get a list of connected TFS projects in Visual Studio? 如何将模型状态错误添加到列表中 - How do I add modelstate error to a list 如何从Visual Studio立即窗口上的列表运行通用查找方法? - How can I run Generic Find method from a List on the Visual Studio Immediate Window? 如何在Visual Studio扩展的“属性窗口对象列表”中修改名称 - How to modify name in Properties Window Object List for Visual Studio extension 如何在Visual Studio中的错误列表中禁用Visual Basic错误 - How to disable visual basic errors in the error list in visual studio 如何将按钮添加到Visual Studio扩展的窗口? - How can I add a button to a window for a Visual Studio Extension?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM