|
|
|
@ -51,7 +51,7 @@ namespace ICSharpCode.ILSpy |
|
|
|
{ |
|
|
|
{ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
#if DEBUG
|
|
|
|
internal static IEnumerable<CSharpLanguage> GetDebugLanguages() |
|
|
|
internal static IEnumerable<CSharpLanguage> GetDebugLanguages() |
|
|
|
{ |
|
|
|
{ |
|
|
|
DecompilerContext context = new DecompilerContext(ModuleDefinition.CreateModule("dummy", ModuleKind.Dll)); |
|
|
|
DecompilerContext context = new DecompilerContext(ModuleDefinition.CreateModule("dummy", ModuleKind.Dll)); |
|
|
|
@ -70,17 +70,20 @@ namespace ICSharpCode.ILSpy |
|
|
|
showAllMembers = true |
|
|
|
showAllMembers = true |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
public override string Name { |
|
|
|
public override string Name |
|
|
|
|
|
|
|
{ |
|
|
|
get { return name; } |
|
|
|
get { return name; } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override string FileExtension { |
|
|
|
public override string FileExtension |
|
|
|
|
|
|
|
{ |
|
|
|
get { return ".cs"; } |
|
|
|
get { return ".cs"; } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override string ProjectFileExtension { |
|
|
|
public override string ProjectFileExtension |
|
|
|
|
|
|
|
{ |
|
|
|
get { return ".csproj"; } |
|
|
|
get { return ".csproj"; } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -286,7 +289,7 @@ namespace ICSharpCode.ILSpy |
|
|
|
IEnumerable<Tuple<string, string>> WriteCodeFilesInProject(AssemblyDefinition assembly, DecompilationOptions options, HashSet<string> directories) |
|
|
|
IEnumerable<Tuple<string, string>> WriteCodeFilesInProject(AssemblyDefinition assembly, DecompilationOptions options, HashSet<string> directories) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var files = assembly.MainModule.Types.Where(t => IncludeTypeWhenDecompilingProject(t, options)).GroupBy( |
|
|
|
var files = assembly.MainModule.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)) { |
|
|
|
return file; |
|
|
|
return file; |
|
|
|
@ -301,7 +304,7 @@ namespace ICSharpCode.ILSpy |
|
|
|
Parallel.ForEach( |
|
|
|
Parallel.ForEach( |
|
|
|
files, |
|
|
|
files, |
|
|
|
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: assembly.MainModule); |
|
|
|
foreach (TypeDefinition type in file) { |
|
|
|
foreach (TypeDefinition type in file) { |
|
|
|
@ -329,7 +332,8 @@ namespace ICSharpCode.ILSpy |
|
|
|
IEnumerable<DictionaryEntry> rs = null; |
|
|
|
IEnumerable<DictionaryEntry> rs = null; |
|
|
|
try { |
|
|
|
try { |
|
|
|
rs = new ResourceSet(s).Cast<DictionaryEntry>(); |
|
|
|
rs = new ResourceSet(s).Cast<DictionaryEntry>(); |
|
|
|
} catch (ArgumentException) { |
|
|
|
} |
|
|
|
|
|
|
|
catch (ArgumentException) { |
|
|
|
} |
|
|
|
} |
|
|
|
if (rs != null && rs.All(e => e.Value is Stream)) { |
|
|
|
if (rs != null && rs.All(e => e.Value is Stream)) { |
|
|
|
foreach (var pair in rs) { |
|
|
|
foreach (var pair in rs) { |
|
|
|
@ -347,7 +351,8 @@ namespace ICSharpCode.ILSpy |
|
|
|
string xaml = null; |
|
|
|
string xaml = null; |
|
|
|
try { |
|
|
|
try { |
|
|
|
xaml = decompiler.DecompileBaml(ms, assembly.FileName, new ConnectMethodDecompiler(assembly), new AssemblyResolver(assembly)); |
|
|
|
xaml = decompiler.DecompileBaml(ms, assembly.FileName, new ConnectMethodDecompiler(assembly), new AssemblyResolver(assembly)); |
|
|
|
} catch (XamlXmlWriterException) {} // ignore XAML writer exceptions
|
|
|
|
} |
|
|
|
|
|
|
|
catch (XamlXmlWriterException) { } // ignore XAML writer exceptions
|
|
|
|
if (xaml != null) { |
|
|
|
if (xaml != null) { |
|
|
|
File.WriteAllText(Path.Combine(options.SaveAsProjectDirectory, Path.ChangeExtension(fileName, ".xaml")), xaml); |
|
|
|
File.WriteAllText(Path.Combine(options.SaveAsProjectDirectory, Path.ChangeExtension(fileName, ".xaml")), xaml); |
|
|
|
yield return Tuple.Create("Page", Path.ChangeExtension(fileName, ".xaml")); |
|
|
|
yield return Tuple.Create("Page", Path.ChangeExtension(fileName, ".xaml")); |
|
|
|
@ -368,7 +373,8 @@ namespace ICSharpCode.ILSpy |
|
|
|
} |
|
|
|
} |
|
|
|
yield return Tuple.Create("EmbeddedResource", fileName); |
|
|
|
yield return Tuple.Create("EmbeddedResource", fileName); |
|
|
|
} |
|
|
|
} |
|
|
|
} finally { |
|
|
|
} |
|
|
|
|
|
|
|
finally { |
|
|
|
if (bamlDecompilerAppDomain != null) |
|
|
|
if (bamlDecompilerAppDomain != null) |
|
|
|
AppDomain.Unload(bamlDecompilerAppDomain); |
|
|
|
AppDomain.Unload(bamlDecompilerAppDomain); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -466,6 +472,14 @@ namespace ICSharpCode.ILSpy |
|
|
|
return showAllMembers || !AstBuilder.MemberIsHidden(member, new DecompilationOptions().DecompilerSettings); |
|
|
|
return showAllMembers || !AstBuilder.MemberIsHidden(member, new DecompilationOptions().DecompilerSettings); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override MemberReference GetOriginalCodeLocation(MemberReference member) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (showAllMembers || !DecompilerSettingsPanel.CurrentDecompilerSettings.AnonymousMethods) |
|
|
|
|
|
|
|
return member; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
return ICSharpCode.ILSpy.TreeNodes.Analyzer.Helpers.GetOriginalCodeLocation(member); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override string GetTooltip(MemberReference member) |
|
|
|
public override string GetTooltip(MemberReference member) |
|
|
|
{ |
|
|
|
{ |
|
|
|
MethodDefinition md = member as MethodDefinition; |
|
|
|
MethodDefinition md = member as MethodDefinition; |
|
|
|
|