View Source CodeDom

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

+3
source share
1 answer

If you create an executable using CodeDom, you can also generate its source code. The following example shows how to create a source file from an object 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);
}
+2
source