@@ -1416,7 +1416,8 @@ private bool EvaluateInstanceCreationWithNewKeyword(string expr, string restOfEx
14161416 || stack . Peek ( ) is ExpressionOperator ) )
14171417 {
14181418 string completeName = instanceCreationMatch . Groups [ "name" ] . Value ;
1419- Type type = GetTypeByFriendlyName ( completeName ) ;
1419+ string genericTypes = instanceCreationMatch . Groups [ "isgeneric" ] . Value ;
1420+ Type type = GetTypeByFriendlyName ( completeName , genericTypes ) ;
14201421
14211422 i += instanceCreationMatch . Length ;
14221423
@@ -1839,8 +1840,9 @@ private bool EvaluateVarOrFunc(string expr, string restOfExpression, Stack<objec
18391840 ! typeName . EndsWith ( "?" ) )
18401841 {
18411842 subIndex += namespaceMatch . Length ;
1842- typeName += $ "{ namespaceMatch . Value } { ( ( i + subIndex < expr . Length && expr . Substring ( i + subIndex ) [ 0 ] == '?' ) ? "?" : "" ) } ";
1843- staticType = GetTypeByFriendlyName ( typeName ) ;
1843+ typeName += $ ".{ namespaceMatch . Groups [ "name" ] . Value } { ( ( i + subIndex < expr . Length && expr . Substring ( i + subIndex ) [ 0 ] == '?' ) ? "?" : "" ) } ";
1844+
1845+ staticType = GetTypeByFriendlyName ( typeName , namespaceMatch . Groups [ "isgeneric" ] . Value ) ;
18441846
18451847 if ( staticType != null )
18461848 {
@@ -2658,12 +2660,20 @@ private bool DefaultFunctions(string name, List<string> args, out object result)
26582660 return functionExists ;
26592661 }
26602662
2661- private Type GetTypeByFriendlyName ( string typeName )
2663+ private Type GetTypeByFriendlyName ( string typeName , string genericTypes = "" )
26622664 {
26632665 Type result = null ;
26642666 try
26652667 {
2666- result = Type . GetType ( typeName , false , ! OptionCaseSensitiveEvaluationActive ) ;
2668+ string formatedGenericTypes = string . Empty ;
2669+
2670+ if ( ! genericTypes . Equals ( string . Empty ) )
2671+ {
2672+ Type [ ] types = GetConcreteTypes ( genericTypes ) ;
2673+ formatedGenericTypes = $ "`{ types . Length } [{ string . Join ( ", " , types . Select ( type => type . FullName ) ) } ]";
2674+ }
2675+
2676+ result = Type . GetType ( typeName + formatedGenericTypes , false , ! OptionCaseSensitiveEvaluationActive ) ;
26672677
26682678 if ( result == null )
26692679 {
@@ -2683,12 +2693,12 @@ private Type GetTypeByFriendlyName(string typeName)
26832693 for ( int a = 0 ; a < Assemblies . Count && result == null ; a ++ )
26842694 {
26852695 if ( typeName . Contains ( "." ) )
2686- result = Type . GetType ( $ "{ typeName } ,{ Assemblies [ a ] . FullName } ", false , ! OptionCaseSensitiveEvaluationActive ) ;
2696+ result = Type . GetType ( $ "{ typeName } { formatedGenericTypes } ,{ Assemblies [ a ] . FullName } ", false , ! OptionCaseSensitiveEvaluationActive ) ;
26872697 else
26882698 {
26892699 for ( int i = 0 ; i < Namespaces . Count && result == null ; i ++ )
26902700 {
2691- result = Type . GetType ( $ "{ Namespaces [ i ] } .{ typeName } ,{ Assemblies [ a ] . FullName } ", false , ! OptionCaseSensitiveEvaluationActive ) ;
2701+ result = Type . GetType ( $ "{ Namespaces [ i ] } .{ typeName } { formatedGenericTypes } ,{ Assemblies [ a ] . FullName } ", false , ! OptionCaseSensitiveEvaluationActive ) ;
26922702 }
26932703 }
26942704 }
0 commit comments