开发者

Integrating DSLs with T4, and indicating script errors

开发者 https://www.devze.com 2023-01-04 23:17 出处:网络
everyone. I have an advanced T4 question and I\'m hoping someone can help. I\'ve created a SQL-like DSL, and the scripts are saved in \'.satsql\' files in my C# projects, like so;

everyone. I have an advanced T4 question and I'm hoping someone can help.

I've created a SQL-like DSL, and the scripts are saved in '.satsql' files in my C# projects, like so;

// contents of myqueries.satsql
SELECT <column t1.Id> FROM <table mytable t1>

I have a .tt file which loads the file and attempts to parse it. If it fails, I want to add an error to the Visual Studio error list, like so;

myqueries.satsql (1,8) error: unknown column 'xid' on table 't3'.
myqueries.satsql (2,9) error: bad reference: pid.

When the user clicks on the error, VS should open the 'my开发者_如何学JAVAqueries.satsql' file and point the cursor at the appropriate line and character, just as it does for C# errors.

T4 already provides the void TextTransform.Error(string) method, but that doesn't seem to give me the opportunity to set the file, line, and character the way C# errors do.

Does anyone know a way for a T4 file to report an error in another file -- not the T4 file itself?

Many thanks,

Steve Cooper.


You can use TextTransformation.Errors collection to report errors with file and line number information.

0

精彩评论

暂无评论...
验证码 换一张
取 消