Skip to content

ParseException after update from v.1.0.8.18 to 1.0.9.0 or any newer (till 1.3.7) #757

@OlegNadymov

Description

@OlegNadymov

1. Description

I have string expressions with inner string statements, e.g.:

StaticHelper.First(StaticHelper.SubSelect("Identity", "AdditionalProcessState", "Code = ""New"" ", ""))

The class:

public static class StaticHelper
{
    public static Guid? GetGuid(string name)
    {
        return Guid.NewGuid();
    }
    public static SqlExpression SubSelect(string columnName, string objectClassName, string filter, string order)
    {
        return new SqlExpression();
    }

    public static object First(SqlExpression sqlExpression)
    {
        return Guid.NewGuid().ToString();
    }
}

public class SqlExpression
{
}

This class is already used in TestCustomTypeProvider of your test class DynamicExpressionParserTests.

I try to parse the expression this way:

var exp = @"StaticHelper.First(StaticHelper.SubSelect(""Identity"", ""AdditionalProcessState"", ""Code = """"New"""" "", ""Order""))";
var lambda = DynamicExpressionParser.ParseLambda(config, typeof(User), null, exp);

2. Exception

Message: 

    System.Linq.Dynamic.Core.Exceptions.ParseException : ')' or ',' expected

Stack Trace: 

    TextParser.ValidateToken(TokenId tokenId, String errorMessage) line 451
    ExpressionParser.ParseArgumentList() line 2167
    ExpressionParser.ParseMemberAccess(Type type, Expression expression) line 1794
    ExpressionParser.ParseTypeAccess(Type type, Boolean getNext) line 1701
    ExpressionParser.ParseIdentifier() line 976
    ExpressionParser.ParsePrimaryStart() line 843
    ExpressionParser.ParsePrimary() line 811
    ExpressionParser.ParseUnary() line 806
    ExpressionParser.ParseArithmetic() line 751
    ExpressionParser.ParseAdditive() line 718
    <25 more frames...>
    ExpressionParser.ParseOrOperator() line 290
    ExpressionParser.ParseLambdaOperator() line 270
    ExpressionParser.ParseNullCoalescingOperator() line 257
    ExpressionParser.ParseConditionalOperator() line 241
    ExpressionParser.Parse(Type resultType, Boolean createParameterCtor) line 156
    DynamicExpressionParser.ParseLambda(Type delegateType, ParsingConfig parsingConfig, Boolean createParameterCtor, ParameterExpression[] parameters, Type resultType, String expression, Object[] values) line 121
    DynamicExpressionParser.ParseLambda(ParsingConfig parsingConfig, Boolean createParameterCtor, ParameterExpression[] parameters, Type resultType, String expression, Object[] values) line 98
    DynamicExpressionParser.ParseLambda(ParsingConfig parsingConfig, Boolean createParameterCtor, Type itType, Type resultType, String expression, Object[] values) line 357
    DynamicExpressionParser.ParseLambda(ParsingConfig parsingConfig, Type itType, Type resultType, String expression, Object[] values) line 319

3. Fiddle or Project

I have done changes in DynamicExpressionParserTests adding SqlExpression, StaticHelper.SubSelect, StaticHelper.First locally only to check the first version where I can't parse my expressions. I have not done any PR.

4. Any further technical details

It is working on v.1.0.8.18.
But it is not working on versions since 1.0.9.0 till the latest 1.3.7.

I want to upgrade to the latest version because of:

Warning As Error: Package 'System.Linq.Dynamic.Core' 1.0.8.18 has a known critical severity vulnerability, https://github.com/advisories/GHSA-w65q-jcmv-28gj

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions