|
|
|
@ -220,6 +220,46 @@ namespace ICSharpCode.ILSpy
@@ -220,6 +220,46 @@ namespace ICSharpCode.ILSpy
|
|
|
|
|
astBuilder.GenerateCode(output); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static string GetPlatformDisplayName(ModuleDefinition module) |
|
|
|
|
{ |
|
|
|
|
switch (module.Architecture) { |
|
|
|
|
case TargetArchitecture.I386: |
|
|
|
|
if ((module.Attributes & ModuleAttributes.Preferred32Bit) == ModuleAttributes.Preferred32Bit) |
|
|
|
|
return "AnyCPU (32-bit preferred)"; |
|
|
|
|
else if ((module.Attributes & ModuleAttributes.Required32Bit) == ModuleAttributes.Required32Bit) |
|
|
|
|
return "x86"; |
|
|
|
|
else |
|
|
|
|
return "AnyCPU (64-bit preferred)"; |
|
|
|
|
break; |
|
|
|
|
case TargetArchitecture.AMD64: |
|
|
|
|
return "x64"; |
|
|
|
|
case TargetArchitecture.IA64: |
|
|
|
|
return "Itanium"; |
|
|
|
|
default: |
|
|
|
|
return module.Architecture.ToString(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static string GetPlatformName(ModuleDefinition module) |
|
|
|
|
{ |
|
|
|
|
switch (module.Architecture) { |
|
|
|
|
case TargetArchitecture.I386: |
|
|
|
|
if ((module.Attributes & ModuleAttributes.Preferred32Bit) == ModuleAttributes.Preferred32Bit) |
|
|
|
|
return "AnyCPU"; |
|
|
|
|
else if ((module.Attributes & ModuleAttributes.Required32Bit) == ModuleAttributes.Required32Bit) |
|
|
|
|
return "x86"; |
|
|
|
|
else |
|
|
|
|
return "AnyCPU"; |
|
|
|
|
break; |
|
|
|
|
case TargetArchitecture.AMD64: |
|
|
|
|
return "x64"; |
|
|
|
|
case TargetArchitecture.IA64: |
|
|
|
|
return "Itanium"; |
|
|
|
|
default: |
|
|
|
|
return module.Architecture.ToString(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override void DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options) |
|
|
|
|
{ |
|
|
|
|
if (options.FullDecompilation && options.SaveAsProjectDirectory != null) { |
|
|
|
@ -236,20 +276,7 @@ namespace ICSharpCode.ILSpy
@@ -236,20 +276,7 @@ namespace ICSharpCode.ILSpy
|
|
|
|
|
output.WriteReference(mainModule.EntryPoint.DeclaringType.FullName + "." + mainModule.EntryPoint.Name, mainModule.EntryPoint); |
|
|
|
|
output.WriteLine(); |
|
|
|
|
} |
|
|
|
|
switch (mainModule.Architecture) { |
|
|
|
|
case TargetArchitecture.I386: |
|
|
|
|
if ((mainModule.Attributes & ModuleAttributes.Required32Bit) == ModuleAttributes.Required32Bit) |
|
|
|
|
output.WriteLine("// Architecture: x86"); |
|
|
|
|
else |
|
|
|
|
output.WriteLine("// Architecture: AnyCPU"); |
|
|
|
|
break; |
|
|
|
|
case TargetArchitecture.AMD64: |
|
|
|
|
output.WriteLine("// Architecture: x64"); |
|
|
|
|
break; |
|
|
|
|
case TargetArchitecture.IA64: |
|
|
|
|
output.WriteLine("// Architecture: Itanium-64"); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
output.WriteLine("// Architecture: " + GetPlatformDisplayName(mainModule)); |
|
|
|
|
if ((mainModule.Attributes & ModuleAttributes.ILOnly) == 0) { |
|
|
|
|
output.WriteLine("// This assembly contains unmanaged code."); |
|
|
|
|
} |
|
|
|
@ -283,23 +310,7 @@ namespace ICSharpCode.ILSpy
@@ -283,23 +310,7 @@ namespace ICSharpCode.ILSpy
|
|
|
|
|
void WriteProjectFile(TextWriter writer, IEnumerable<Tuple<string, string>> files, ModuleDefinition module) |
|
|
|
|
{ |
|
|
|
|
const string ns = "http://schemas.microsoft.com/developer/msbuild/2003"; |
|
|
|
|
string platformName; |
|
|
|
|
switch (module.Architecture) { |
|
|
|
|
case TargetArchitecture.I386: |
|
|
|
|
if ((module.Attributes & ModuleAttributes.Required32Bit) == ModuleAttributes.Required32Bit) |
|
|
|
|
platformName = "x86"; |
|
|
|
|
else |
|
|
|
|
platformName = "AnyCPU"; |
|
|
|
|
break; |
|
|
|
|
case TargetArchitecture.AMD64: |
|
|
|
|
platformName = "x64"; |
|
|
|
|
break; |
|
|
|
|
case TargetArchitecture.IA64: |
|
|
|
|
platformName = "Itanium"; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
throw new NotSupportedException("Invalid value for TargetArchitecture"); |
|
|
|
|
} |
|
|
|
|
string platformName = GetPlatformName(module); |
|
|
|
|
using (XmlTextWriter w = new XmlTextWriter(writer)) { |
|
|
|
|
w.Formatting = Formatting.Indented; |
|
|
|
|
w.WriteStartDocument(); |
|
|
|
|