Power-Fx / src
CLAUDE.md3.4k starsChanged 6 months agoMITView on GitHub
Power Fx is a low-code general-purpose programming language based on spreadsheet-like formulas. This is the open-source implementation of the language used across Microsoft Power Platform. The codebase contains a complete compiler and interpreter infrastructure written in C#. Note: The runLocalTests.cmd script runs tests for both .NET Framework 4.6.2 and .NET 7.0 configurations using VSTest. The Power Fx implementation follows a classic multi-phase compiler architecture: Expression Text → [Lexer] → Tokens → [Parser] → AST → [Binder] → Typed AST →…
Trending
More talk lately.about the whole repository
Who's talking about microsoft/Power-Fx
- A Hacker News story“Microsoft Power Fx – A low-code general purpose programming language”Hacker News · Mar 3, 2021 · 395 points
- A Hacker News story“Microsoft Power-Fx – Low-code programming language”Hacker News · Mar 8, 2021 · 2 points
- A Hacker News story“Power Fx low-code programming language”Hacker News · Mar 2, 2021 · 2 points
- microsoft/PowerApps-Tooling“Directly pass through custom page schema files, and handle any validation in canvas”GitHub · Sep 15, 2022 · 1 reactions
- ECas95/canvas-app-visualizer“v0.2: Run the official Microsoft Power Fx engine locally in browser WebAssembly”GitHub · Oct 3, 2026
The biggest 5 of 22 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 22
Talked about on GitHub and Hacker News (22 times).
On GitHub · 19
- Sep 15, 2022Directly pass through custom page schema files, and handle any validation in canvas — microsoft/PowerApps-Tooling1 reaction · 2 comments
- Oct 3, 2026v0.2: Run the official Microsoft Power Fx engine locally in browser WebAssembly — ECas95/canvas-app-visualizer0 reactions
- Mar 21, 2025Reduce network calls when CDP results are returned — microsoft/Power-Fx-Dataverse0 reactions · 2 comments
- Jan 25, 2025feat(powerfx): Transform expressions to syntax tree. — hastebrot/2025-toy-compiler0 reactions
- Jan 24, 2025Dependency scan — microsoft/Power-Fx-Dataverse0 reactions · 2 comments
14 more on GitHub
- Jan 3, 2025Summarize() when grouping on Columns should propagate the display names. — microsoft/Power-Fx-Dataverse0 reactions
- Nov 19, 2024Update build numbers to use 1.99.0-local for local builds — microsoft/Power-Fx-Dataverse0 reactions · 1 comment
- Nov 19, 2024pickup fix to stabalize tests — microsoft/Power-Fx-Dataverse0 reactions · 1 comment
- Nov 16, 2024Get latest Fx — microsoft/Power-Fx-Dataverse0 reactions · 2 comments
- Oct 16, 2024Add CDP test with delegation — microsoft/Power-Fx-Dataverse0 reactions · 3 comments
- Jul 31, 2024working by adding nuget source of powerfx daily builds — rajyraman/Power-Fx-.NET-Interactive0 reactions · 1 comment
- Dec 12, 2023Sql: support OptionSetInfo — microsoft/Power-Fx-Dataverse0 reactions
- Oct 25, 2023你现在的工作快乐吗 — guevara/read-it-later0 reactions
- Oct 10, 2023Upgrade to 1.0 Power Fx — UiPath/CoreWF0 reactions · 1 comment
- Aug 7, 2023SQL compiler: updated Text compat — microsoft/Power-Fx-Dataverse0 reactions
- May 11, 2023Move Formula Columns resource strings out of PowerFx into Dataverse — microsoft/Power-Fx-Dataverse0 reactions · 1 comment
- Apr 20, 2023Standardize editor config — microsoft/Power-Fx-Dataverse0 reactions
- Oct 1, 2022Microsoft.DotNet.ApiCompat reports a false CannotChangeAttribute compat issue — dotnet/arcade0 reactions · 1 comment
- Dec 29, 2021Mac OS: The type initializer for 'Microsoft.PowerFx.Core.Texl.BuiltinFunctionsCore' threw an exception — microsoft/power-fx-host-samples0 reactions
On Hacker News · 3
- Mar 3, 2021Microsoft Power Fx – A low-code general purpose programming language395 points · 189 comments
- Mar 8, 2021Microsoft Power-Fx – Low-code programming language2 points
- Mar 2, 2021Power Fx low-code programming language2 points
In this repositoryOne other file it gives its agents.
- CLAUDE.mdCLAUDE.md
The file
We split this CLAUDE.md into the rules it gives an agent
5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 135
Add static method with [TexlFunction] attribute or similar pattern
- Distinctive: line 136
Use IR nodes as input parameters
- Distinctive: line 260
Treat warnings as errors in Release
- Very specific: line 278
Test projects are organized into .Net4.6.2/ and .Net7.0/ folders with .Shared/ projects containing shared test code.
- Distinctive: line 304
Public NuGet Packages: Search for "Microsoft.PowerFx.*" on nuget.org
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Overview
Power Fx is a low-code general-purpose programming language based on spreadsheet-like formulas. This is the open-source implementation of the language used across Microsoft Power Platform. The codebase contains a complete compiler and interpreter infrastructure written in C#.
Build Commands
Building the Solution
# From src/ directory
dotnet build Microsoft.PowerFx.sln
# Or using MSBuild directly
msbuild Microsoft.PowerFx.sln -p:Configuration=Debug
# Build specific configuration
msbuild Microsoft.PowerFx.sln -p:Configuration=Release
msbuild Microsoft.PowerFx.sln -p:Configuration=DebugAll # Multi-targeting (net462 + net7.0)Building NuGet Packages
# From src/ directory
.\buildLocalPackages.cmd [Configuration] # Windows
# Default configuration is DebugAll if not specified
# Output packages go to src/outputpackages/Running Tests
# From src/ directory
.\runLocalTests.cmd [Configuration] # Windows (uses VSTest)
# Or using dotnet CLI (from solution root)
dotnet test src/Microsoft.PowerFx.sln
# Run tests for a specific project
dotnet test src/tests/Microsoft.PowerFx.Core.Tests.Shared/Microsoft.PowerFx.Core.Tests.Shared.csproj
# Run a single test by name
dotnet test --filter "FullyQualifiedName~YourTestName"
# Run tests by category
dotnet test --filter "Category=ExpressionTest"Note: The runLocalTests.cmd script runs tests for both .NET Framework 4.6.2 and .NET 7.0 configurations using VSTest.
Code Analysis
# StyleCop analyzers are configured in PowerFx.ruleset
# Analysis runs automatically during build
# Warnings are treated as errors in Release buildsArchitecture Overview
Core Components
The Power Fx implementation follows a classic multi-phase compiler architecture:
Expression Text → [Lexer] → Tokens → [Parser] → AST → [Binder] → Typed AST → [IR Translator] → IR → [Interpreter/Backend] → Result
- Microsoft.PowerFx.Core - The language compiler (no evaluation)
Lexer/- Tokenization with culture-aware parsingParser/- Recursive descent parser producing AST (Syntax/Nodes/)Binding/- Semantic analysis, symbol resolution, type checking (Binder.csis the core)Types/- Type system implementation (DType.cs,FormulaType.cs)IR/- Intermediate Representation for backend consumptionTexl/Builtins/- Function signatures and type checking (no implementation)
- Microsoft.PowerFx.Interpreter - Execution engine
EvalVisitor.cs- Walks IR tree to compute resultsFunctions/Library*.cs- Actual function implementationsRecalcEngine.cs- ExtendsEnginewith evaluation and reactive formulas
- Microsoft.PowerFx.Connectors - OpenAPI connector support for external APIs
- Microsoft.PowerFx.LanguageServerProtocol - LSP implementation for IDE integration
- Microsoft.PowerFx.Json - JSON serialization/deserialization
Key Architecture Patterns
Separation of Compilation and Execution: The Core library only compiles to IR with zero evaluation code. This allows multiple backends (JavaScript, SQL, etc.) to consume the same IR independently.
Symbol Table Composition: Multiple symbol tables can be layered (Config → Engine → Parameters), allowing flexible scoping:
SymbolTable- Mutable, contains variables, functions, enums, user-defined typesReadOnlySymbolTable- Immutable view, composableSymbolValues- Runtime values paired with SymbolTable
CheckResult Workflow: Central to compilation, with lazy phase evaluation:
var check = engine.Check(expressionText, parameterType);
check.ThrowOnErrors(); // Compilation errors
var result = check.Eval(); // Execution (Interpreter only)Type System:
DType- Internal discriminated union type representation (viaDKindenum)FormulaType- Public API wrapper around DTypeCoercionMatrix.cs- Defines valid type conversionsBinaryOpMatrix.cs- Type rules for operators- Supports: primitives, records, tables, functions, polymorphic types
Intermediate Representation (IR):
- Purpose: Makes it easier for backends to consume compiler output
- Explicit coercion nodes (backends don't reimplement coercion matrix)
- Normalized operators (And() as both operator and function → unified)
- Enums translated to backing values
- Simplified scope handling
- Located in
Microsoft.PowerFx.Core/IR/
Display Names vs Logical Names: Throughout the codebase, dual tracking of:
- Display names: User-facing, localized (e.g., "First Name")
- Logical names: Internal identifiers (e.g., "nwind_firstname")
Adding a New Built-in Function
Functions are split between Core (signatures/type checking) and Interpreter (implementation):
- Define signature in
src/libraries/Microsoft.PowerFx.Core/Texl/Builtins/NewFunction.cs:- Extend
TexlFunctionbase class - Implement
CheckInvocationfor type checking - Add to
BuiltinFunctionsCore._library
- Extend
- Implement logic in
src/libraries/Microsoft.PowerFx.Interpreter/Functions/Library*.cs:- Add static method with
[TexlFunction]attribute or similar pattern - Use IR nodes as input parameters
- Return
FormulaValueresults - Register in appropriate
Librarycategory
- Add static method with
- Add tests in
src/tests/Microsoft.PowerFx.Core.Tests.Shared/ExpressionTestCases/NewFunction.txt:>> NewFunction(arg1, arg2) ExpectedResult >> NewFunction("test", 42) "test42"
Expression Test Cases
Tests use a unique .txt file format in tests/Microsoft.PowerFx.Core.Tests.Shared/ExpressionTestCases/:
>> Expression
ExpectedResult
>> If(true, "yes", "no")
"yes"
>> 1+1
2
>> 1/0
Error({Kind:ErrorKind.Div0})BaseRunner.cs- Test harness infrastructure- Tests run across multiple backends/configurations
- Special markers:
#skip,#error,#novalue - Fuzzy numeric comparisons for floating point
- 60-second timeout per test
User-Defined Functions (UDFs)
- Parsed from Power Fx syntax
UserDefinedFunction.csin both Core and Interpreter- Support for recursion with stack depth tracking
- Can be added via
Engine.AddUserDefinedFunction()
String Localization
- Resource files in
src/strings/PowerFxResources.*.resx - Embedded in assemblies
- Access via
StringResourcesclass
Feature Flags
Featuresclass controls language behaviorFeatures.PowerFxV1- Current standard- Allows gradual feature rollout and compatibility modes
- Configured via
PowerFxConfig
Versioning
- Uses Nerdbank.GitVersioning (NBGV)
- Configuration in
version.jsonat repository root - Versions automatically derived from git tags/height
- Base version: 1.5
- Public releases from tags matching
v\d+\.\d+\.\d+$orrelease/\d+\.\d+$branches
Project Structure
src/
├── Microsoft.PowerFx.sln # Main solution file
├── libraries/ # Core libraries
│ ├── Microsoft.PowerFx.Core/ # Compiler (no evaluation)
│ ├── Microsoft.PowerFx.Interpreter/ # Execution engine
│ ├── Microsoft.PowerFx.Connectors/ # OpenAPI connectors
│ ├── Microsoft.PowerFx.Json/ # JSON integration
│ └── Microsoft.PowerFx.LanguageServerProtocol/ # LSP for IDE support
├── tests/ # Test projects
│ ├── Microsoft.PowerFx.Core.Tests.Shared/
│ │ └── ExpressionTestCases/ # .txt test files
│ └── Microsoft.PowerFx.Interpreter.Tests.Shared/
├── strings/ # Localized resource files
├── Directory.Build.props # Common MSBuild properties
├── PowerFx.ruleset # StyleCop configuration
└── nuget.config # NuGet feed configuration
docs/ # Language documentation
├── overview.md # Language design principles
├── data-types.md # Type system documentation
├── expression-grammar.md # Formal grammar
└── operators.md # Operator referenceKey Files to Understand
Microsoft.PowerFx.Core/Binding/Binder.cs(245KB) - Heart of semantic analysisMicrosoft.PowerFx.Core/Types/DType.cs(167KB) - Core type representationMicrosoft.PowerFx.Interpreter/Functions/Library.cs(146KB) - Main function implementationsMicrosoft.PowerFx.Core/Public/Engine.cs- Main entry point for compilationMicrosoft.PowerFx.Interpreter/RecalcEngine.cs- Evaluation and reactive formulasMicrosoft.PowerFx.Interpreter/EvalVisitor.cs- IR tree walker for evaluationMicrosoft.PowerFx.Core/Public/CheckResult.cs- Lazy compilation pipeline result
Important Concepts
Texl vs Power Fx
"Texl" is the internal codename (from Excel heritage) that appears throughout the codebase. Terms like TexlFunction, TexlLexer, TexlParser all refer to Power Fx components.
Cooperative Cancellation
The interpreter regularly checks CancellationToken and calls Governor.Poll() for cooperative cancellation, especially in loops. This prevents runaway evaluation.
Immutability
Most core data structures are immutable (DType, IR nodes, bound trees). Symbol tables are mutable but have version hashes to detect concurrent mutations.
DPath
Represents paths through type structure (e.g., "record.field.subfield"). Used extensively for type navigation and error reporting.
Guard Single Threaded
Core uses GuardSingleThreaded to detect concurrent mutations of mutable structures in development builds, catching threading bugs early.
Configuration Files
Directory.Build.props- Shared MSBuild properties across all projects- C# 10.0 language version
- StyleCop analyzers (strict code quality)
- Treat warnings as errors in Release
- Assembly signing configuration
- NuGet package metadata
PowerFx.ruleset/PowerFx.Tests.ruleset- StyleCop rule configuration- Strict code analysis for production code
- Relaxed rules for test code
version.json- NBGV configuration for automatic versioning
Development Notes
Multiple .NET Targets
Projects multi-target:
- .NET Standard 2.0 (for broad compatibility)
- .NET Framework 4.6.2 (legacy support)
- .NET 7.0+ (modern runtime)
Test projects are organized into .Net4.6.2/ and .Net7.0/ folders with .Shared/ projects containing shared test code.
Build Configurations
Debug/Release- Standard single-target buildsDebug462/Release462- .NET Framework 4.6.2 specificDebug70/Release70- .NET 7.0 specificDebugAll/ReleaseAll- Multi-targeting (used by local build scripts)
Code Quality
- StyleCop analyzers enforce consistent code style
- Warnings treated as errors in Release builds
- Code coverage configured in
CodeCoverage.runsettings - Performance tests in
Microsoft.PowerFx.Performance.Tests
Daily Builds
Daily packages published to Azure Artifacts:
https://pkgs.dev.azure.com/Power-Fx/7dd30b4a-31be-4ac9-a649-e6addd4d5b0a/_packaging/PowerFx/nuget/v3/index.jsonSee dailyBuilds.md for consumption details.
Resources
- Main Documentation:
docs/overview.md- Language design principles and philosophy - Samples Repository: https://github.com/microsoft/power-fx-host-samples
- Public NuGet Packages: Search for "Microsoft.PowerFx.*" on nuget.org
- Expression Grammar:
docs/expression-grammar.md - YAML Formula Grammar:
docs/yaml-formula-grammar.md(for source file storage)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

