Skip to content

Publicly accessible PrettyPrint in CheckResult #2582#3030

Open
modery wants to merge 1 commit intomicrosoft:mainfrom
modery:main
Open

Publicly accessible PrettyPrint in CheckResult #2582#3030
modery wants to merge 1 commit intomicrosoft:mainfrom
modery:main

Conversation

@modery
Copy link

@modery modery commented Mar 11, 2026

Currently there is no publicly accessible PrettyPrint function. The TexlParser.Format function does the right job, but it is only accessible internally. By providing a publicly accessible function, other tools can make use of it to format PowerFx code in a nicer way.
This contribution adds a publicly accessible PrettyPrint function, CheckResult.ApplyFormat(), as requested in #2582

Fix

File: ‎src/libraries/Microsoft.PowerFx.Core/Public/CheckResult.cs
CheckResult.cs has been updated with a new function called ApplyFormat(), which returns the pretty-printed form of the expression. This way, we can use an Engine() object with CheckResult, set the text, and apply formatting:

var check = new CheckResult(new Engine(new PowerFxConfig()));
check.SetText(script);
var formatted = check.ApplyFormat();

Tests

File: ‎src/tests/Microsoft.PowerFx.Core.Tests.Shared/FormatterTests.cs
Test cases have been added similar to the existing TestPrettyPrint test case

@modery modery requested a review from a team as a code owner March 11, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant