|
|
@ -18,20 +18,25 @@ |
|
|
|
|
|
|
|
|
|
|
|
using System; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.Generic; |
|
|
|
|
|
|
|
using System.Diagnostics; |
|
|
|
using System.IO; |
|
|
|
using System.IO; |
|
|
|
using System.Linq; |
|
|
|
using System.Linq; |
|
|
|
using System.Text; |
|
|
|
|
|
|
|
using System.Threading; |
|
|
|
using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using System.Windows; |
|
|
|
using System.Windows; |
|
|
|
using System.Windows.Controls; |
|
|
|
using System.Windows.Controls; |
|
|
|
|
|
|
|
using System.Windows.Input; |
|
|
|
|
|
|
|
using System.Windows.Media; |
|
|
|
using System.Windows.Media.Animation; |
|
|
|
using System.Windows.Media.Animation; |
|
|
|
using System.Windows.Threading; |
|
|
|
using System.Windows.Threading; |
|
|
|
using System.Xml; |
|
|
|
using System.Xml; |
|
|
|
|
|
|
|
|
|
|
|
using ICSharpCode.AvalonEdit.Folding; |
|
|
|
using ICSharpCode.AvalonEdit.Folding; |
|
|
|
using ICSharpCode.AvalonEdit.Highlighting; |
|
|
|
using ICSharpCode.AvalonEdit.Highlighting; |
|
|
|
using ICSharpCode.AvalonEdit.Highlighting.Xshd; |
|
|
|
using ICSharpCode.AvalonEdit.Highlighting.Xshd; |
|
|
|
|
|
|
|
using ICSharpCode.Decompiler; |
|
|
|
using ICSharpCode.ILSpy.TreeNodes; |
|
|
|
using ICSharpCode.ILSpy.TreeNodes; |
|
|
|
|
|
|
|
using Microsoft.Win32; |
|
|
|
using Mono.Cecil; |
|
|
|
using Mono.Cecil; |
|
|
|
|
|
|
|
|
|
|
|
namespace ICSharpCode.ILSpy.TextView |
|
|
|
namespace ICSharpCode.ILSpy.TextView |
|
|
@ -42,12 +47,14 @@ namespace ICSharpCode.ILSpy.TextView |
|
|
|
sealed partial class DecompilerTextView : UserControl |
|
|
|
sealed partial class DecompilerTextView : UserControl |
|
|
|
{ |
|
|
|
{ |
|
|
|
readonly ReferenceElementGenerator referenceElementGenerator; |
|
|
|
readonly ReferenceElementGenerator referenceElementGenerator; |
|
|
|
|
|
|
|
readonly UIElementGenerator uiElementGenerator; |
|
|
|
readonly FoldingManager foldingManager; |
|
|
|
readonly FoldingManager foldingManager; |
|
|
|
internal MainWindow mainWindow; |
|
|
|
internal MainWindow mainWindow; |
|
|
|
|
|
|
|
|
|
|
|
DefinitionLookup definitionLookup; |
|
|
|
DefinitionLookup definitionLookup; |
|
|
|
CancellationTokenSource currentCancellationTokenSource; |
|
|
|
CancellationTokenSource currentCancellationTokenSource; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Constructor
|
|
|
|
public DecompilerTextView() |
|
|
|
public DecompilerTextView() |
|
|
|
{ |
|
|
|
{ |
|
|
|
HighlightingManager.Instance.RegisterHighlighting( |
|
|
|
HighlightingManager.Instance.RegisterHighlighting( |
|
|
@ -63,11 +70,15 @@ namespace ICSharpCode.ILSpy.TextView |
|
|
|
InitializeComponent(); |
|
|
|
InitializeComponent(); |
|
|
|
this.referenceElementGenerator = new ReferenceElementGenerator(this); |
|
|
|
this.referenceElementGenerator = new ReferenceElementGenerator(this); |
|
|
|
textEditor.TextArea.TextView.ElementGenerators.Add(referenceElementGenerator); |
|
|
|
textEditor.TextArea.TextView.ElementGenerators.Add(referenceElementGenerator); |
|
|
|
|
|
|
|
this.uiElementGenerator = new UIElementGenerator(); |
|
|
|
|
|
|
|
textEditor.TextArea.TextView.ElementGenerators.Add(uiElementGenerator); |
|
|
|
textEditor.Text = "Welcome to ILSpy!"; |
|
|
|
textEditor.Text = "Welcome to ILSpy!"; |
|
|
|
foldingManager = FoldingManager.Install(textEditor.TextArea); |
|
|
|
foldingManager = FoldingManager.Install(textEditor.TextArea); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
public void Decompile(ILSpy.Language language, IEnumerable<ILSpyTreeNodeBase> treeNodes) |
|
|
|
#region RunWithCancellation
|
|
|
|
|
|
|
|
void RunWithCancellation<T>(Func<CancellationToken, Task<T>> taskCreation, Action<Task<T>> taskCompleted) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (waitAdorner.Visibility != Visibility.Visible) { |
|
|
|
if (waitAdorner.Visibility != Visibility.Visible) { |
|
|
|
waitAdorner.Visibility = Visibility.Visible; |
|
|
|
waitAdorner.Visibility = Visibility.Visible; |
|
|
@ -80,35 +91,13 @@ namespace ICSharpCode.ILSpy.TextView |
|
|
|
if (previousCancellationTokenSource != null) |
|
|
|
if (previousCancellationTokenSource != null) |
|
|
|
previousCancellationTokenSource.Cancel(); |
|
|
|
previousCancellationTokenSource.Cancel(); |
|
|
|
|
|
|
|
|
|
|
|
DecompilationOptions options = new DecompilationOptions(); |
|
|
|
var task = taskCreation(myCancellationTokenSource.Token); |
|
|
|
options.CancellationToken = myCancellationTokenSource.Token; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var task = RunDecompiler(language, treeNodes.ToArray(), options); |
|
|
|
|
|
|
|
Action continuation = delegate { |
|
|
|
Action continuation = delegate { |
|
|
|
try { |
|
|
|
try { |
|
|
|
if (currentCancellationTokenSource == myCancellationTokenSource) { |
|
|
|
if (currentCancellationTokenSource == myCancellationTokenSource) { |
|
|
|
currentCancellationTokenSource = null; |
|
|
|
currentCancellationTokenSource = null; |
|
|
|
waitAdorner.Visibility = Visibility.Collapsed; |
|
|
|
waitAdorner.Visibility = Visibility.Collapsed; |
|
|
|
textEditor.ScrollToHome(); |
|
|
|
taskCompleted(task); |
|
|
|
foldingManager.Clear(); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
SmartTextOutput textOutput = task.Result; |
|
|
|
|
|
|
|
referenceElementGenerator.References = textOutput.References; |
|
|
|
|
|
|
|
definitionLookup = textOutput.DefinitionLookup; |
|
|
|
|
|
|
|
textEditor.SyntaxHighlighting = language.SyntaxHighlighting; |
|
|
|
|
|
|
|
textEditor.Text = textOutput.ToString(); |
|
|
|
|
|
|
|
foldingManager.UpdateFoldings(textOutput.Foldings.OrderBy(f => f.StartOffset), -1); |
|
|
|
|
|
|
|
} catch (AggregateException aggregateException) { |
|
|
|
|
|
|
|
textEditor.SyntaxHighlighting = null; |
|
|
|
|
|
|
|
referenceElementGenerator.References = null; |
|
|
|
|
|
|
|
definitionLookup = null; |
|
|
|
|
|
|
|
// Unpack aggregate exceptions as long as there's only a single exception:
|
|
|
|
|
|
|
|
// (assembly load errors might produce nested aggregate exceptions)
|
|
|
|
|
|
|
|
Exception ex = aggregateException; |
|
|
|
|
|
|
|
while (ex is AggregateException && (ex as AggregateException).InnerExceptions.Count == 1) |
|
|
|
|
|
|
|
ex = ex.InnerException; |
|
|
|
|
|
|
|
textEditor.Text = ex.ToString(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
try { |
|
|
|
try { |
|
|
|
task.Wait(); |
|
|
|
task.Wait(); |
|
|
@ -123,8 +112,71 @@ namespace ICSharpCode.ILSpy.TextView |
|
|
|
task.ContinueWith(delegate { Dispatcher.BeginInvoke(DispatcherPriority.Normal, continuation); }); |
|
|
|
task.ContinueWith(delegate { Dispatcher.BeginInvoke(DispatcherPriority.Normal, continuation); }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static Task<SmartTextOutput> RunDecompiler(ILSpy.Language language, ILSpyTreeNodeBase[] nodes, DecompilationOptions options) |
|
|
|
void cancelButton_Click(object sender, RoutedEventArgs e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (currentCancellationTokenSource != null) |
|
|
|
|
|
|
|
currentCancellationTokenSource.Cancel(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region ShowOutput
|
|
|
|
|
|
|
|
void ShowOutput(SmartTextOutput textOutput, ILSpy.Language language = null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
textEditor.ScrollToHome(); |
|
|
|
|
|
|
|
foldingManager.Clear(); |
|
|
|
|
|
|
|
uiElementGenerator.UIElements = textOutput.UIElements; |
|
|
|
|
|
|
|
referenceElementGenerator.References = textOutput.References; |
|
|
|
|
|
|
|
definitionLookup = textOutput.DefinitionLookup; |
|
|
|
|
|
|
|
textEditor.SyntaxHighlighting = language != null ? language.SyntaxHighlighting : null; |
|
|
|
|
|
|
|
textEditor.Text = textOutput.ToString(); |
|
|
|
|
|
|
|
foldingManager.UpdateFoldings(textOutput.Foldings.OrderBy(f => f.StartOffset), -1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Decompile (for display)
|
|
|
|
|
|
|
|
const int defaultOutputLengthLimit = 5000000; // more than 5M characters is too slow to output (when user browses treeview)
|
|
|
|
|
|
|
|
const int extendedOutputLengthLimit = 75000000; // more than 75M characters can get us into trouble with memory usage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void Decompile(ILSpy.Language language, IEnumerable<ILSpyTreeNodeBase> treeNodes, DecompilationOptions options) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Decompile(language, treeNodes.ToArray(), defaultOutputLengthLimit, options); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Decompile(ILSpy.Language language, ILSpyTreeNodeBase[] treeNodes, int outputLengthLimit, DecompilationOptions options) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
RunWithCancellation( |
|
|
|
|
|
|
|
delegate (CancellationToken ct) { // creation of the background task
|
|
|
|
|
|
|
|
options.CancellationToken = ct; |
|
|
|
|
|
|
|
return RunDecompiler(language, treeNodes, options, outputLengthLimit); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
delegate (Task<SmartTextOutput> task) { // handling the result
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
SmartTextOutput textOutput = task.Result; |
|
|
|
|
|
|
|
Debug.WriteLine("Decompiler finished; output size = {0} characters", textOutput.TextLength); |
|
|
|
|
|
|
|
ShowOutput(textOutput, language); |
|
|
|
|
|
|
|
} catch (AggregateException aggregateException) { |
|
|
|
|
|
|
|
textEditor.SyntaxHighlighting = null; |
|
|
|
|
|
|
|
Debug.WriteLine("Decompiler crashed: " + aggregateException.ToString()); |
|
|
|
|
|
|
|
// Unpack aggregate exceptions as long as there's only a single exception:
|
|
|
|
|
|
|
|
// (assembly load errors might produce nested aggregate exceptions)
|
|
|
|
|
|
|
|
Exception ex = aggregateException; |
|
|
|
|
|
|
|
while (ex is AggregateException && (ex as AggregateException).InnerExceptions.Count == 1) |
|
|
|
|
|
|
|
ex = ex.InnerException; |
|
|
|
|
|
|
|
if (ex is OutputLengthExceededException) { |
|
|
|
|
|
|
|
ShowOutputLengthExceededMessage(language, treeNodes, options, outputLengthLimit == defaultOutputLengthLimit); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
SmartTextOutput output = new SmartTextOutput(); |
|
|
|
|
|
|
|
output.WriteLine(ex.ToString()); |
|
|
|
|
|
|
|
ShowOutput(output); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static Task<SmartTextOutput> RunDecompiler(ILSpy.Language language, ILSpyTreeNodeBase[] nodes, DecompilationOptions options, int outputLengthLimit) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Debug.WriteLine("Start decompilation of {0} nodes", nodes.Length); |
|
|
|
|
|
|
|
|
|
|
|
if (nodes.Length == 0) { |
|
|
|
if (nodes.Length == 0) { |
|
|
|
// If there's nothing to be decompiled, don't bother starting up a thread.
|
|
|
|
// If there's nothing to be decompiled, don't bother starting up a thread.
|
|
|
|
// (Improves perf in some cases since we don't have to wait for the thread-pool to accept our task)
|
|
|
|
// (Improves perf in some cases since we don't have to wait for the thread-pool to accept our task)
|
|
|
@ -136,16 +188,77 @@ namespace ICSharpCode.ILSpy.TextView |
|
|
|
return Task.Factory.StartNew( |
|
|
|
return Task.Factory.StartNew( |
|
|
|
delegate { |
|
|
|
delegate { |
|
|
|
SmartTextOutput textOutput = new SmartTextOutput(); |
|
|
|
SmartTextOutput textOutput = new SmartTextOutput(); |
|
|
|
bool first = true; |
|
|
|
textOutput.LengthLimit = outputLengthLimit; |
|
|
|
foreach (var node in nodes) { |
|
|
|
DecompileNodes(language, nodes, options, textOutput); |
|
|
|
if (first) first = false; else textOutput.WriteLine(); |
|
|
|
|
|
|
|
options.CancellationToken.ThrowIfCancellationRequested(); |
|
|
|
|
|
|
|
node.Decompile(language, textOutput, options); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return textOutput; |
|
|
|
return textOutput; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void DecompileNodes(ILSpy.Language language, ILSpyTreeNodeBase[] nodes, DecompilationOptions options, ITextOutput textOutput) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bool first = true; |
|
|
|
|
|
|
|
foreach (var node in nodes) { |
|
|
|
|
|
|
|
if (first) first = false; else textOutput.WriteLine(); |
|
|
|
|
|
|
|
options.CancellationToken.ThrowIfCancellationRequested(); |
|
|
|
|
|
|
|
node.Decompile(language, textOutput, options); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region ShowOutputLengthExceededMessage
|
|
|
|
|
|
|
|
void ShowOutputLengthExceededMessage(ILSpy.Language language, ILSpyTreeNodeBase[] treeNodes, DecompilationOptions options, bool wasNormalLimit) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
SmartTextOutput output = new SmartTextOutput(); |
|
|
|
|
|
|
|
if (wasNormalLimit) { |
|
|
|
|
|
|
|
output.WriteLine("You have selected too much code for it to be displayed automatically."); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
output.WriteLine("You have selected too much code; it cannot be displayed here."); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
output.WriteLine(); |
|
|
|
|
|
|
|
Button button; |
|
|
|
|
|
|
|
if (wasNormalLimit) { |
|
|
|
|
|
|
|
output.AddUIElement(MakeButton( |
|
|
|
|
|
|
|
Images.ViewCode, "Display Code", |
|
|
|
|
|
|
|
delegate { |
|
|
|
|
|
|
|
Decompile(language, treeNodes, extendedOutputLengthLimit, options); |
|
|
|
|
|
|
|
})); |
|
|
|
|
|
|
|
output.WriteLine(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
output.AddUIElement(MakeButton( |
|
|
|
|
|
|
|
Images.Save, "Save Code", |
|
|
|
|
|
|
|
delegate { |
|
|
|
|
|
|
|
SaveToDisk(language, treeNodes, options); |
|
|
|
|
|
|
|
})); |
|
|
|
|
|
|
|
output.WriteLine(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ShowOutput(output); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Func<Button> MakeButton(ImageSource icon, string text, RoutedEventHandler click) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return () => { |
|
|
|
|
|
|
|
Button button = new Button(); |
|
|
|
|
|
|
|
button.Cursor = Cursors.Arrow; |
|
|
|
|
|
|
|
button.Margin = new Thickness(2); |
|
|
|
|
|
|
|
if (icon != null) { |
|
|
|
|
|
|
|
button.Content = new StackPanel { |
|
|
|
|
|
|
|
Orientation = Orientation.Horizontal, |
|
|
|
|
|
|
|
Children = { |
|
|
|
|
|
|
|
new Image { Width = 16, Height = 16, Source = icon, Margin = new Thickness(0, 0, 4, 0) }, |
|
|
|
|
|
|
|
new TextBlock { Text = text } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
button.Content = text; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
button.Click += click; |
|
|
|
|
|
|
|
return button; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region JumpToReference
|
|
|
|
internal void JumpToReference(ReferenceSegment referenceSegment) |
|
|
|
internal void JumpToReference(ReferenceSegment referenceSegment) |
|
|
|
{ |
|
|
|
{ |
|
|
|
object reference = referenceSegment.Reference; |
|
|
|
object reference = referenceSegment.Reference; |
|
|
@ -177,11 +290,80 @@ namespace ICSharpCode.ILSpy.TextView |
|
|
|
mainWindow.SelectNode(assemblyList.Assemblies.FirstOrDefault(node => node.AssemblyDefinition == reference)); |
|
|
|
mainWindow.SelectNode(assemblyList.Assemblies.FirstOrDefault(node => node.AssemblyDefinition == reference)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
void cancelButton_Click(object sender, RoutedEventArgs e) |
|
|
|
#region SaveToDisk
|
|
|
|
|
|
|
|
public void SaveToDisk(ILSpy.Language language, IEnumerable<ILSpyTreeNodeBase> treeNodes, DecompilationOptions options) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (currentCancellationTokenSource != null) |
|
|
|
if (!treeNodes.Any()) |
|
|
|
currentCancellationTokenSource.Cancel(); |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SaveFileDialog dlg = new SaveFileDialog(); |
|
|
|
|
|
|
|
dlg.DefaultExt = language.FileExtension; |
|
|
|
|
|
|
|
dlg.Filter = language.Name + "|*" + language.FileExtension + "|All Files|*.*"; |
|
|
|
|
|
|
|
dlg.FileName = CleanUpName(treeNodes.First().ToString()) + language.FileExtension; |
|
|
|
|
|
|
|
if (dlg.ShowDialog() == true) { |
|
|
|
|
|
|
|
SaveToDisk(language, treeNodes.ToArray(), options, dlg.FileName); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SaveToDisk(ILSpy.Language language, ILSpyTreeNodeBase[] nodes, DecompilationOptions options, string fileName) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
RunWithCancellation( |
|
|
|
|
|
|
|
delegate (CancellationToken ct) { |
|
|
|
|
|
|
|
options.CancellationToken = ct; |
|
|
|
|
|
|
|
return Task.Factory.StartNew( |
|
|
|
|
|
|
|
delegate { |
|
|
|
|
|
|
|
using (StreamWriter w = new StreamWriter(fileName)) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
DecompileNodes(language, nodes, options, new PlainTextOutput(w)); |
|
|
|
|
|
|
|
} catch (OperationCanceledException) { |
|
|
|
|
|
|
|
w.WriteLine(); |
|
|
|
|
|
|
|
w.WriteLine("Decompiled was cancelled."); |
|
|
|
|
|
|
|
throw; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SmartTextOutput output = new SmartTextOutput(); |
|
|
|
|
|
|
|
output.WriteLine("Decompilation complete."); |
|
|
|
|
|
|
|
output.WriteLine(); |
|
|
|
|
|
|
|
output.AddUIElement(MakeButton( |
|
|
|
|
|
|
|
null, "Open Explorer", |
|
|
|
|
|
|
|
delegate { |
|
|
|
|
|
|
|
Process.Start("explorer", "/select,\"" + fileName + "\""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
)); |
|
|
|
|
|
|
|
output.WriteLine(); |
|
|
|
|
|
|
|
return output; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
delegate (Task<SmartTextOutput> task) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
ShowOutput(task.Result); |
|
|
|
|
|
|
|
} catch (AggregateException aggregateException) { |
|
|
|
|
|
|
|
textEditor.SyntaxHighlighting = null; |
|
|
|
|
|
|
|
Debug.WriteLine("Decompiler crashed: " + aggregateException.ToString()); |
|
|
|
|
|
|
|
// Unpack aggregate exceptions as long as there's only a single exception:
|
|
|
|
|
|
|
|
// (assembly load errors might produce nested aggregate exceptions)
|
|
|
|
|
|
|
|
Exception ex = aggregateException; |
|
|
|
|
|
|
|
while (ex is AggregateException && (ex as AggregateException).InnerExceptions.Count == 1) |
|
|
|
|
|
|
|
ex = ex.InnerException; |
|
|
|
|
|
|
|
SmartTextOutput output = new SmartTextOutput(); |
|
|
|
|
|
|
|
output.WriteLine(ex.ToString()); |
|
|
|
|
|
|
|
ShowOutput(output); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string CleanUpName(string text) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
int pos = text.IndexOf(':'); |
|
|
|
|
|
|
|
if (pos > 0) |
|
|
|
|
|
|
|
text = text.Substring(0, pos); |
|
|
|
|
|
|
|
text = text.Trim(); |
|
|
|
|
|
|
|
foreach (char c in Path.GetInvalidFileNameChars()) |
|
|
|
|
|
|
|
text = text.Replace(c, '-'); |
|
|
|
|
|
|
|
return text; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|