Skip to content

Commit

Permalink
Fix not equal operator
Browse files Browse the repository at this point in the history
  • Loading branch information
dudikeleti committed Mar 8, 2024
1 parent 5a75734 commit 3606c0a
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal partial class ProbeExpressionParser<T>
{
private Expression NotEqual(JsonTextReader reader, List<ParameterExpression> parameters, ParameterExpression itParameter)
{
return BinaryOperation(reader, parameters, itParameter, "==");
return BinaryOperation(reader, parameters, itParameter, "!=");
}

private Expression Equal(JsonTextReader reader, List<ParameterExpression> parameters, ParameterExpression itParameter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private Expression ParseTree(
}

case "!=":
case "neq":
case "ne":
{
return NotEqual(reader, parameters, itParameter);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
Condition:
Json:
{
"or": [
{
"eq": [
{
"getmember": [
{
"ref": "Nested"
},
"NestedString"
]
},
"dd"
]
},
{
"ne": [
{
"getmember": [
{
"ref": "Nested"
},
"NestedString"
]
},
null
]
}
]
}

Expression: (
scopeMember,
scopeMember,
scopeMember,
exception,
scopeMemberArray) =>
{
var this = (DebuggerExpressionLanguageTests.TestStruct)scopeMember.Value;
var @return = (string)scopeMember.Value;
var @duration = (TimeSpan)scopeMember.Value;
var @exception = exception;
var IntLocal = (int)scopeMemberArray[0].Value;
var DoubleLocal = (double)scopeMemberArray[1].Value;
var StringLocal = (string)scopeMemberArray[2].Value;
var CollectionLocal = (List<string>)scopeMemberArray[3].Value;
var DictionaryLocal = (Dictionary<string, string>)scopeMemberArray[4].Value;
var NestedObjectLocal = (DebuggerExpressionLanguageTests.TestStruct.NestedObject)scopeMemberArray[5].Value;
var NullLocal = (DebuggerExpressionLanguageTests.TestStruct.NestedObject)scopeMemberArray[6].Value;
var IntArg = (int)scopeMemberArray[7].Value;
var DoubleArg = (double)scopeMemberArray[8].Value;
var StringArg = (string)scopeMemberArray[9].Value;
var CollectionArg = (List<string>)scopeMemberArray[10].Value;
var NestedObjectArg = (DebuggerExpressionLanguageTests.TestStruct.NestedObject)scopeMemberArray[11].Value;
var $dd_el_result = (this.Nested.NestedString == "dd") || (this.Nested.NestedString != null);

return $dd_el_result;
}
Result: True
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"dsl": "Nested.NestedString == \"d\" or Nested.NestedString != null",
"or": [
{
"eq": [
{
"getmember": [
{
"ref": "Nested"
},
"NestedString"
]
},
"dd"
]
},
{
"ne": [
{
"getmember": [
{
"ref": "Nested"
},
"NestedString"
]
},
null
]
}
]
}

0 comments on commit 3606c0a

Please sign in to comment.