diff --git a/CilTools.BytecodeAnalysis/Syntax/SyntaxNode.cs b/CilTools.BytecodeAnalysis/Syntax/SyntaxNode.cs index 0e8b6d7..4c0861f 100644 --- a/CilTools.BytecodeAnalysis/Syntax/SyntaxNode.cs +++ b/CilTools.BytecodeAnalysis/Syntax/SyntaxNode.cs @@ -398,10 +398,23 @@ public static IEnumerable GetTypeDefSyntax(Type t) content.Add(new GenericSyntax(Environment.NewLine)); //base type - if ((t.IsClass || t.IsValueType) && t.BaseType!=null) + if (!t.IsInterface && t.BaseType!=null) { content.Add(new KeywordSyntax(String.Empty, "extends", " ", KeywordKind.Other)); - content.Add(new MemberRefSyntax(CilAnalysis.GetTypeFullNameSyntax(t.BaseType).ToArray(), t.BaseType)); + + try + { + content.Add(new MemberRefSyntax(CilAnalysis.GetTypeFullNameSyntax(t.BaseType).ToArray(), t.BaseType)); + } + catch (TypeLoadException ex) + { + //handle error when base type is not available + content.Add(new IdentifierSyntax(String.Empty, "UnknownType", String.Empty, false, null)); + + Diagnostics.OnError( + t, new CilErrorEventArgs(ex, "Failed to read base type for: "+ t.Name) + ); + } content.Add(new GenericSyntax(Environment.NewLine)); } diff --git a/CilView/UI.Controls/CilBrowser.xaml.cs b/CilView/UI.Controls/CilBrowser.xaml.cs index 08a2d90..c636333 100644 --- a/CilView/UI.Controls/CilBrowser.xaml.cs +++ b/CilView/UI.Controls/CilBrowser.xaml.cs @@ -135,9 +135,20 @@ public ObservableCollection NavigateToType(Type t) { if (t == null) return new ObservableCollection(); - CilBrowserPage page = new CilBrowserPage(t, Navigated); - page.Title = "Type: " + t.Name; - frameContent.Navigate(page); + string contenttext = String.Empty; + + try + { + CilBrowserPage page = new CilBrowserPage(t, Navigated); + page.Title = "Type: " + t.Name; + frameContent.Navigate(page); + contenttext = page.ContentText; + } + catch (TypeLoadException ex) + { + ErrorHandler.Current.Error(ex); + frameContent.Navigate(String.Empty); + } //display method list in left pane ObservableCollection methods = AssemblySource.LoadMethods(t); @@ -146,7 +157,7 @@ public ObservableCollection NavigateToType(Type t) this.current_method = null; this.current_type = t; - this.text = page.ContentText; + this.text = contenttext; //make sure content is visible ExpandContentPane();