Repository navigation
.NET: fix(dotnet): parse declarative workflow formulas and values with InvariantCulture - #10069
Open
Prognosticate X (Prognosticate-X) wants to merge 2 commits into
Conversation
…h InvariantCulture
Prognosticate X (Prognosticate-X)
temporarily deployed
to
github-app-auth
November 4, 2026 00:08 — with
GitHub Actions
Inactive
Prognosticate X (Prognosticate-X)
temporarily deployed
to
github-app-auth
November 4, 2026 00:08 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The invariant-culture fix lacks a regression test directly exercising RecalcEngine.Format under de-DE or fr-FR, so existing tests would still pass if the fix were removed.
1 open issue
What changed in this PR
This PR addresses #10033 by making .NET declarative workflow formula parsing and type conversions independent of the host culture.
Changes:
- Sets invariant culture for Power Fx parsing in the expression engine and template extension.
- Uses invariant culture for numeric and temporal parsing and formattable string conversion.
- Adds
de-DEandfr-FRregression tests for expressions, conversions, and workflow execution.
| File | Description |
|---|---|
dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/PowerFx/WorkflowExpressionEngineTests.cs |
Tests formula parsing under German and French cultures. |
dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/Extensions/ObjectExtensionsTests.cs |
Tests invariant numeric parsing and string conversion. |
dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/DeclarativeWorkflowTest.cs |
Tests workflow execution and numeric state across cultures. |
dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/PowerFx/WorkflowExpressionEngine.cs |
Configures invariant parsing while preserving side-effect settings. |
dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Extensions/TemplateExtensions.cs |
Passes invariant parser options to template evaluation. |
dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Extensions/ObjectExtensions.cs |
Makes supported parsing and formatting conversions culture-independent. |
Review effort: Balanced
| if (expressionSegment.Expression.ExpressionText is not null) | ||
| { | ||
| return engine.Eval(expressionSegment.Expression.ExpressionText).Format(); | ||
| return engine.Eval(expressionSegment.Expression.ExpressionText, options: options).Format(); |
Contributor
Author
There was a problem hiding this comment.
Added regression tests in TemplateExtensionsTests.cs (both PowerFx and Extensions test suites) exercising RecalcEngine.Format with Max(1, 2) under de-DE and fr-FR host locales. Thanks for the review!
Prognosticate X (Prognosticate-X)
deployed
to
github-app-auth
November 4, 2026 06:53 — with
GitHub Actions
Active
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Motivation & Context
In
.NETdeclarative workflows (Microsoft.Agents.AI.Workflows.Declarative), expressions and values were parsed using the host process's current culture (CultureInfo.CurrentCulture). On host systems configured with cultures where,is used as the decimal separator (such asde-DEorfr-FR):=Max(1, 2)failed to parse because,was treated as a decimal separator instead of an argument delimiter.ObjectExtensions.ConvertTypeparsed strings like"3.14"using default culture, parsing"3.14"as314onde-DEor failing withFormatExceptiononfr-FR.ConvertTypeproduced localized strings (e.g."3,14").Declarative workflows defined in YAML must produce identical, consistent behavior regardless of host locale, matching the behavior of the Python SDK package.
Fixes #10033
Description & Review Guide
What are the major changes?
WorkflowExpressionEngine.cs: explicitly setParserOptions.Culture = CultureInfo.InvariantCulturewhen initializing the engine options so PowerFx parses formulas using invariant culture.TemplateExtensions.cs: passParserOptionswithCultureInfo.InvariantCulturetoengine.Eval(...).ObjectExtensions.cs: passCultureInfo.InvariantCulturetoint.Parse,long.Parse,decimal.Parse,double.Parse,DateTime.Parse, andTimeSpan.Parse. When convertingIFormattable/DateTime/TimeSpanto string inConvertToString, useCultureInfo.InvariantCulture.WorkflowExpressionEngineTests.cs,ObjectExtensionsTests.cs, andDeclarativeWorkflowTest.cstesting formula evaluation, type conversion, and declarative workflow execution underde-DEandfr-FRcultures.What is the impact of these changes?
What do you want reviewers to focus on?
CultureInfo.InvariantCultureusage across PowerFx parser options andConvertType.Related Issue
Fixes #10033
AI Assistance
AI assistance details: Analysis of culture-dependent parsing paths and drafting unit tests for de-DE and fr-FR host locales.
Contribution Checklist