Browse Source

Fix NullReferenceException in AssemblyTreeNode.get_ToolTip

pull/728/merge
Daniel Grunwald 9 years ago
parent
commit
4c07ba2448
  1. 4
      ICSharpCode.Decompiler/CSharp/Transforms/DeclareVariables.cs
  2. 28
      ICSharpCode.Decompiler/Tests/TestCases/Pretty/Async.cs
  3. 12
      ILSpy/TreeNodes/AssemblyTreeNode.cs

4
ICSharpCode.Decompiler/CSharp/Transforms/DeclareVariables.cs

@ -39,6 +39,10 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -39,6 +39,10 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
/// </summary>
struct InsertionPoint
{
/// <summary>
/// The nesting level of `nextNode` within the AST.
/// Used to speed up FindCommonParent().
/// </summary>
internal int level;
internal AstNode nextNode;

28
ICSharpCode.Decompiler/Tests/TestCases/Pretty/Async.cs

@ -166,5 +166,33 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -166,5 +166,33 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
Console.WriteLine("A", 1, num);
}
}
public async Task AwaitInCatch(Task<int> task1, Task<int> task2)
{
try {
Console.WriteLine("Start try");
await task1;
Console.WriteLine("End try");
} catch (Exception) {
Console.WriteLine("Start catch");
await task2;
Console.WriteLine("End catch");
}
Console.WriteLine("End Method");
}
public async Task AwaitInFinally(Task<int> task1, Task<int> task2)
{
try {
Console.WriteLine("Start try");
await task1;
Console.WriteLine("End try");
} finally {
Console.WriteLine("Start finally");
await task2;
Console.WriteLine("End finally");
}
Console.WriteLine("End Method");
}
}
}

12
ILSpy/TreeNodes/AssemblyTreeNode.cs

@ -97,15 +97,17 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -97,15 +97,17 @@ namespace ICSharpCode.ILSpy.TreeNodes
if (tooltip == null) {
tooltip = new TextBlock();
tooltip.Inlines.Add(new Bold(new Run("Name: ")));
tooltip.Inlines.Add(new Run(assembly.AssemblyDefinition.FullName));
tooltip.Inlines.Add(new LineBreak());
if (assembly.AssemblyDefinition != null) {
tooltip.Inlines.Add(new Bold(new Run("Name: ")));
tooltip.Inlines.Add(new Run(assembly.AssemblyDefinition.FullName));
tooltip.Inlines.Add(new LineBreak());
}
tooltip.Inlines.Add(new Bold(new Run("Location: ")));
tooltip.Inlines.Add(new Run(assembly.FileName));
tooltip.Inlines.Add(new LineBreak());
tooltip.Inlines.Add(new Bold(new Run("Architecture: ")));
tooltip.Inlines.Add(new Run(CSharpLanguage.GetPlatformDisplayName(assembly.AssemblyDefinition.MainModule)));
string runtimeName = CSharpLanguage.GetRuntimeDisplayName(assembly.AssemblyDefinition.MainModule);
tooltip.Inlines.Add(new Run(CSharpLanguage.GetPlatformDisplayName(assembly.ModuleDefinition)));
string runtimeName = CSharpLanguage.GetRuntimeDisplayName(assembly.ModuleDefinition);
if (runtimeName != null) {
tooltip.Inlines.Add(new LineBreak());
tooltip.Inlines.Add(new Bold(new Run("Runtime: ")));

Loading…
Cancel
Save