static void _Patch(CodeBinaryOperatorExpression op, CodeDomVisitContext ctx, CodeDomResolver resolver) { if (null != op) { //var rf = op.Left as CodeFieldReferenceExpression; //if (null != rf && rf.FieldName == "Reduce") // System.Diagnostics.Debugger.Break(); var scope = resolver.GetScope(op); if (CodeBinaryOperatorType.IdentityEquality == op.Operator) { if (_HasUnresolved(op.Left)) { return; } //var vop = op.Right as CodeVariableReferenceExpression; //if (null != vop && vop.VariableName == "n") // System.Diagnostics.Debugger.Break(); var tr1 = resolver.GetTypeOfExpression(op.Left); if (resolver.IsValueType(tr1)) { if (_HasUnresolved(op.Right)) { return; } var tr2 = resolver.GetTypeOfExpression(op.Right); if (resolver.IsValueType(tr2)) { var op2 = new CodeBinaryOperatorExpression(op.Left, CodeBinaryOperatorType.ValueEquality, op.Right); CodeDomVisitor.ReplaceTarget(ctx, op2); return; } } op.UserData.Remove("slang:unresolved"); } else if (CodeBinaryOperatorType.IdentityInequality == op.Operator) { if (_HasUnresolved(op.Left)) { return; } var tr1 = resolver.GetTypeOfExpression(op.Left); if (resolver.IsValueType(tr1)) { if (_HasUnresolved(op.Right)) { return; } var tr2 = resolver.GetTypeOfExpression(op.Right); if (resolver.IsValueType(tr2)) { // we have to hack the codedom because there is no value inequality op.Operator = CodeBinaryOperatorType.ValueEquality; var newOp = new CodeBinaryOperatorExpression(new CodePrimitiveExpression(false), CodeBinaryOperatorType.ValueEquality, op); CodeDomVisitor.ReplaceTarget(ctx, newOp); } } op.UserData.Remove("slang:unresolved"); } } }