11/******************************************************************************************************
22 Title : ExpressionEvaluator (https://github.com/codingseb/ExpressionEvaluator)
3- Version : 1.4.27 .0
3+ Version : 1.4.28 .0
44 (if last digit (the forth) is not a zero, the version is an intermediate version and can be unstable)
55
66 Author : Coding Seb
@@ -29,8 +29,6 @@ public partial class ExpressionEvaluator
2929 {
3030 #region Regex declarations
3131
32- protected const string primaryTypesRegexPattern = @"(?<=^|[^\p{L}_])(?<primaryType>object|string|bool[?]?|byte[?]?|char[?]?|decimal[?]?|double[?]?|short[?]?|int[?]?|long[?]?|sbyte[?]?|float[?]?|ushort[?]?|uint[?]?|ulong[?]?|void)(?=[^a-zA-Z_]|$)" ;
33-
3432 protected static readonly Regex varOrFunctionRegEx = new Regex ( @"^((?<sign>[+-])|(?<prefixOperator>[+][+]|--)|(?<varKeyword>var)\s+|(?<dynamicKeyword>dynamic)\s+|((?<nullConditional>[?])?(?<inObject>\.))?)(?<name>[\p{L}_](?>[\p{L}_0-9]*))(?>\s*)((?<assignationOperator>(?<assignmentPrefix>[+\-*/%&|^]|<<|>>|\?\?)?=(?![=>]))|(?<postfixOperator>([+][+]|--)(?![\p{L}_0-9]))|((?<isgeneric>[<](?>([\p{L}_](?>[\p{L}_0-9]*)|(?>\s+)|[,\.])+|(?<gentag>[<])|(?<-gentag>[>]))*(?(gentag)(?!))[>])?(?<isfunction>[(])?))" , RegexOptions . IgnoreCase | RegexOptions . Compiled ) ;
3533
3634 protected const string numberRegexOrigPattern = @"^(?<sign>[+-])?([0-9][0-9_{1}]*[0-9]|\d)(?<hasdecimal>{0}?([0-9][0-9_]*[0-9]|\d)(e[+-]?([0-9][0-9_]*[0-9]|\d))?)?(?<type>ul|[fdulm])?" ;
@@ -40,6 +38,7 @@ public partial class ExpressionEvaluator
4038 protected static readonly Regex stringBeginningRegex = new Regex ( "^(?<interpolated>[$])?(?<escaped>[@])?[\" ]" , RegexOptions . Compiled ) ;
4139 protected static readonly Regex internalCharRegex = new Regex ( @"^['](\\[\\'0abfnrtv]|[^'])[']" , RegexOptions . Compiled ) ;
4240 protected static readonly Regex indexingBeginningRegex = new Regex ( @"^[?]?\[" , RegexOptions . Compiled ) ;
41+ protected static readonly Regex arrayTypeDetectionRegex = new Regex ( @"^(\s*(\[(?>(?>\s+)|[,])*)\])+" , RegexOptions . Compiled ) ;
4342 protected static readonly Regex assignationOrPostFixOperatorRegex = new Regex ( @"^(?>\s*)((?<assignmentPrefix>[+\-*/%&|^]|<<|>>|\?\?)?=(?![=>])|(?<postfixOperator>([+][+]|--)(?![\p{L}_0-9])))" ) ;
4443 protected static readonly Regex genericsDecodeRegex = new Regex ( "(?<name>[^,<>]+)(?<isgeneric>[<](?>[^<>]+|(?<gentag>[<])|(?<-gentag>[>]))*(?(gentag)(?!))[>])?" , RegexOptions . Compiled ) ;
4544 protected static readonly Regex genericsEndOnlyOneTrim = new Regex ( @"(?>\s*)[>](?>\s*)$" , RegexOptions . Compiled ) ;
@@ -2583,6 +2582,18 @@ protected virtual Type EvaluateType(string expression,ref int i, string currentN
25832582 }
25842583 }
25852584
2585+ Match arrayTypeMatch ;
2586+
2587+ if ( i < expression . Length && ( arrayTypeMatch = arrayTypeDetectionRegex . Match ( expression . Substring ( i ) ) ) . Success )
2588+ {
2589+ Type arrayType = GetTypeByFriendlyName ( staticType + arrayTypeMatch . Value ) ;
2590+ if ( arrayType != null )
2591+ {
2592+ i += arrayTypeMatch . Length ;
2593+ staticType = arrayType ;
2594+ }
2595+ }
2596+
25862597 return staticType ;
25872598 }
25882599
@@ -3929,6 +3940,11 @@ protected virtual Type GetTypeByFriendlyName(string typeName, string genericType
39293940 typeName = typeName . Replace ( " " , "" ) . Replace ( "\t " , "" ) . Replace ( "\r " , "" ) . Replace ( "\n " , "" ) ;
39303941 genericTypes = genericTypes . Replace ( " " , "" ) . Replace ( "\t " , "" ) . Replace ( "\r " , "" ) . Replace ( "\n " , "" ) ;
39313942
3943+ if ( primaryTypesDict . ContainsKey ( OptionCaseSensitiveEvaluationActive ? typeName : typeName . ToLower ( ) ) )
3944+ {
3945+ result = primaryTypesDict [ OptionCaseSensitiveEvaluationActive ? typeName : typeName . ToLower ( ) ] ;
3946+ }
3947+
39323948 if ( CacheTypesResolutions && ( TypesResolutionCaching ? . ContainsKey ( typeName + genericTypes ) ?? false ) )
39333949 {
39343950 result = TypesResolutionCaching [ typeName + genericTypes ] ;
@@ -3946,14 +3962,6 @@ protected virtual Type GetTypeByFriendlyName(string typeName, string genericType
39463962 result = Type . GetType ( typeName + formatedGenericTypes , false , ! OptionCaseSensitiveEvaluationActive ) ;
39473963 }
39483964
3949- if ( result == null )
3950- {
3951- typeName = Regex . Replace ( typeName , primaryTypesRegexPattern ,
3952- ( Match match ) => primaryTypesDict [ OptionCaseSensitiveEvaluationActive ? match . Value : match . Value . ToLower ( ) ] . ToString ( ) , optionCaseSensitiveEvaluationActive ? RegexOptions . None : RegexOptions . IgnoreCase ) ;
3953-
3954- result = Type . GetType ( typeName , false , ! OptionCaseSensitiveEvaluationActive ) ;
3955- }
3956-
39573965 if ( result == null )
39583966 {
39593967 result = Types . ToList ( ) . Find ( type => type . Name . Equals ( typeName , StringComparisonForCasing ) || type . FullName . StartsWith ( typeName + "," ) ) ;
0 commit comments