Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support unused Field access in Block #439

Closed
dadhi opened this issue Dec 13, 2024 · 0 comments
Closed

Support unused Field access in Block #439

dadhi opened this issue Dec 13, 2024 · 0 comments
Assignees
Milestone

Comments

@dadhi
Copy link
Owner

dadhi commented Dec 13, 2024

see #438 for the context

When unused expressions are introduced in the expression tree, we encountered issues. We've resolved this by cleaning up our code to avoid adding these unnecessary snippets. (We didn't actually see these issues originally, so this help us clean up our code nicely!)

// FEC throws System.InvalidProgramException: Common Language Runtime detected an invalid program.
// WORKAROUND: Remove the unused value from the block

public class TestClass
{
    public int Result0 = 42;
    public int Result1;
}

var variable = Variable( typeof( TestClass ), "testClass" );

var block = Block(
    [variable],
    Assign(
        variable,
        New( typeof( TestClass ) )
    ),
    Block(
        Field( variable, nameof( TestClass.Result0 ) ), // Unused
        Assign(
            Field( variable, nameof( TestClass.Result1 ) ),
            Field( variable, nameof( TestClass.Result0 ) )
        )
    ),
    Field( variable, nameof( TestClass.Result1 ) )
);

var lambda = Lambda<Func<int>>( block );
var compiledLambda = lambda.CompileFast();
@dadhi dadhi self-assigned this Dec 13, 2024
@dadhi dadhi added this to the v5.0.1 milestone Dec 13, 2024
@dadhi dadhi changed the title Support unused Variable in Block Support unused Field access in Block Dec 13, 2024
dadhi added a commit that referenced this issue Dec 13, 2024
@dadhi dadhi closed this as completed in ae2264f Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant