1- using System . Text ;
1+ using OpenShock . Common . Models ;
22using System . Text . Json . Serialization . Metadata ;
3- using OpenShock . Common . Models ;
43
54namespace OpenShock . Common . OpenApi ;
65
@@ -28,10 +27,17 @@ private static bool IsSystemType(Type type)
2827
2928 private static string ? GetFriendlyGenericTypeName ( Type type )
3029 {
31- StringBuilder sb = new ( ) ;
32-
33- while ( type . IsGenericType )
30+ string suffix = "" ;
31+
32+ while ( type . IsGenericType || type . IsArray )
3433 {
34+ if ( type . IsArray )
35+ {
36+ suffix = "Array" + suffix ;
37+ type = type . GetElementType ( ) ! ;
38+ continue ;
39+ }
40+
3541 var genericTypeDefinition = type . GetGenericTypeDefinition ( ) ;
3642
3743 if ( genericTypeDefinition == typeof ( LegacyDataResponse < > ) || genericTypeDefinition == typeof ( Nullable < > ) )
@@ -43,34 +49,31 @@ private static bool IsSystemType(Type type)
4349
4450 if ( IsCollection ( genericTypeDefinition ) )
4551 {
46- sb . Append ( "CollectionOf" ) ;
52+ suffix = "Array" + suffix ;
4753 type = type . GetGenericArguments ( ) [ 0 ] ;
4854 continue ;
4955 }
5056
5157 if ( genericTypeDefinition == typeof ( Paginated < > ) )
5258 {
53- sb . Append ( "Paginated" ) ;
59+ suffix = "Page" + suffix ;
5460 type = type . GetGenericArguments ( ) [ 0 ] ;
5561 continue ;
5662 }
5763
5864 throw new NotImplementedException ( ) ;
5965 }
6066
61- sb . Append ( type . Name ) ;
62-
63- return sb . ToString ( ) ;
67+ return type . Name + suffix ;
6468 }
6569
6670 public static string ? GetFriendlyName ( Type type )
6771 {
6872 if ( IsSystemType ( type ) ) return null ;
6973
70- if ( type . IsArray ) return "CollectionOf" + ( GetFriendlyName ( type . GetElementType ( ) ! ) ?? type . Name ) ;
71-
72- if ( type . IsGenericType ) return GetFriendlyGenericTypeName ( type ) ;
7374
75+ if ( type . IsGenericType || type . IsArray ) return GetFriendlyGenericTypeName ( type ) ;
76+
7477 return type . Name ;
7578 }
7679 public static string ? GetFriendlyName ( JsonTypeInfo jsonTypeInfo )
0 commit comments