CsCheck/Utils.cs
/// <summary>Default print implementation. Handles most collections and tuple like types.</summary>
Default print implementation. Handles most collections and tuple like types.
Default print implementation . Handles most collections and tuple like types .
public static string Print<T>(T t) => t switch
        {
            null => "null",
            string s => s,
            Array { Rank: 2 } a => PrintArray2D(a),
            IList { Count: <= 12 } l => "[" + string.Join(", ", l.Cast<object>().Select(Print)) + "]",
            IList l => $"L={l.Count} [{Print(l[0])}, {Print(l[1])}, {Print(l[2])} ... {Print(l[l.Count - 2])}, {Print(l[l.Count - 1])}]",
            IEnumerable<object> e when e.Take(12).Count() <= 12 => "{" + string.Join(", ", e.Select(Print)) + "}",
            IEnumerable<object> e when e.Take(999).Count() <= 999 => "L=" + e.Count() + " {" + string.Join(", ", e.Select(Print)) + "}",
            IEnumerable<object> e => "L>999 {" + string.Join(", ", e.Take(6).Select(Print)) + " ... }",
            IEnumerable e => Print(e.Cast<object>()),
            T pt when IsPropertyType(pt) => PrintProperties(pt),
            T ft when IsFieldType(ft) => PrintFields(ft),
            _ => t.ToString(),
        };
public static string Print < T > ( T t ) => t switch { null => " " , string s => s , Array { Rank : 2 } a => PrintArray2D ( a ) , IList { Count : <= 12 } l => " " + string . Join ( " " , l . Cast < object > ( ) . Select ( Print ) ) + " " , IList l => $" L= { l . Count }  [ { Print ( l [ 0 ] ) } ,  { Print ( l [ 1 ] ) } ,  { Print ( l [ 2 ] ) }  ...  { Print ( l [ l . Count - 2 ] ) } ,  { Print ( l [ l . Count - 1 ] ) } ] " , IEnumerable < object > e when e . Take ( 12 ) . Count ( ) <= 12 => " " + string . Join ( " " , e . Select ( Print ) ) + " " , IEnumerable < object > e when e . Take ( 999 ) . Count ( ) <= 999 => " " + e . Count ( ) + " " + string . Join ( " " , e . Select ( Print ) ) + " " , IEnumerable < object > e => " " + string . Join ( " " , e . Take ( 6 ) . Select ( Print ) ) + " " , IEnumerable e => Print ( e . Cast < object > ( ) ) , T pt when IsPropertyType ( pt ) => PrintProperties ( pt ) , T ft when IsFieldType ( ft ) => PrintFields ( ft ) , _ => t . ToString ( ) , } ;
Default print implementation.
Default print implementation .
t
T