@@ -53,7 +53,7 @@ public partial class ExpressionEvaluator
53
53
protected static readonly Regex lambdaExpressionRegex = new Regex ( @"^(?>\s*)(?<args>((?>\s*)[(](?>\s*)([\p{L}_](?>[\p{L}_0-9]*)(?>\s*)([,](?>\s*)[\p{L}_][\p{L}_0-9]*(?>\s*))*)?[)])|[\p{L}_](?>[\p{L}_0-9]*))(?>\s*)=>(?<expression>.*)$" , RegexOptions . Singleline | RegexOptions . Compiled ) ;
54
54
protected static readonly Regex lambdaArgRegex = new Regex ( @"[\p{L}_](?>[\p{L}_0-9]*)" , RegexOptions . Compiled ) ;
55
55
protected static readonly Regex initInNewBeginningRegex = new Regex ( @"^(?>\s*){" , RegexOptions . Compiled ) ;
56
- protected static readonly Regex functionArgKeywordsRegex = new Regex ( @"^\s*(?<keyword>out|ref)\s+((?<typeName>[\p{L}_][\p{L}_0-9\.\[\]<>]*[?]?)\s+(?=[\p{L}_]))?(?<toEval>(?<varName>[\p{L}_](?>[\p{L}_0-9]*))\s*(=.*)?)$" , RegexOptions . Compiled | RegexOptions . IgnoreCase ) ;
56
+ protected static readonly Regex functionArgKeywordsRegex = new Regex ( @"^\s*(?<keyword>out|ref|in )\s+((?<typeName>[\p{L}_][\p{L}_0-9\.\[\]<>]*[?]?)\s+(?=[\p{L}_]))?(?<toEval>(?<varName>[\p{L}_](?>[\p{L}_0-9]*))\s*(=.*)?)$" , RegexOptions . Compiled | RegexOptions . IgnoreCase ) ;
57
57
58
58
// Depending on OptionInlineNamespacesEvaluationActive. Initialized in constructor
59
59
protected string InstanceCreationWithNewKeywordRegexPattern { get { return @"^new(?>\s*)((?<isAnonymous>[{{])|((?<name>[\p{L}_][\p{L}_0-9" + ( OptionInlineNamespacesEvaluationActive ? @"\." : string . Empty ) + @"]*)(?>\s*)(?<isgeneric>[<](?>[^<>]+|(?<gentag>[<])|(?<-gentag>[>]))*(?(gentag)(?!))[>])?(?>\s*)((?<isfunction>[(])|(?<isArray>\[)|(?<isInit>[{{]))?))" ; } }
@@ -1896,7 +1896,7 @@ protected virtual bool EvaluateVarOrFunc(string expression, Stack<object> stack,
1896
1896
else
1897
1897
{
1898
1898
int argIndex = 0 ;
1899
- List < OutOrRefArg > outOrRefArgs = new List < OutOrRefArg > ( ) ;
1899
+ List < ArgKeywordsEncaps > argsWithKeywords = new List < ArgKeywordsEncaps > ( ) ;
1900
1900
1901
1901
List < object > oArgs = funcArgs . ConvertAll ( arg =>
1902
1902
{
@@ -1905,18 +1905,24 @@ protected virtual bool EvaluateVarOrFunc(string expression, Stack<object> stack,
1905
1905
1906
1906
if ( functionArgKeywordsMatch . Success )
1907
1907
{
1908
- OutOrRefArg outOrRefArg = new OutOrRefArg ( ) { Index = argIndex , VariableName = functionArgKeywordsMatch . Groups [ "varName" ] . Value } ;
1909
- outOrRefArgs . Add ( outOrRefArg ) ;
1908
+ ArgKeywordsEncaps argKeywordEncaps = new ArgKeywordsEncaps ( )
1909
+ {
1910
+ Index = argIndex ,
1911
+ Keyword = functionArgKeywordsMatch . Groups [ "keyword" ] . Value ,
1912
+ VariableName = functionArgKeywordsMatch . Groups [ "varName" ] . Value
1913
+ } ;
1914
+
1915
+ argsWithKeywords . Add ( argKeywordEncaps ) ;
1910
1916
1911
1917
if ( functionArgKeywordsMatch . Groups [ "typeName" ] . Success )
1912
1918
{
1913
1919
Type fixedType = ( ( ClassOrEnumType ) Evaluate ( functionArgKeywordsMatch . Groups [ "typeName" ] . Value ) ) . Type ;
1914
1920
1915
- variables [ outOrRefArg . VariableName ] = new StronglyTypedVariable ( ) { Type = fixedType , Value = GetDefaultValueOfType ( fixedType ) } ;
1921
+ variables [ argKeywordEncaps . VariableName ] = new StronglyTypedVariable ( ) { Type = fixedType , Value = GetDefaultValueOfType ( fixedType ) } ;
1916
1922
}
1917
- else if ( ! variables . ContainsKey ( outOrRefArg . VariableName ) )
1923
+ else if ( ! variables . ContainsKey ( argKeywordEncaps . VariableName ) )
1918
1924
{
1919
- variables [ outOrRefArg . VariableName ] = null ;
1925
+ variables [ argKeywordEncaps . VariableName ] = null ;
1920
1926
}
1921
1927
1922
1928
argValue = Evaluate ( functionArgKeywordsMatch . Groups [ "toEval" ] . Value ) ;
@@ -1979,7 +1985,9 @@ protected virtual bool EvaluateVarOrFunc(string expression, Stack<object> stack,
1979
1985
{
1980
1986
object [ ] argsArray = oArgs . ToArray ( ) ;
1981
1987
stack . Push ( methodInfo . Invoke ( isExtention ? null : obj , argsArray ) ) ;
1982
- outOrRefArgs . ForEach ( outOrRefArg => AssignVariable ( outOrRefArg . VariableName , argsArray [ outOrRefArg . Index ] ) ) ;
1988
+ argsWithKeywords
1989
+ . FindAll ( argWithKeyword => argWithKeyword . Keyword . Equals ( "out" , StringComparisonForCasing ) || argWithKeyword . Keyword . Equals ( "ref" , StringComparisonForCasing ) )
1990
+ . ForEach ( outOrRefArg => AssignVariable ( outOrRefArg . VariableName , argsArray [ outOrRefArg . Index ] ) ) ;
1983
1991
}
1984
1992
else if ( objType . GetProperty ( varFuncName , StaticBindingFlag ) is PropertyInfo staticPropertyInfo
1985
1993
&& ( staticPropertyInfo . PropertyType . IsSubclassOf ( typeof ( Delegate ) ) || staticPropertyInfo . PropertyType == typeof ( Delegate ) )
@@ -3695,9 +3703,10 @@ public void AssignValue()
3695
3703
protected class NullConditionalNullValue
3696
3704
{ }
3697
3705
3698
- protected class OutOrRefArg
3706
+ protected class ArgKeywordsEncaps
3699
3707
{
3700
3708
public int Index { get ; set ; }
3709
+ public string Keyword { get ; set ; }
3701
3710
public string VariableName { get ; set ; }
3702
3711
}
3703
3712
0 commit comments