FastExpressionCompiler icon indicating copy to clipboard operation
FastExpressionCompiler copied to clipboard

Add structural equality comparison to the LightExpression

Open dadhi opened this issue 1 year ago • 1 comments

Given that we already have ToLambaExpression and after #271 we will have ToLightExpression. Now we have possibility to convert the Light Expression from and to the System Expression. The missing link is the ability to compare the restored expression. This issue should address it.

Update For now, we may compare the expressions converted to the C# code (which is not optimal):

#if LIGHT_EXPRESSION
        var sysExpr = expr.ToLambdaExpression();
        var restoredExpr = sysExpr.ToLightExpression();
        // todo: @feature #431 compare the restored target and source expressions directly instead of strings
        Assert.AreEqual(expr.ToCSharpString(), restoredExpr.ToCSharpString());
#endif

Update:

Take into account that when comparing the generated C# code, the generated names may be different based on the new expression identities. Because currently AppendName provides the unique name suffix based on the expression.GetHashCode()

dadhi avatar Nov 10 '24 11:11 dadhi

See #433, It might be beneficial to construct a string or a byte representation of Expression first and then compare those representations. It is likely not ideal from the performance perspective but worth to think about.

dadhi avatar Apr 04 '25 09:04 dadhi