From 9d985f0f0a8fad3374262a478a7f86943d94467e Mon Sep 17 00:00:00 2001 From: Nils Andresen Date: Wed, 17 Aug 2022 14:24:53 +0200 Subject: [PATCH] (#922) fixed ArgumentNullException on .NET Framework It seems, when Spectre.Console is compiled for netstandard2.0, StackTrace.GetFrames() returns null instead of an empty array. --- src/Spectre.Console/Widgets/Exceptions/ExceptionFormatter.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Spectre.Console/Widgets/Exceptions/ExceptionFormatter.cs b/src/Spectre.Console/Widgets/Exceptions/ExceptionFormatter.cs index 1d749a4..97acddf 100644 --- a/src/Spectre.Console/Widgets/Exceptions/ExceptionFormatter.cs +++ b/src/Spectre.Console/Widgets/Exceptions/ExceptionFormatter.cs @@ -221,9 +221,9 @@ internal static class ExceptionFormatter return true; } - private static IEnumerable FilterStackFrames(this IEnumerable frames) + private static IEnumerable FilterStackFrames(this IEnumerable? frames) { - var allFrames = frames.ToArray(); + var allFrames = frames?.ToArray() ?? Array.Empty(); var numberOfFrames = allFrames.Length; for (var i = 0; i < numberOfFrames; i++)