查看 CodeDom 的源代码

发布于 2024-11-10 03:15:41 字数 85 浏览 3 评论 0原文

有没有办法从我使用 CodeDom 生成的可执行文件中获取源代码文件?我希望能够打开源文件,以便我可以清楚地看到生成任何代码时出错的位置。

Is there some way to get the source code files from the executable I generated using CodeDom? I would like to be able to open the source files so that I can clearly see where I made errors generating any code.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

硪扪都還晓 2024-11-17 03:15:41

如果您使用 CodeDom 生成可执行文件,您还可以从中生成其源代码。下面的示例展示了如何从 CodeCompileUnit 对象创建源文件。

CodeDomProvider provider = CodeDomProvider.CreateProvider("C#");
System.CodeDom.Compiler.CodeGeneratorOptions options = new CodeGeneratorOptions();
options.BracingStyle = "C";
using (StreamWriter sw = File.CreateText(@"c:\temp\MyFile.cs"))
{
    provider.GenerateCodeFromCompileUnit(unit, sw, options);
}

If you generate an executable with CodeDom, you can also generate its source code from it. The example below shows how to create a source file from the CodeCompileUnit object.

CodeDomProvider provider = CodeDomProvider.CreateProvider("C#");
System.CodeDom.Compiler.CodeGeneratorOptions options = new CodeGeneratorOptions();
options.BracingStyle = "C";
using (StreamWriter sw = File.CreateText(@"c:\temp\MyFile.cs"))
{
    provider.GenerateCodeFromCompileUnit(unit, sw, options);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文