question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problems with null and inexistent properties, Exception not handled

See original GitHub issue

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; }
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
codingsebcommented, Jun 29, 2021

The new version 1.4.30.0 Correct this issue thanks again.

1reaction
codingsebcommented, Jun 16, 2021

Thanks for opening theses issues @TheoVC I will look about that asap.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - What is a NullReferenceException, and how do I fix it?
This means the reference is null , and you cannot access members (such as methods) through a null reference. The simplest case: string...
Read more >
TypeError: null or undefined has no properties
The Null or Undefined Has No Properties error occurs specifically when attempting to call a property of the null object or undefined type....
Read more >
How to Avoid Returning Null from a Method
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object. at ConsoleApplication1.Program.
Read more >
The worst mistake of computer science
The short answer: NULL is a value that is not a value. And that's a problem. It has festered in the most popular...
Read more >
Treat value={null} as empty string · Issue #11417
One can do a workaround, i.e. <input value={foo || ''} onChange={this.handleChange} /> , but this is an error-prone approach and quite awkward.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found