Power-Fx
Power-Fx copied to clipboard
Cannot use JSON function on own record types
The following unit test fails but it should not.
public class LazyRecordType : RecordType
{
public LazyRecordType()
{
}
public override IEnumerable<string> FieldNames => new string[1] { "SubProperty" };
public override bool TryGetFieldType(string name, out FormulaType type)
{
var subrecord = RecordType.Empty();
subrecord = subrecord.Add("x", FormulaType.String);
type = subrecord;
return true;
}
public override bool Equals(object other)
{
return true;
}
public override int GetHashCode()
{
return 1;
}
}
[Fact]
public void Json_IncludeBinaryData_AllowSideEffects()
{
var config = new PowerFxConfig();
config.EnableJsonFunctions();
var engine = new RecalcEngine(config);
var record = RecordType.Empty();
record = record.Add("Property", new LazyRecordType());
var formulaParams = RecordType.Empty();
formulaParams = formulaParams.Add("Var", record);
var result = engine.Check(
"JSON(Var)",
formulaParams);
Assert.True(result.IsSuccess);
}