Problems with null and inexistent properties, Exception not handled
See original GitHub issueSomething 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:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The new version 1.4.30.0 Correct this issue thanks again.
Thanks for opening theses issues @TheoVC I will look about that asap.