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.

ConditionalAnd with variables

See original GitHub issue

First, I want to say it’s a fascinating and high-quality module, congratulations and thank you for putting it up here!

I have a problem evaluating expressions with variables when using ConditionalAnd and null values:

Dictionary<string, object> dictValues = new Dictionary<string, object>();
string nullString = null;
dictValues[ "TestNullString" ] = nullString;

//pass dictValues as expEval.Variables into expression evaluation instance and then...
string expression = "!string.IsNullOrEmpty(TestNullString) && TestNullString.StartsWith(\"ABC\")";
var result = expEval.Evaluate(expression);

This throws a NullReferenceException with the second half, where “plain C#” would skip evaluating this part. The issue seems related to some that were discussed here recently, especially #51 and #53, but the fixes don’t address it. The exception details are:

 at ExpressionEvaluator.DetermineInstanceOrStatic(Type& objType, Object& obj, ValueTypeNestingTrace& valueTypeNestingTrace) in EvaluatorTest\ExpressionEvaluator.cs

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Karbotcommented, Jul 10, 2020

Hello @codingseb, I am a coworker of @HelgeL and we had another look at the problem. We figured out a way to realize left associativity and put together a solution that’s working for our cases and passes all of your test cases as well. I will add a few comments to it and than suggest a pull request for our fork. Maybe it will help you or others.

0reactions
codingsebcommented, Jul 15, 2020

Just published version 1.4.13.0 with additionals corrections for this. And some Refactoring and simplification.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Conditionals, loops, variables and functions | Codelearn.com
The first one is the simplest, the first conditional we have seen: if the condition happens, we do the action that is associated...
Read more >
How to make a conditional variable based on multiple ...
Trying to make a catch all variable - so if a respondent answers "yes" to at least one of the 9 yes/no variables,...
Read more >
Conditional Statements with Variables - YouTube
In this video, we discuss how open primitive statements affect conditional statements that they are apart of.
Read more >
Variables and Conditional Statements
This month we will take a look and explain variables and conditional statements. ... This program is quite simple and has one variable...
Read more >
How to use “&” and “|” to combine conditional statements in R
In the example below, we use the & operator to combine conditional statements that will test if a variable value is greater or...
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