|
|
@ -47,12 +47,12 @@ namespace ICSharpCode.ILSpy |
|
|
|
string name = "C#"; |
|
|
|
string name = "C#"; |
|
|
|
bool showAllMembers = false; |
|
|
|
bool showAllMembers = false; |
|
|
|
Predicate<IAstTransform> transformAbortCondition = null; |
|
|
|
Predicate<IAstTransform> transformAbortCondition = null; |
|
|
|
|
|
|
|
|
|
|
|
public CSharpLanguage() |
|
|
|
public CSharpLanguage() |
|
|
|
{ |
|
|
|
{ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#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)); |
|
|
@ -71,20 +71,23 @@ 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"; } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override void DecompileMethod(MethodDefinition method, ITextOutput output, DecompilationOptions options) |
|
|
|
public override void DecompileMethod(MethodDefinition method, ITextOutput output, DecompilationOptions options) |
|
|
|
{ |
|
|
|
{ |
|
|
|
WriteCommentLine(output, TypeToString(method.DeclaringType, includeNamespace: true)); |
|
|
|
WriteCommentLine(output, TypeToString(method.DeclaringType, includeNamespace: true)); |
|
|
@ -92,7 +95,7 @@ namespace ICSharpCode.ILSpy |
|
|
|
codeDomBuilder.AddMethod(method); |
|
|
|
codeDomBuilder.AddMethod(method); |
|
|
|
RunTransformsAndGenerateCode(codeDomBuilder, output, options); |
|
|
|
RunTransformsAndGenerateCode(codeDomBuilder, output, options); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override void DecompileProperty(PropertyDefinition property, ITextOutput output, DecompilationOptions options) |
|
|
|
public override void DecompileProperty(PropertyDefinition property, ITextOutput output, DecompilationOptions options) |
|
|
|
{ |
|
|
|
{ |
|
|
|
WriteCommentLine(output, TypeToString(property.DeclaringType, includeNamespace: true)); |
|
|
|
WriteCommentLine(output, TypeToString(property.DeclaringType, includeNamespace: true)); |
|
|
@ -100,7 +103,7 @@ namespace ICSharpCode.ILSpy |
|
|
|
codeDomBuilder.AddProperty(property); |
|
|
|
codeDomBuilder.AddProperty(property); |
|
|
|
RunTransformsAndGenerateCode(codeDomBuilder, output, options); |
|
|
|
RunTransformsAndGenerateCode(codeDomBuilder, output, options); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override void DecompileField(FieldDefinition field, ITextOutput output, DecompilationOptions options) |
|
|
|
public override void DecompileField(FieldDefinition field, ITextOutput output, DecompilationOptions options) |
|
|
|
{ |
|
|
|
{ |
|
|
|
WriteCommentLine(output, TypeToString(field.DeclaringType, includeNamespace: true)); |
|
|
|
WriteCommentLine(output, TypeToString(field.DeclaringType, includeNamespace: true)); |
|
|
@ -108,7 +111,7 @@ namespace ICSharpCode.ILSpy |
|
|
|
codeDomBuilder.AddField(field); |
|
|
|
codeDomBuilder.AddField(field); |
|
|
|
RunTransformsAndGenerateCode(codeDomBuilder, output, options); |
|
|
|
RunTransformsAndGenerateCode(codeDomBuilder, output, options); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override void DecompileEvent(EventDefinition ev, ITextOutput output, DecompilationOptions options) |
|
|
|
public override void DecompileEvent(EventDefinition ev, ITextOutput output, DecompilationOptions options) |
|
|
|
{ |
|
|
|
{ |
|
|
|
WriteCommentLine(output, TypeToString(ev.DeclaringType, includeNamespace: true)); |
|
|
|
WriteCommentLine(output, TypeToString(ev.DeclaringType, includeNamespace: true)); |
|
|
@ -116,7 +119,7 @@ namespace ICSharpCode.ILSpy |
|
|
|
codeDomBuilder.AddEvent(ev); |
|
|
|
codeDomBuilder.AddEvent(ev); |
|
|
|
RunTransformsAndGenerateCode(codeDomBuilder, output, options); |
|
|
|
RunTransformsAndGenerateCode(codeDomBuilder, output, options); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override void DecompileType(TypeDefinition type, ITextOutput output, DecompilationOptions options) |
|
|
|
public override void DecompileType(TypeDefinition type, ITextOutput output, DecompilationOptions options) |
|
|
|
{ |
|
|
|
{ |
|
|
|
AstBuilder codeDomBuilder = CreateAstBuilder(options, currentType: type); |
|
|
|
AstBuilder codeDomBuilder = CreateAstBuilder(options, currentType: type); |
|
|
@ -131,7 +134,7 @@ namespace ICSharpCode.ILSpy |
|
|
|
AddXmlDocTransform.Run(astBuilder.CompilationUnit); |
|
|
|
AddXmlDocTransform.Run(astBuilder.CompilationUnit); |
|
|
|
astBuilder.GenerateCode(output); |
|
|
|
astBuilder.GenerateCode(output); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override void DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options) |
|
|
|
public override void DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (options.FullDecompilation && options.SaveAsProjectDirectory != null) { |
|
|
|
if (options.FullDecompilation && options.SaveAsProjectDirectory != null) { |
|
|
@ -150,7 +153,7 @@ namespace ICSharpCode.ILSpy |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#region WriteProjectFile
|
|
|
|
#region WriteProjectFile
|
|
|
|
void WriteProjectFile(TextWriter writer, IEnumerable<Tuple<string, string>> files, ModuleDefinition module) |
|
|
|
void WriteProjectFile(TextWriter writer, IEnumerable<Tuple<string, string>> files, ModuleDefinition module) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -178,20 +181,20 @@ namespace ICSharpCode.ILSpy |
|
|
|
w.WriteStartElement("Project", ns); |
|
|
|
w.WriteStartElement("Project", ns); |
|
|
|
w.WriteAttributeString("ToolsVersion", "4.0"); |
|
|
|
w.WriteAttributeString("ToolsVersion", "4.0"); |
|
|
|
w.WriteAttributeString("DefaultTargets", "Build"); |
|
|
|
w.WriteAttributeString("DefaultTargets", "Build"); |
|
|
|
|
|
|
|
|
|
|
|
w.WriteStartElement("PropertyGroup"); |
|
|
|
w.WriteStartElement("PropertyGroup"); |
|
|
|
w.WriteElementString("ProjectGuid", Guid.NewGuid().ToString().ToUpperInvariant()); |
|
|
|
w.WriteElementString("ProjectGuid", Guid.NewGuid().ToString().ToUpperInvariant()); |
|
|
|
|
|
|
|
|
|
|
|
w.WriteStartElement("Configuration"); |
|
|
|
w.WriteStartElement("Configuration"); |
|
|
|
w.WriteAttributeString("Condition", " '$(Configuration)' == '' "); |
|
|
|
w.WriteAttributeString("Condition", " '$(Configuration)' == '' "); |
|
|
|
w.WriteValue("Debug"); |
|
|
|
w.WriteValue("Debug"); |
|
|
|
w.WriteEndElement(); // </Configuration>
|
|
|
|
w.WriteEndElement(); // </Configuration>
|
|
|
|
|
|
|
|
|
|
|
|
w.WriteStartElement("Platform"); |
|
|
|
w.WriteStartElement("Platform"); |
|
|
|
w.WriteAttributeString("Condition", " '$(Platform)' == '' "); |
|
|
|
w.WriteAttributeString("Condition", " '$(Platform)' == '' "); |
|
|
|
w.WriteValue(platformName); |
|
|
|
w.WriteValue(platformName); |
|
|
|
w.WriteEndElement(); // </Platform>
|
|
|
|
w.WriteEndElement(); // </Platform>
|
|
|
|
|
|
|
|
|
|
|
|
switch (module.Kind) { |
|
|
|
switch (module.Kind) { |
|
|
|
case ModuleKind.Windows: |
|
|
|
case ModuleKind.Windows: |
|
|
|
w.WriteElementString("OutputType", "WinExe"); |
|
|
|
w.WriteElementString("OutputType", "WinExe"); |
|
|
@ -203,7 +206,7 @@ namespace ICSharpCode.ILSpy |
|
|
|
w.WriteElementString("OutputType", "Library"); |
|
|
|
w.WriteElementString("OutputType", "Library"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
w.WriteElementString("AssemblyName", module.Assembly.Name.Name); |
|
|
|
w.WriteElementString("AssemblyName", module.Assembly.Name.Name); |
|
|
|
switch (module.Runtime) { |
|
|
|
switch (module.Runtime) { |
|
|
|
case TargetRuntime.Net_1_0: |
|
|
|
case TargetRuntime.Net_1_0: |
|
|
@ -222,14 +225,14 @@ namespace ICSharpCode.ILSpy |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
w.WriteElementString("WarningLevel", "4"); |
|
|
|
w.WriteElementString("WarningLevel", "4"); |
|
|
|
|
|
|
|
|
|
|
|
w.WriteEndElement(); // </PropertyGroup>
|
|
|
|
w.WriteEndElement(); // </PropertyGroup>
|
|
|
|
|
|
|
|
|
|
|
|
w.WriteStartElement("PropertyGroup"); // platform-specific
|
|
|
|
w.WriteStartElement("PropertyGroup"); // platform-specific
|
|
|
|
w.WriteAttributeString("Condition", " '$(Platform)' == '" + platformName + "' "); |
|
|
|
w.WriteAttributeString("Condition", " '$(Platform)' == '" + platformName + "' "); |
|
|
|
w.WriteElementString("PlatformTarget", platformName); |
|
|
|
w.WriteElementString("PlatformTarget", platformName); |
|
|
|
w.WriteEndElement(); // </PropertyGroup> (platform-specific)
|
|
|
|
w.WriteEndElement(); // </PropertyGroup> (platform-specific)
|
|
|
|
|
|
|
|
|
|
|
|
w.WriteStartElement("PropertyGroup"); // Debug
|
|
|
|
w.WriteStartElement("PropertyGroup"); // Debug
|
|
|
|
w.WriteAttributeString("Condition", " '$(Configuration)' == 'Debug' "); |
|
|
|
w.WriteAttributeString("Condition", " '$(Configuration)' == 'Debug' "); |
|
|
|
w.WriteElementString("OutputPath", "bin\\Debug\\"); |
|
|
|
w.WriteElementString("OutputPath", "bin\\Debug\\"); |
|
|
@ -237,7 +240,7 @@ namespace ICSharpCode.ILSpy |
|
|
|
w.WriteElementString("DebugType", "full"); |
|
|
|
w.WriteElementString("DebugType", "full"); |
|
|
|
w.WriteElementString("Optimize", "false"); |
|
|
|
w.WriteElementString("Optimize", "false"); |
|
|
|
w.WriteEndElement(); // </PropertyGroup> (Debug)
|
|
|
|
w.WriteEndElement(); // </PropertyGroup> (Debug)
|
|
|
|
|
|
|
|
|
|
|
|
w.WriteStartElement("PropertyGroup"); // Release
|
|
|
|
w.WriteStartElement("PropertyGroup"); // Release
|
|
|
|
w.WriteAttributeString("Condition", " '$(Configuration)' == 'Release' "); |
|
|
|
w.WriteAttributeString("Condition", " '$(Configuration)' == 'Release' "); |
|
|
|
w.WriteElementString("OutputPath", "bin\\Release\\"); |
|
|
|
w.WriteElementString("OutputPath", "bin\\Release\\"); |
|
|
@ -245,8 +248,8 @@ namespace ICSharpCode.ILSpy |
|
|
|
w.WriteElementString("DebugType", "pdbonly"); |
|
|
|
w.WriteElementString("DebugType", "pdbonly"); |
|
|
|
w.WriteElementString("Optimize", "true"); |
|
|
|
w.WriteElementString("Optimize", "true"); |
|
|
|
w.WriteEndElement(); // </PropertyGroup> (Release)
|
|
|
|
w.WriteEndElement(); // </PropertyGroup> (Release)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
w.WriteStartElement("ItemGroup"); // References
|
|
|
|
w.WriteStartElement("ItemGroup"); // References
|
|
|
|
foreach (AssemblyNameReference r in module.AssemblyReferences) { |
|
|
|
foreach (AssemblyNameReference r in module.AssemblyReferences) { |
|
|
|
if (r.Name != "mscorlib") { |
|
|
|
if (r.Name != "mscorlib") { |
|
|
@ -257,7 +260,7 @@ namespace ICSharpCode.ILSpy |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
w.WriteEndElement(); // </ItemGroup> (References)
|
|
|
|
w.WriteEndElement(); // </ItemGroup> (References)
|
|
|
|
|
|
|
|
|
|
|
|
foreach (IGrouping<string, string> gr in (from f in files group f.Item2 by f.Item1 into g orderby g.Key select g)) { |
|
|
|
foreach (IGrouping<string, string> gr in (from f in files group f.Item2 by f.Item1 into g orderby g.Key select g)) { |
|
|
|
w.WriteStartElement("ItemGroup"); |
|
|
|
w.WriteStartElement("ItemGroup"); |
|
|
|
foreach (string file in gr.OrderBy(f => f, StringComparer.OrdinalIgnoreCase)) { |
|
|
|
foreach (string file in gr.OrderBy(f => f, StringComparer.OrdinalIgnoreCase)) { |
|
|
@ -267,16 +270,16 @@ namespace ICSharpCode.ILSpy |
|
|
|
} |
|
|
|
} |
|
|
|
w.WriteEndElement(); |
|
|
|
w.WriteEndElement(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
w.WriteStartElement("Import"); |
|
|
|
w.WriteStartElement("Import"); |
|
|
|
w.WriteAttributeString("Project", "$(MSBuildToolsPath)\\Microsoft.CSharp.targets"); |
|
|
|
w.WriteAttributeString("Project", "$(MSBuildToolsPath)\\Microsoft.CSharp.targets"); |
|
|
|
w.WriteEndElement(); |
|
|
|
w.WriteEndElement(); |
|
|
|
|
|
|
|
|
|
|
|
w.WriteEndDocument(); |
|
|
|
w.WriteEndDocument(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region WriteCodeFilesInProject
|
|
|
|
#region WriteCodeFilesInProject
|
|
|
|
bool IncludeTypeWhenDecompilingProject(TypeDefinition type, DecompilationOptions options) |
|
|
|
bool IncludeTypeWhenDecompilingProject(TypeDefinition type, DecompilationOptions options) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -286,11 +289,11 @@ namespace ICSharpCode.ILSpy |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
@ -305,7 +308,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) { |
|
|
@ -319,7 +322,7 @@ namespace ICSharpCode.ILSpy |
|
|
|
return files.Select(f => Tuple.Create("Compile", f.Key)); |
|
|
|
return files.Select(f => Tuple.Create("Compile", f.Key)); |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region WriteResourceFilesInProject
|
|
|
|
#region WriteResourceFilesInProject
|
|
|
|
IEnumerable<Tuple<string, string>> WriteResourceFilesInProject(LoadedAssembly assembly, DecompilationOptions options, HashSet<string> directories) |
|
|
|
IEnumerable<Tuple<string, string>> WriteResourceFilesInProject(LoadedAssembly assembly, DecompilationOptions options, HashSet<string> directories) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -333,7 +336,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) { |
|
|
@ -351,7 +355,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")); |
|
|
@ -372,12 +377,13 @@ 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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
string GetFileNameForResource(string fullName, HashSet<string> directories) |
|
|
|
string GetFileNameForResource(string fullName, HashSet<string> directories) |
|
|
|
{ |
|
|
|
{ |
|
|
|
string[] splitName = fullName.Split('.'); |
|
|
|
string[] splitName = fullName.Split('.'); |
|
|
@ -393,7 +399,7 @@ namespace ICSharpCode.ILSpy |
|
|
|
return fileName; |
|
|
|
return fileName; |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
AstBuilder CreateAstBuilder(DecompilationOptions options, ModuleDefinition currentModule = null, TypeDefinition currentType = null, bool isSingleMember = false) |
|
|
|
AstBuilder CreateAstBuilder(DecompilationOptions options, ModuleDefinition currentModule = null, TypeDefinition currentType = null, bool isSingleMember = false) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (currentModule == null) |
|
|
|
if (currentModule == null) |
|
|
@ -417,7 +423,7 @@ namespace ICSharpCode.ILSpy |
|
|
|
if (includeNamespace) |
|
|
|
if (includeNamespace) |
|
|
|
options |= ConvertTypeOptions.IncludeNamespace; |
|
|
|
options |= ConvertTypeOptions.IncludeNamespace; |
|
|
|
AstType astType = AstBuilder.ConvertType(type, typeAttributes, options); |
|
|
|
AstType astType = AstBuilder.ConvertType(type, typeAttributes, options); |
|
|
|
|
|
|
|
|
|
|
|
StringWriter w = new StringWriter(); |
|
|
|
StringWriter w = new StringWriter(); |
|
|
|
if (type.IsByReference) { |
|
|
|
if (type.IsByReference) { |
|
|
|
ParameterDefinition pd = typeAttributes as ParameterDefinition; |
|
|
|
ParameterDefinition pd = typeAttributes as ParameterDefinition; |
|
|
@ -425,11 +431,11 @@ namespace ICSharpCode.ILSpy |
|
|
|
w.Write("out "); |
|
|
|
w.Write("out "); |
|
|
|
else |
|
|
|
else |
|
|
|
w.Write("ref "); |
|
|
|
w.Write("ref "); |
|
|
|
|
|
|
|
|
|
|
|
if (astType is ComposedType && ((ComposedType)astType).PointerRank > 0) |
|
|
|
if (astType is ComposedType && ((ComposedType)astType).PointerRank > 0) |
|
|
|
((ComposedType)astType).PointerRank--; |
|
|
|
((ComposedType)astType).PointerRank--; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
astType.AcceptVisitor(new OutputVisitor(w, new CSharpFormattingOptions()), null); |
|
|
|
astType.AcceptVisitor(new OutputVisitor(w, new CSharpFormattingOptions()), null); |
|
|
|
return w.ToString(); |
|
|
|
return w.ToString(); |
|
|
|
} |
|
|
|
} |
|
|
@ -464,12 +470,20 @@ namespace ICSharpCode.ILSpy |
|
|
|
} else |
|
|
|
} else |
|
|
|
return property.Name; |
|
|
|
return property.Name; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override bool ShowMember(MemberReference member) |
|
|
|
public override bool ShowMember(MemberReference member) |
|
|
|
{ |
|
|
|
{ |
|
|
|
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; |
|
|
@ -490,12 +504,12 @@ namespace ICSharpCode.ILSpy |
|
|
|
b.RunTransformations(); |
|
|
|
b.RunTransformations(); |
|
|
|
foreach (var attribute in b.CompilationUnit.Descendants.OfType<AttributeSection>()) |
|
|
|
foreach (var attribute in b.CompilationUnit.Descendants.OfType<AttributeSection>()) |
|
|
|
attribute.Remove(); |
|
|
|
attribute.Remove(); |
|
|
|
|
|
|
|
|
|
|
|
StringWriter w = new StringWriter(); |
|
|
|
StringWriter w = new StringWriter(); |
|
|
|
b.GenerateCode(new PlainTextOutput(w)); |
|
|
|
b.GenerateCode(new PlainTextOutput(w)); |
|
|
|
return Regex.Replace(w.ToString(), @"\s+", " ").TrimEnd(); |
|
|
|
return Regex.Replace(w.ToString(), @"\s+", " ").TrimEnd(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return base.GetTooltip(member); |
|
|
|
return base.GetTooltip(member); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|