Browse Source

Fix possible null de-reference

pull/3274/head
tom-englert 10 months 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; @@ -29,6 +29,8 @@ using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpyX;
using TomsToolbox.Essentials;
namespace ICSharpCode.ILSpy
{
/// <summary>
@ -124,9 +126,9 @@ namespace ICSharpCode.ILSpy @@ -124,9 +126,9 @@ namespace ICSharpCode.ILSpy
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(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);
@ -177,17 +179,18 @@ namespace ICSharpCode.ILSpy @@ -177,17 +179,18 @@ namespace ICSharpCode.ILSpy
else
output.AppendLine("-------------------------------------------------");
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 e.LoaderExceptions)
foreach (var ex in exception.LoaderExceptions.ExceptNullItems())
{
output.AppendLine(ex.ToString());
output.AppendLine();
}
}
else
{
output.AppendLine(item.Exception.ToString());
}
}
return true;

Loading…
Cancel
Save