Visual Studio扩展:如何在错误列表中拦截/修改/删除生成错误消息?
我正在开发一个Visual Studio扩展,它将清理"编译错误消息,使它们更易于阅读.
I'm working on a Visual Studio extension that will "clean up" compilation error messages to make them easier to read.
我已经知道如何生成自己的错误.相反,我要尝试做的是修改/替换由于解析编译输出而将Visual Studio添加到错误列表"窗格中的错误消息的文本.
I already know how to generate my own errors. Instead, what I am trying to do is modify/replace the text of the error messages that Visual Studio adds to the Error List pane as a result of parsing compilation output.
到目前为止,我一直没有找到实现此目标的方法.这是我的发现:
So far I have been unsuccessful in finding a way to do this. Here are my findings:
- SVsErrorList中的IVsTaskItems都是只读的,因此我无法直接对其进行编辑.
- 出于相同的原因,我也不能删除IVsTaskItems(因此无法用我自己的IVsTaskItems代替它们.)
- 我可以将自己的文本附加到生成输出窗口"窗格中,但是我无法修改现有文本,以便在Visual Studio解析错误消息之前先编辑错误消息.
还有其他方法可以实现此目标吗?在扩展中的 中是否存在一种方法:
Is there some other way to accomplish this goal? Is there, within an extension, a way to:
- 挂接VS内部进行的调用,以将错误消息添加到错误列表",并在处理之前对其进行更改?
- 要挂钩构建过程中的输出并在VS处理它之前对其进行修改?
- 要通过其他方式实现这一目标?
执行此操作的正确方法是修改编译过程的输出,或者修改项目系统和/或.targets文件的报告方式.信息从编译器到IDE.如果您无法控制编译器或项目系统,那么这将是一件难以完成的任务.
The proper way of doing this would be to either modify the output of your compilation process, or modify the way your project system and/or .targets file reports the information from the compiler to the IDE. If you don't have control over either the compiler or the project system, then this would be a difficult to impossible task.
-
显示的任务实现了
IVsTaskItem
,该接口实际上是由客户端代码实现的,因此不能保证任务项将提供修改其任何值的能力.
Displayed tasks implement
IVsTaskItem
, and this interface is actually implemented by client code so there are no guarantees that a task item will provide the ability to modify any of its values.
The IVsTaskList2
interface adds a method RemoveTasks
, but it requires you have the provider cookie that was returned when the provider was registered (and there is no way to get this).