Browse Source

Fix possible null de-reference

pull/3274/head
tom-englert 2 years ago committed by tom-englert
parent
commit
2d8ad69d3b
  1. 13
      ILSpy/ExtensionMethods.cs

13
ILSpy/ExtensionMethods.cs

@ -29,6 +29,8 @@ using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.TypeSystem; using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpyX; using ICSharpCode.ILSpyX;
using TomsToolbox.Essentials;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy
{ {
/// <summary> /// <summary>
@ -124,9 +126,9 @@ namespace ICSharpCode.ILSpy
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++) for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
{ {
DependencyObject child = VisualTreeHelper.GetChild(depObj, i); DependencyObject child = VisualTreeHelper.GetChild(depObj, i);
if (child != null && child is T) if (child is T dependencyObject)
{ {
return (T)child; return dependencyObject;
} }
T? childItem = FindVisualChild<T>(child); T? childItem = FindVisualChild<T>(child);
@ -177,18 +179,19 @@ namespace ICSharpCode.ILSpy
else else
output.AppendLine("-------------------------------------------------"); output.AppendLine("-------------------------------------------------");
output.AppendLine("Error(s) loading plugin: " + item.PluginName); output.AppendLine("Error(s) loading plugin: " + item.PluginName);
if (item.Exception is System.Reflection.ReflectionTypeLoadException) if (item.Exception is System.Reflection.ReflectionTypeLoadException exception)
{ {
var e = (System.Reflection.ReflectionTypeLoadException)item.Exception; foreach (var ex in exception.LoaderExceptions.ExceptNullItems())
foreach (var ex in e.LoaderExceptions)
{ {
output.AppendLine(ex.ToString()); output.AppendLine(ex.ToString());
output.AppendLine(); output.AppendLine();
} }
} }
else else
{
output.AppendLine(item.Exception.ToString()); output.AppendLine(item.Exception.ToString());
} }
}
return true; return true;
} }

Loading…
Cancel
Save