简体   繁体   中英

View source code for 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.

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);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM