Skip to content

Allow as and is to use instances of System.Type #459

@zspitz

Description

@zspitz

The following:

class Foo { }
class Bar : Foo { }

var prm = Parameter(typeof(Foo));
var selector = $"as(@0)";
var parser = new ExpressionParser(new[] { prm }, selector, new object[] { typeof(Bar) }, ParsingConfig.Default);
var expr = parser.Parse(null);

fails with:

System.Linq.Dynamic.Core.Exceptions.ParseException: 'The 'as' function requires one argument which is not null.'

The same happens with is:

var selector = $"is(@0)";

It might be helpful to clarify the error by explaining that the one argument must be the FullName of the type.

But I suggest it be possible to accept a System.Type, and FullName should be read from the type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions