microsoft / microsoft/Power-Fx
Public PrettyPrint (similar to TexlParser.Format)
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 3.4k
- Forks
- 358
- Avg merge
- 10h 34m
- Merged PRs (30d)
- 3
Description
I'm looking at integrating PowerFx.Core into my application so that I can format code snippets to a more user-friendly format.
I can see that https://github.com/microsoft/Power-Fx/blob/main/src/tests/Microsoft.PowerFx.Core.Tests.Shared/FormatterTests.cs#L259 has got a test that covers what I would need, however the TexlParser.Format (https://github.com/microsoft/Power-Fx/blob/main/src/libraries/Microsoft.PowerFx.Core/Parser/TexlParser.cs#L1964) function is internal only.
I also saw that TexlNode.ToString() prettifies the output, but not in the same way (https://github.com/microsoft/Power-Fx/blob/main/src/libraries/Microsoft.PowerFx.Core/Syntax/Nodes/TexlNode.cs#L278)
For example, using the following code snippet
If(CountRows(Filter('Time Off Requests','Created On'>=Today()&&Owner=LookUp(Users_1,'User Name'=User().Email,User)))>0,Navigate([@'Attendance Already Submitted'],ScreenTransition.Cover),NewForm(AttendanceForm))
Running the above through TexlNode.ToString() (via Engine.Parse("...").Root.ToString()) gives me
If(CountRows(Filter('Time Off Requests', 'Created On' >= Today() && Owner = LookUp(Users_1, 'User Name' = User().Email, User))) > 0, Navigate([@'Attendance Already Submitted'], ScreenTransition.Cover), NewForm(AttendanceForm))
(so some spacing has been added)
However, TexlParser.Format would return
If(
CountRows(
Filter(
'Time Off Requests',
'Created On' >= Today() && Owner = LookUp(
Users_1,
'User Name' = User().Email,
User
)
)
) > 0,
Navigate(
[@'Attendance Already Submitted'],
ScreenTransition.Cover
),
NewForm(AttendanceForm)
)
Is there a possibility to get a public PrettyPrint function somewhere (TexlNode.PrettyPrint(), for example)?
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
Start with FormatterTests.cs around the referenced test, then read the internal TexlParser.Format method in Parser/TexlParser.cs and compare it with TexlNode.ToString() in Syntax/Nodes/TexlNode.cs. Check how Engine.Parse exposes the syntax tree. Done means a public formatting entry point produces the multiline pretty-printed form demonstrated in the issue, with test coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100