@@ -53,7 +53,7 @@ public partial class ExpressionEvaluator
5353 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 ) ;
5454 protected static readonly Regex lambdaArgRegex = new Regex ( @"[\p{L}_](?>[\p{L}_0-9]*)" , RegexOptions . Compiled ) ;
5555 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 ) ;
5757
5858 // Depending on OptionInlineNamespacesEvaluationActive. Initialized in constructor
5959 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,
18961896 else
18971897 {
18981898 int argIndex = 0 ;
1899- List < OutOrRefArg > outOrRefArgs = new List < OutOrRefArg > ( ) ;
1899+ List < ArgKeywordsEncaps > argsWithKeywords = new List < ArgKeywordsEncaps > ( ) ;
19001900
19011901 List < object > oArgs = funcArgs . ConvertAll ( arg =>
19021902 {
@@ -1905,18 +1905,24 @@ protected virtual bool EvaluateVarOrFunc(string expression, Stack<object> stack,
19051905
19061906 if ( functionArgKeywordsMatch . Success )
19071907 {
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 ) ;
19101916
19111917 if ( functionArgKeywordsMatch . Groups [ "typeName" ] . Success )
19121918 {
19131919 Type fixedType = ( ( ClassOrEnumType ) Evaluate ( functionArgKeywordsMatch . Groups [ "typeName" ] . Value ) ) . Type ;
19141920
1915- variables [ outOrRefArg . VariableName ] = new StronglyTypedVariable ( ) { Type = fixedType , Value = GetDefaultValueOfType ( fixedType ) } ;
1921+ variables [ argKeywordEncaps . VariableName ] = new StronglyTypedVariable ( ) { Type = fixedType , Value = GetDefaultValueOfType ( fixedType ) } ;
19161922 }
1917- else if ( ! variables . ContainsKey ( outOrRefArg . VariableName ) )
1923+ else if ( ! variables . ContainsKey ( argKeywordEncaps . VariableName ) )
19181924 {
1919- variables [ outOrRefArg . VariableName ] = null ;
1925+ variables [ argKeywordEncaps . VariableName ] = null ;
19201926 }
19211927
19221928 argValue = Evaluate ( functionArgKeywordsMatch . Groups [ "toEval" ] . Value ) ;
@@ -1979,7 +1985,9 @@ protected virtual bool EvaluateVarOrFunc(string expression, Stack<object> stack,
19791985 {
19801986 object [ ] argsArray = oArgs . ToArray ( ) ;
19811987 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 ] ) ) ;
19831991 }
19841992 else if ( objType . GetProperty ( varFuncName , StaticBindingFlag ) is PropertyInfo staticPropertyInfo
19851993 && ( staticPropertyInfo . PropertyType . IsSubclassOf ( typeof ( Delegate ) ) || staticPropertyInfo . PropertyType == typeof ( Delegate ) )
@@ -3695,9 +3703,10 @@ public void AssignValue()
36953703 protected class NullConditionalNullValue
36963704 { }
36973705
3698- protected class OutOrRefArg
3706+ protected class ArgKeywordsEncaps
36993707 {
37003708 public int Index { get ; set ; }
3709+ public string Keyword { get ; set ; }
37013710 public string VariableName { get ; set ; }
37023711 }
37033712
0 commit comments