microsoft / microsoft/Power-Fx
EvalAsync takes CurrentCulture to get FormulaValue
Open
@LucGenetier is already working on this.
Since Jun 29, 2023.
- Dominant language
- C#
- Stars
- 3.4k
- Forks
- 358
- Avg merge
- 10h 34m
- Merged PRs (30d)
- 3
Description
We found out that EvalAsync function takes a Current Culture when getting a FormulaValue result even though we don't pass CultureInfo to the ParserOptions.
Attached unit tests to reproduce
[Fact]
public async Task test()
{
// Setup
CultureInfo culture = new CultureInfo("es-ES");
CultureInfo.CurrentCulture = culture;
var parserOptions = new ParserOptions() { AllowsSideEffects = true, NumberIsFloat = true};
RecalcEngine recalcEngine = new RecalcEngine();
var check = recalcEngine.Check("Float(\"4,99\")", parserOptions);
var run = check.GetEvaluator();
var result = await run.EvalAsync(CancellationToken.None);
// Look at Result Value => Seems like 4.99
Assert.Equal(4.99, result.ToObject());
}
[Fact]
public async Task test2()
{
// Setup
CultureInfo culture = new CultureInfo("en-US");
CultureInfo.CurrentCulture = culture;
var parserOptions = new ParserOptions() { AllowsSideEffects = true, NumberIsFloat = true };
RecalcEngine recalcEngine = new RecalcEngine();
var check = recalcEngine.Check("Float(\"4,99\")", parserOptions);
var run = check.GetEvaluator();
var result = await run.EvalAsync(CancellationToken.None);
// Look at Result Value => Seems like 499
Assert.Equal((double)499, result.ToObject());
}
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.
Assessment
This issue has not been assessed yet.