User Output => Interpretation of Error Interpretation in VS2008 IDE

I have a project "database solution" in VS2008 - it generates SQL for more than one database provider from some templates. To save time, I also have a built-in tool in VS2008 (Python script) that can compile a separate stored procedure. Now, with the Python script, I have the freedom to process the output, and let it take whatever form I want. I play with the idea that these errors and warnings are somehow recognized and populate the list of errors / warnings available by click. Here's what a typical Oracle error looks like:

LINE/COL ERROR -------- ----------------------------------------------------------------- 324/5 PL/SQL: Statement ignored 324/82 PLS-00363: expression 'VSOURCE_SYSTEM_ID' cannot be used as an assignment target Warning: Procedure created with compilation errors. PROCEDURE: ADD_PROPOSED error on creation Errors for PROCEDURE ADD_PROPOSED: LINE/COL ERROR 

It may be a long shot, but for me it is worth it. I do it a lot. Thanks!

+4
source share
1 answer

The IVsSingleFileGenerator interface has a call to the void Generate (...) method, which has a parameter of type IVsGeneratorProgress . This interface has a void GeneratorError () method that allows you to report errors and warnings to the Visual Studio error list. GenerateError () takes a row and a column among other parameters, so I assume that double-clicking your custom error will lead you to the appropriate place in the source file.

To put it all together, I would do something like the following:

 public class MyGenerator : IVsSingleFileGenerator { public Generate(string path, string inputContents, string namespace, IntPtr[] outputContents, out unit outputLength, IVsGeneratorProgress progress) { // Invoke your Python script // Parse the error output from either a file or structure // Assume you generate two lists: one for warnings, one for errors foreach (var error in PythonErrors) progress.GenerateError(false, 0, error.Text, error.Line, error.Column); foreach (var warning in PythonErrors) progress.GenerateError(true, 0, warning.Text, warning.Line, warning.Colum); } } 

Compile this into an assembly. (I don’t understand if this is an EXE or a DLL, but I suspect it will work because you have a class that implements the correct interface.) Then go to the properties of each SQL file in your project and associate the MyGenerator user tool with it. When you compile the project, Visual Studio should now run its own tool and generate output in the error window.

+2
source

Source: https://habr.com/ru/post/1303266/


All Articles