antlr / antlrcs

The C# port of ANTLR 3, StringTemplate 3, and StringTemplate 4

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TemplateGroupString.FileName is incorrect, causes errors

elanthis opened this issue · comments

The TemplateGroupString.FileName property always returns "<string>" rather than the sourceName field value. Aside from being incorrect when one wants to query the file name, this also causes a bad failure in ErrorManager. The ErrorManager will attempt to parse the FileName during an error using Path.GetFileName(). However, since < is an illegal character, an exception is thrown by Path.GetFileName about invalid characters. This means that a compile error will result in an I/O error with no useful information, making the error reporting and debugging facility all but useless for string template groups.

Replacing the TemplateGroupString.FileName property to return the sourceName (in TemplateGroupString.cs) should fix the issue.

I updated this in two ways:

  1. Make the FileName property simply return sourceName;
  2. Change the default name to [string], which does not contain invalid file name characters