@@ -1416,7 +1416,8 @@ private bool EvaluateInstanceCreationWithNewKeyword(string expr, string restOfEx
1416
1416
|| stack . Peek ( ) is ExpressionOperator ) )
1417
1417
{
1418
1418
string completeName = instanceCreationMatch . Groups [ "name" ] . Value ;
1419
- Type type = GetTypeByFriendlyName ( completeName ) ;
1419
+ string genericTypes = instanceCreationMatch . Groups [ "isgeneric" ] . Value ;
1420
+ Type type = GetTypeByFriendlyName ( completeName , genericTypes ) ;
1420
1421
1421
1422
i += instanceCreationMatch . Length ;
1422
1423
@@ -1839,8 +1840,9 @@ private bool EvaluateVarOrFunc(string expr, string restOfExpression, Stack<objec
1839
1840
! typeName . EndsWith ( "?" ) )
1840
1841
{
1841
1842
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 ) ;
1844
1846
1845
1847
if ( staticType != null )
1846
1848
{
@@ -2658,12 +2660,20 @@ private bool DefaultFunctions(string name, List<string> args, out object result)
2658
2660
return functionExists ;
2659
2661
}
2660
2662
2661
- private Type GetTypeByFriendlyName ( string typeName )
2663
+ private Type GetTypeByFriendlyName ( string typeName , string genericTypes = "" )
2662
2664
{
2663
2665
Type result = null ;
2664
2666
try
2665
2667
{
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 ) ;
2667
2677
2668
2678
if ( result == null )
2669
2679
{
@@ -2683,12 +2693,12 @@ private Type GetTypeByFriendlyName(string typeName)
2683
2693
for ( int a = 0 ; a < Assemblies . Count && result == null ; a ++ )
2684
2694
{
2685
2695
if ( typeName . Contains ( "." ) )
2686
- result = Type . GetType ( $ "{ typeName } ,{ Assemblies [ a ] . FullName } ", false , ! OptionCaseSensitiveEvaluationActive ) ;
2696
+ result = Type . GetType ( $ "{ typeName } { formatedGenericTypes } ,{ Assemblies [ a ] . FullName } ", false , ! OptionCaseSensitiveEvaluationActive ) ;
2687
2697
else
2688
2698
{
2689
2699
for ( int i = 0 ; i < Namespaces . Count && result == null ; i ++ )
2690
2700
{
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 ) ;
2692
2702
}
2693
2703
}
2694
2704
}
0 commit comments