@@ -4,7 +4,9 @@ namespace AgileObjects.ReadableExpressions.Translators
44 using System . Collections . Generic ;
55 using System . Globalization ;
66 using System . Linq . Expressions ;
7+ #if NET_STANDARD
78 using System . Reflection ;
9+ #endif
810 using System . Text . RegularExpressions ;
911 using Extensions ;
1012 using NetStandardPolyfills ;
@@ -283,26 +285,32 @@ private static IEnumerable<string> ParseArgumentNames(params string[] arguments)
283285 var genericTypeArgumentsClosesNeeded = 1 ;
284286 var genericTypeArgumentsString = argument ;
285287
286- while ( i < arguments . Length - 1 )
288+ if ( i == arguments . Length - 1 )
287289 {
288- if ( argument . IndexOf ( '`' ) != - 1 )
289- {
290- ++ genericTypeArgumentsClosesNeeded ;
291- }
292-
293- argument = arguments [ ++ i ] ;
294- genericTypeArgumentsString += "," + argument ;
295-
296- if ( argument . EndsWith ( ']' ) && ( argument [ argument . Length - 2 ] != '[' ) )
297- {
298- -- genericTypeArgumentsClosesNeeded ;
299- }
300-
301- if ( genericTypeArgumentsClosesNeeded == 0 )
290+ genericTypeArgumentsString = RemoveFinalGenericArgumentsClose ( genericTypeArgumentsString ) ;
291+ }
292+ else
293+ {
294+ while ( i < arguments . Length - 1 )
302295 {
303- genericTypeArgumentsString =
304- genericTypeArgumentsString . Substring ( 0 , genericTypeArgumentsString . Length - 1 ) ;
305- break ;
296+ if ( argument . IndexOf ( '`' ) != - 1 )
297+ {
298+ ++ genericTypeArgumentsClosesNeeded ;
299+ }
300+
301+ argument = arguments [ ++ i ] ;
302+ genericTypeArgumentsString += "," + argument ;
303+
304+ if ( argument . EndsWith ( ']' ) && ( argument [ argument . Length - 2 ] != '[' ) )
305+ {
306+ -- genericTypeArgumentsClosesNeeded ;
307+ }
308+
309+ if ( genericTypeArgumentsClosesNeeded == 0 )
310+ {
311+ genericTypeArgumentsString = RemoveFinalGenericArgumentsClose ( genericTypeArgumentsString ) ;
312+ break ;
313+ }
306314 }
307315 }
308316
@@ -312,6 +320,17 @@ private static IEnumerable<string> ParseArgumentNames(params string[] arguments)
312320 }
313321 }
314322
323+ private static string GetTypeName ( string typeFullName )
324+ {
325+ if ( typeFullName . EndsWith ( "[]" , StringComparison . Ordinal ) )
326+ {
327+ return GetTypeName ( typeFullName . Substring ( 0 , typeFullName . Length - 2 ) ) + "[]" ;
328+ }
329+
330+ return typeFullName . GetSubstitutionOrNull ( ) ??
331+ typeFullName . Substring ( typeFullName . LastIndexOf ( '.' ) + 1 ) ;
332+ }
333+
315334 private static readonly int _nullableTypeArgumentStart = "System.Nullable`1[" . Length ;
316335
317336 private static string GetNullableTypeName ( string typeFullName )
@@ -322,15 +341,9 @@ private static string GetNullableTypeName(string typeFullName)
322341 return GetTypeName ( nullableTypeName ) + "?" ;
323342 }
324343
325- private static string GetTypeName ( string typeFullName )
344+ private static string RemoveFinalGenericArgumentsClose ( string genericTypeArgumentsString )
326345 {
327- if ( typeFullName . EndsWith ( "[]" , StringComparison . Ordinal ) )
328- {
329- return GetTypeName ( typeFullName . Substring ( 0 , typeFullName . Length - 2 ) ) + "[]" ;
330- }
331-
332- return typeFullName . GetSubstitutionOrNull ( ) ??
333- typeFullName . Substring ( typeFullName . LastIndexOf ( '.' ) + 1 ) ;
346+ return genericTypeArgumentsString . Substring ( 0 , genericTypeArgumentsString . Length - 1 ) ;
334347 }
335348
336349 private static string GetGenericTypeName ( string typeName , IEnumerable < string > arguments )
0 commit comments