|
|
|
@ -72,13 +72,13 @@ namespace ICSharpCode.ILSpy.VB |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (options.FullDecompilation && options.SaveAsProjectDirectory != null) { |
|
|
|
if (options.FullDecompilation && options.SaveAsProjectDirectory != null) { |
|
|
|
HashSet<string> directories = new HashSet<string>(StringComparer.OrdinalIgnoreCase); |
|
|
|
HashSet<string> directories = new HashSet<string>(StringComparer.OrdinalIgnoreCase); |
|
|
|
var files = WriteCodeFilesInProject(assembly.AssemblyDefinition, options, directories).ToList(); |
|
|
|
var files = WriteCodeFilesInProject(assembly.ModuleDefinition, options, directories).ToList(); |
|
|
|
files.AddRange(WriteResourceFilesInProject(assembly, options, directories)); |
|
|
|
files.AddRange(WriteResourceFilesInProject(assembly, options, directories)); |
|
|
|
WriteProjectFile(new TextOutputWriter(output), files, assembly.AssemblyDefinition.MainModule); |
|
|
|
WriteProjectFile(new TextOutputWriter(output), files, assembly.ModuleDefinition); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
base.DecompileAssembly(assembly, output, options); |
|
|
|
base.DecompileAssembly(assembly, output, options); |
|
|
|
output.WriteLine(); |
|
|
|
output.WriteLine(); |
|
|
|
ModuleDefinition mainModule = assembly.AssemblyDefinition.MainModule; |
|
|
|
ModuleDefinition mainModule = assembly.ModuleDefinition; |
|
|
|
if (mainModule.EntryPoint != null) { |
|
|
|
if (mainModule.EntryPoint != null) { |
|
|
|
output.Write("' Entry point: "); |
|
|
|
output.Write("' Entry point: "); |
|
|
|
output.WriteReference(mainModule.EntryPoint.DeclaringType.FullName + "." + mainModule.EntryPoint.Name, mainModule.EntryPoint); |
|
|
|
output.WriteReference(mainModule.EntryPoint.DeclaringType.FullName + "." + mainModule.EntryPoint.Name, mainModule.EntryPoint); |
|
|
|
@ -106,9 +106,9 @@ namespace ICSharpCode.ILSpy.VB |
|
|
|
|
|
|
|
|
|
|
|
// don't automatically load additional assemblies when an assembly node is selected in the tree view
|
|
|
|
// don't automatically load additional assemblies when an assembly node is selected in the tree view
|
|
|
|
using (options.FullDecompilation ? null : LoadedAssembly.DisableAssemblyLoad()) { |
|
|
|
using (options.FullDecompilation ? null : LoadedAssembly.DisableAssemblyLoad()) { |
|
|
|
AstBuilder codeDomBuilder = CreateAstBuilder(options, currentModule: assembly.AssemblyDefinition.MainModule); |
|
|
|
AstBuilder codeDomBuilder = CreateAstBuilder(options, currentModule: assembly.ModuleDefinition); |
|
|
|
codeDomBuilder.AddAssembly(assembly.AssemblyDefinition, onlyAssemblyLevel: !options.FullDecompilation); |
|
|
|
codeDomBuilder.AddAssembly(assembly.ModuleDefinition, onlyAssemblyLevel: !options.FullDecompilation); |
|
|
|
RunTransformsAndGenerateCode(codeDomBuilder, output, options, assembly.AssemblyDefinition.MainModule); |
|
|
|
RunTransformsAndGenerateCode(codeDomBuilder, output, options, assembly.ModuleDefinition); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -248,9 +248,9 @@ namespace ICSharpCode.ILSpy.VB |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
IEnumerable<Tuple<string, string>> WriteCodeFilesInProject(AssemblyDefinition assembly, DecompilationOptions options, HashSet<string> directories) |
|
|
|
IEnumerable<Tuple<string, string>> WriteCodeFilesInProject(ModuleDefinition module, DecompilationOptions options, HashSet<string> directories) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var files = assembly.MainModule.Types.Where(t => IncludeTypeWhenDecompilingProject(t, options)).GroupBy( |
|
|
|
var files = module.Types.Where(t => IncludeTypeWhenDecompilingProject(t, options)).GroupBy( |
|
|
|
delegate(TypeDefinition type) { |
|
|
|
delegate(TypeDefinition type) { |
|
|
|
string file = TextView.DecompilerTextView.CleanUpName(type.Name) + this.FileExtension; |
|
|
|
string file = TextView.DecompilerTextView.CleanUpName(type.Name) + this.FileExtension; |
|
|
|
if (string.IsNullOrEmpty(type.Namespace)) { |
|
|
|
if (string.IsNullOrEmpty(type.Namespace)) { |
|
|
|
@ -268,11 +268,11 @@ namespace ICSharpCode.ILSpy.VB |
|
|
|
new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount }, |
|
|
|
new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount }, |
|
|
|
delegate(IGrouping<string, TypeDefinition> file) { |
|
|
|
delegate(IGrouping<string, TypeDefinition> file) { |
|
|
|
using (StreamWriter w = new StreamWriter(Path.Combine(options.SaveAsProjectDirectory, file.Key))) { |
|
|
|
using (StreamWriter w = new StreamWriter(Path.Combine(options.SaveAsProjectDirectory, file.Key))) { |
|
|
|
AstBuilder codeDomBuilder = CreateAstBuilder(options, currentModule: assembly.MainModule); |
|
|
|
AstBuilder codeDomBuilder = CreateAstBuilder(options, currentModule: module); |
|
|
|
foreach (TypeDefinition type in file) { |
|
|
|
foreach (TypeDefinition type in file) { |
|
|
|
codeDomBuilder.AddType(type); |
|
|
|
codeDomBuilder.AddType(type); |
|
|
|
} |
|
|
|
} |
|
|
|
RunTransformsAndGenerateCode(codeDomBuilder, new PlainTextOutput(w), options, assembly.MainModule); |
|
|
|
RunTransformsAndGenerateCode(codeDomBuilder, new PlainTextOutput(w), options, module); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
AstMethodBodyBuilder.PrintNumberOfUnhandledOpcodes(); |
|
|
|
AstMethodBodyBuilder.PrintNumberOfUnhandledOpcodes(); |
|
|
|
@ -285,7 +285,7 @@ namespace ICSharpCode.ILSpy.VB |
|
|
|
{ |
|
|
|
{ |
|
|
|
//AppDomain bamlDecompilerAppDomain = null;
|
|
|
|
//AppDomain bamlDecompilerAppDomain = null;
|
|
|
|
//try {
|
|
|
|
//try {
|
|
|
|
foreach (EmbeddedResource r in assembly.AssemblyDefinition.MainModule.Resources.OfType<EmbeddedResource>()) { |
|
|
|
foreach (EmbeddedResource r in assembly.ModuleDefinition.Resources.OfType<EmbeddedResource>()) { |
|
|
|
string fileName; |
|
|
|
string fileName; |
|
|
|
Stream s = r.GetResourceStream(); |
|
|
|
Stream s = r.GetResourceStream(); |
|
|
|
s.Position = 0; |
|
|
|
s.Position = 0; |
|
|
|
@ -306,8 +306,8 @@ namespace ICSharpCode.ILSpy.VB |
|
|
|
Stream entryStream = (Stream)pair.Value; |
|
|
|
Stream entryStream = (Stream)pair.Value; |
|
|
|
entryStream.Position = 0; |
|
|
|
entryStream.Position = 0; |
|
|
|
if (fileName.EndsWith(".baml", StringComparison.OrdinalIgnoreCase)) { |
|
|
|
if (fileName.EndsWith(".baml", StringComparison.OrdinalIgnoreCase)) { |
|
|
|
MemoryStream ms = new MemoryStream(); |
|
|
|
//MemoryStream ms = new MemoryStream();
|
|
|
|
entryStream.CopyTo(ms); |
|
|
|
//entryStream.CopyTo(ms);
|
|
|
|
// TODO implement extension point
|
|
|
|
// TODO implement extension point
|
|
|
|
// var decompiler = Baml.BamlResourceEntryNode.CreateBamlDecompilerInAppDomain(ref bamlDecompilerAppDomain, assembly.FileName);
|
|
|
|
// var decompiler = Baml.BamlResourceEntryNode.CreateBamlDecompilerInAppDomain(ref bamlDecompilerAppDomain, assembly.FileName);
|
|
|
|
// string xaml = null;
|
|
|
|
// string xaml = null;
|
|
|
|
|