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.

Boolean operators not working for dynamic objects

See original GitHub issue

Hello,

I’ve encountered this issue when trying to use boolean operators with dynamic properties:

dynamic dyn = new ExpandoObject();
dyn.val1 = 100;
dyn.val2 = 200;

var interpreter = new Interpreter();
interpreter.SetVariable("dyn", dyn);

interpreter.Eval("dyn.val1 == 100"); //returns true, as expected
interpreter.Eval("dyn.val1 == 100 && dyn.val2 == 200"); // throws exception: "Invalid argument value\r\nParameter name: operation

Please advise if this is indeed a bug or something is not properly configured.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
rotsincommented, Oct 6, 2021
1reaction
rotsincommented, Oct 5, 2021

In

private Expression ParseConditionalAnd()
{
	var left = ParseLogicalOr();
	while (_token.id == TokenId.DoubleAmphersand)
	{
		NextToken();
		var right = ParseLogicalOr();
		CheckAndPromoteOperands(typeof(ParseSignatures.ILogicalSignatures), ref left, ref right);
		left = GenerateBinary(ExpressionType.AndAlso, left, right);
	}
	return left;
}

which is called when there are dynamic expressions, expression type AndAlso is passed, problem is that Microsoft.CSharp.RuntimeBinder.Binder.BinaryOperation does not seem to support this type of operation. Changing it to And seems to resolve the issue, also added a small test to check that Andi’s scenario works and it does, and all other tests run successfully.

Cound not push my branch to the repo (I may need rights), but the fix should be reasonably simple that there is no need to get my on the PR pipeline.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Filter a list of objects with dynamic boolean operators
Up to now it does it job: based on a static List of objects, it returns what can be filtered from the list...
Read more >
Working with untyped and dynamic objects - Power Apps
When dealing with actions in Power Apps, it's possible to encounter untyped return values or input values for some actions.
Read more >
How to dynamically assign properties to an object in ...
Understanding the problem with dynamically assigning properties to objects. Generally speaking, TypeScript determines the type of a variable ...
Read more >
Boolean operators allow conditional search results
Note: Boolean operators are case-sensitive. For example, OR is a Boolean operator while Or and or are search terms that may be stop...
Read more >
Edit objects using Boolean operations
Combine objects using Boolean operations. You can combine simple shapes to create compound shapes and objects. Select the shapes that you ...
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