Skip to content

Problems with null and inexistent properties, Exception not handled #105

@TheoVC

Description

@TheoVC

Something is broken handling nulls and inexistent variables

if Name has a valid string, everything is ok, but if Name is null an exception should be triggered but it doesn't
and if instead of Name you call some other property (inexistent) an exception should be triggered too but it doesn't

the problem happens when the expression is compossed with some elements

Eval.Context = new { Person = new Person { Name = null, Value = 1.11m } };
try
{
     var result2 = Eval.Evaluate("\"test one \" + Person.Name.Trim()");
     var result3 = Eval.Evaluate("\"test two\" + Person.AnotherName.Trim()"); 
}
catch(Exception e)
{
    // no exception is triggered
     Console.WriteLine(e.Message);
}


//****************************************************
public class Person
{
    public string Name { get; set; }
    public decimal? Value { get; set; }
}

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions