Source/NFX/MiscUtils.cs
/// <summary>
/// Returns the the name of the type with expanded generic argument names.
/// This helper is useful for printing class names to logs/messages.
///   List'1[System.Object]  ->  List&lt;Object&gt;
/// </summary>
Returns the the name of the type with expanded generic argument names.
This helper is useful for printing class names to logs/messages.
Returns the the name of the type with expanded generic argument names . This helper is useful for printing class names to logs / messages .
public static string DisplayNameWithExpandedGenericArgs(this Type type)
    {
        var gargs = type.GetGenericArguments();
        if (gargs.Length==0)
        {
         return type.Name;
        }
        var sb = new StringBuilder();
        for(int i=0; i<gargs.Length; i++)
        {
            if (i>0) sb.Append(", ");
            sb.Append( gargs[i].DisplayNameWithExpandedGenericArgs() );
        }
        var nm = type.Name;
        var idx = nm.IndexOf('`');
        if(idx>=0)
            nm = nm.Substring(0, idx);
        return  "{0}<{1}>".Args(nm, sb.ToString());
    }
public static string DisplayNameWithExpandedGenericArgs ( this Type type ) { var gargs = type . GetGenericArguments ( ) ; if ( gargs . Length == 0 ) { return type . Name ; } var sb = new StringBuilder ( ) ; for ( int i = 0 ; i < gargs . Length ; i ++ ) { if ( i > 0 ) sb . Append ( " " ) ; sb . Append ( gargs [ i ] . DisplayNameWithExpandedGenericArgs ( ) ) ; } var nm = type . Name ; var idx = nm . IndexOf ( ' ' ) ; if ( idx >= 0 ) nm = nm . Substring ( 0 , idx ) ; return " " . Args ( nm , sb . ToString ( ) ) ; }
Returns the the name of the type with expanded generic argument names.
Returns the the name of the type with expanded generic argument names .
Type
this