Skip to content

Bug with recursive extension functions #109

@caesay

Description

@caesay

I added the following test toExtensionFixture.cs :

        [Test]
        public void TestRecursiveCustomExtension()
        {
            var variables = new VariableDictionary();
            variables.Add("Foo", "Bar");

            variables.AddExtension("supercoolfunc", SuperCoolFunc!);
            variables.Add("Var1", "#{Foo|supercoolfunc}");
            variables.Add("Var2", "#{Var1}");
            
            var result = variables.Get("Var2");
            result.Should().Be("2-1-18");
        }

This should work fine, but actually the test fails, and the result is #{Foo|supercoolfunc}.

The bug can be fixed by updating the EvaluationContext to pass extensions to nested contexts.

On EvaluationContext.cs line 125, change:

var context = new EvaluationContext(new Binding(), x, this);

to:

var context = new EvaluationContext(new Binding(), x, this, Extensions);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions