Browse Source

Merge branch 'learn-more-master'

pull/550/head
Siegfried Pammer 11 years ago
parent
commit
56f668da5e
  1. 11
      ILSpy/CommandLineArguments.cs
  2. 3
      ILSpy/Languages/CSharpLanguage.cs
  3. 24
      ILSpy/MainWindow.xaml.cs
  4. 3
      ILSpy/VB/VBLanguage.cs

11
ILSpy/CommandLineArguments.cs

@ -30,6 +30,8 @@ namespace ICSharpCode.ILSpy @@ -30,6 +30,8 @@ namespace ICSharpCode.ILSpy
public string Search;
public string Language;
public bool NoActivate;
public Guid? FixedGuid;
public string SaveDirectory;
public CommandLineArguments(IEnumerable<string> arguments)
{
@ -49,6 +51,15 @@ namespace ICSharpCode.ILSpy @@ -49,6 +51,15 @@ namespace ICSharpCode.ILSpy
this.Language = arg.Substring("/language:".Length);
else if (arg.Equals("/noActivate", StringComparison.OrdinalIgnoreCase))
this.NoActivate = true;
else if (arg.StartsWith("/fixedGuid:", StringComparison.OrdinalIgnoreCase)) {
string guid = arg.Substring("/fixedGuid:".Length);
if (guid.Length < 32)
guid = guid + new string('0', 32 - guid.Length);
Guid fixedGuid;
if (Guid.TryParse(guid, out fixedGuid))
this.FixedGuid = fixedGuid;
} else if (arg.StartsWith("/saveDir:", StringComparison.OrdinalIgnoreCase))
this.SaveDirectory = arg.Substring("/saveDir:".Length);
} else {
this.AssembliesToLoad.Add(arg);
}

3
ILSpy/Languages/CSharpLanguage.cs

@ -321,6 +321,7 @@ namespace ICSharpCode.ILSpy @@ -321,6 +321,7 @@ namespace ICSharpCode.ILSpy
{
const string ns = "http://schemas.microsoft.com/developer/msbuild/2003";
string platformName = GetPlatformName(module);
Guid guid = App.CommandLineArguments.FixedGuid ?? Guid.NewGuid();
using (XmlTextWriter w = new XmlTextWriter(writer)) {
w.Formatting = Formatting.Indented;
w.WriteStartDocument();
@ -329,7 +330,7 @@ namespace ICSharpCode.ILSpy @@ -329,7 +330,7 @@ namespace ICSharpCode.ILSpy
w.WriteAttributeString("DefaultTargets", "Build");
w.WriteStartElement("PropertyGroup");
w.WriteElementString("ProjectGuid", Guid.NewGuid().ToString("B").ToUpperInvariant());
w.WriteElementString("ProjectGuid", guid.ToString("B").ToUpperInvariant());
w.WriteStartElement("Configuration");
w.WriteAttributeString("Condition", " '$(Configuration)' == '' ");

24
ILSpy/MainWindow.xaml.cs

@ -300,9 +300,33 @@ namespace ICSharpCode.ILSpy @@ -300,9 +300,33 @@ namespace ICSharpCode.ILSpy
SearchPane.Instance.SearchTerm = args.Search;
SearchPane.Instance.Show();
}
if (!string.IsNullOrEmpty(args.SaveDirectory)) {
foreach (var x in commandLineLoadedAssemblies) {
x.ContinueWhenLoaded( (Task<ModuleDefinition> moduleTask) => {
OnExportAssembly(moduleTask, args.SaveDirectory);
}, TaskScheduler.FromCurrentSynchronizationContext());
}
}
commandLineLoadedAssemblies.Clear(); // clear references once we don't need them anymore
}
void OnExportAssembly(Task<ModuleDefinition> moduleTask, string path)
{
AssemblyTreeNode asmNode = assemblyListTreeNode.FindAssemblyNode(moduleTask.Result);
if (asmNode != null) {
string file = DecompilerTextView.CleanUpName(asmNode.LoadedAssembly.ShortName);
Language language = sessionSettings.FilterSettings.Language;
DecompilationOptions options = new DecompilationOptions();
options.FullDecompilation = true;
options.SaveAsProjectDirectory = Path.Combine(App.CommandLineArguments.SaveDirectory, file);
if (!Directory.Exists(options.SaveAsProjectDirectory)) {
Directory.CreateDirectory(options.SaveAsProjectDirectory);
}
string fullFile = Path.Combine(options.SaveAsProjectDirectory, file + language.ProjectFileExtension);
TextView.SaveToDisk(language, new[] { asmNode }, options, fullFile);
}
}
void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
ILSpySettings spySettings = this.spySettings;

3
ILSpy/VB/VBLanguage.cs

@ -127,6 +127,7 @@ namespace ICSharpCode.ILSpy.VB @@ -127,6 +127,7 @@ namespace ICSharpCode.ILSpy.VB
{
const string ns = "http://schemas.microsoft.com/developer/msbuild/2003";
string platformName = CSharpLanguage.GetPlatformName(module);
Guid guid = App.CommandLineArguments.FixedGuid ?? Guid.NewGuid();
using (XmlTextWriter w = new XmlTextWriter(writer)) {
w.Formatting = Formatting.Indented;
w.WriteStartDocument();
@ -135,7 +136,7 @@ namespace ICSharpCode.ILSpy.VB @@ -135,7 +136,7 @@ namespace ICSharpCode.ILSpy.VB
w.WriteAttributeString("DefaultTargets", "Build");
w.WriteStartElement("PropertyGroup");
w.WriteElementString("ProjectGuid", Guid.NewGuid().ToString("B").ToUpperInvariant());
w.WriteElementString("ProjectGuid", guid.ToString("B").ToUpperInvariant());
w.WriteStartElement("Configuration");
w.WriteAttributeString("Condition", " '$(Configuration)' == '' ");

Loading…
Cancel
Save