This commit is contained in:
Tyrrrz
2023-06-26 22:57:57 +03:00
parent 8c1cff3bb7
commit 4aef8ce8fb
2 changed files with 9 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ using System.IO;
using CliFx.Exceptions; using CliFx.Exceptions;
using CliFx.Infrastructure; using CliFx.Infrastructure;
using CliFx.Utils; using CliFx.Utils;
using CliFx.Utils.Extensions;
namespace CliFx.Formatting; namespace CliFx.Formatting;
@@ -26,10 +27,8 @@ internal class ExceptionConsoleFormatter : ConsoleFormatter
Write('('); Write('(');
for (var i = 0; i < stackFrame.Parameters.Count; i++) foreach (var (parameter, i) in stackFrame.Parameters.WithIndex())
{ {
var parameter = stackFrame.Parameters[i];
// Separator // Separator
if (i > 0) if (i > 0)
{ {

View File

@@ -7,6 +7,13 @@ namespace CliFx.Utils.Extensions;
internal static class CollectionExtensions internal static class CollectionExtensions
{ {
public static IEnumerable<(T value, int index)> WithIndex<T>(this IEnumerable<T> source)
{
var i = 0;
foreach (var o in source)
yield return (o, i++);
}
public static IEnumerable<T> WhereNotNull<T>(this IEnumerable<T?> source) public static IEnumerable<T> WhereNotNull<T>(this IEnumerable<T?> source)
where T : class where T : class
{ {