|
|
@ -206,20 +206,22 @@ namespace ICSharpCode.Decompiler.Tests.Helpers |
|
|
|
|
|
|
|
|
|
|
|
public static string DecompileCSharp(string assemblyFileName) |
|
|
|
public static string DecompileCSharp(string assemblyFileName) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var typeSystem = new DecompilerTypeSystem(ModuleDefinition.ReadModule(assemblyFileName)); |
|
|
|
using (var module = ModuleDefinition.ReadModule(assemblyFileName)) { |
|
|
|
CSharpDecompiler decompiler = new CSharpDecompiler(typeSystem, new DecompilerSettings()); |
|
|
|
var typeSystem = new DecompilerTypeSystem(module); |
|
|
|
decompiler.AstTransforms.Insert(0, new RemoveCompilerAttribute()); |
|
|
|
CSharpDecompiler decompiler = new CSharpDecompiler(typeSystem, new DecompilerSettings()); |
|
|
|
decompiler.AstTransforms.Add(new EscapeInvalidIdentifiers()); |
|
|
|
decompiler.AstTransforms.Insert(0, new RemoveCompilerAttribute()); |
|
|
|
var syntaxTree = decompiler.DecompileWholeModuleAsSingleFile(); |
|
|
|
decompiler.AstTransforms.Add(new EscapeInvalidIdentifiers()); |
|
|
|
|
|
|
|
var syntaxTree = decompiler.DecompileWholeModuleAsSingleFile(); |
|
|
|
StringWriter output = new StringWriter(); |
|
|
|
|
|
|
|
var visitor = new CSharpOutputVisitor(output, FormattingOptionsFactory.CreateSharpDevelop()); |
|
|
|
StringWriter output = new StringWriter(); |
|
|
|
syntaxTree.AcceptVisitor(visitor); |
|
|
|
var visitor = new CSharpOutputVisitor(output, FormattingOptionsFactory.CreateSharpDevelop()); |
|
|
|
|
|
|
|
syntaxTree.AcceptVisitor(visitor); |
|
|
|
|
|
|
|
|
|
|
|
string fileName = Path.GetTempFileName(); |
|
|
|
string fileName = Path.GetTempFileName(); |
|
|
|
File.WriteAllText(fileName, output.ToString()); |
|
|
|
File.WriteAllText(fileName, output.ToString()); |
|
|
|
|
|
|
|
|
|
|
|
return fileName; |
|
|
|
return fileName; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void RunAndCompareOutput(string testFileName, string outputFile, string decompiledOutputFile, string decompiledCodeFile = null) |
|
|
|
public static void RunAndCompareOutput(string testFileName, string outputFile, string decompiledOutputFile, string decompiledCodeFile = null) |
|
|
|