microsoft / microsoft/Power-Fx
Cannot use JSON function on own record types
Open
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 3.4k
- Forks
- 358
- Avg merge
- 10h 34m
- Merged PRs (30d)
- 3
Description
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);
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the Json_IncludeBinaryData_AllowSideEffects test with EnableJsonFunctions, RecalcEngine.Check, and the JSON(Var) expression shown here. Trace why checking a record containing LazyRecordType does not succeed; done means the supplied test passes with result.IsSuccess true.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100