C# StringTemplate - 如何设置 eol 字符

标签 c# stringtemplate

我正在使用 C# 版本的 StringTemplate 库 ( http://www.stringtemplate.org/ ) 生成 C++ 代码。我的模板工作正常,直到我开始使用

<attribute:template(argument-list)>

将模板应用于“列表”中的多个值的语法(如果我在 StringTemplate 术语中是正确的,则为“多值参数”)。从那一刻起,EOL 字符从\n 切换为\r\n,这导致 Visual Studio 和其他编辑器在我每次打开生成的文件时弹出“将行尾字符转换为\n”警告。

所以,我的问题是:如何强制 StringTemplate 始终输出\n 作为 EOL 标记?

最佳答案

您可以尝试使用输出过滤器 ( http://www.antlr.org/wiki/display/ST/Output+Filters ) 将所有\r\n 替换为\n

关于C# StringTemplate - 如何设置 eol 字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/156988/

相关文章:

c# - 检测浏览器语言并避免空引用异常

c# - 将 C 字符串返回到 C# 程序

stringtemplate - StringTemplate 中的分层数据

java - 如何在 StringTemplate 中默认转义 HTML?

渲染模板时ANTLR StringTemplate无限循环

java - 带美元符号的字符串模板

c# - 为什么我在终端中运行它时,在 VS Code 中看不到我用 C# 编写的程序的输出

c# - 您如何用初学者语言描述观察者模式?

c# - 无法在 MongoDB Web API 中按 ID 获取文档

antlr - 使用 Antlr4 和 StringTemplates 从 AST 生成源代码