Repository navigation
05 Layer Farol.Engine Verification and Testing
The Verification and Testing subsystem delivers fast, compiler-accurate feedback for agent edits, provides Roslyn lightbulb quick-fixes and refactorings, executes toolchain-appropriate builds, and runs impacted tests.
Farol.Engine (Verification & Testing)
├── Diagnostics/
│ ├── DiagnosticCheck.cs # Compiler check engine (about a second)
│ ├── DiagnosticBaseline.cs # Baseline diagnostics of the load, computed on first need
│ ├── DeclarationShape.cs # Syntax-only declaration diffing (body vs signature changes)
│ ├── EditImpact.cs # Dependency reach analysis for modified symbols
│ ├── CheckCompilations.cs # Reusable compilations with replaced reference pointers
│ └── CheckModels.cs # Requests, plans, and results models
├── CodeActions/
│ ├── CodeActionFinder.cs # Discovers Roslyn fixes & refactorings at line/column
│ ├── CodeActionEditor.cs # Generates unified diff previews & applies edits atomically
│ └── CodeActionProviders.cs # Reflection-based provider loader for C# and VB.NET
├── Building/
│ ├── BuildRunner.cs # Orchestrates dotnet build and Visual Studio MSBuild.exe
│ ├── BuildLogReader.cs # Parses binary logs (.binlog) via MSBuild.StructuredLogger
│ └── BuildModels.cs # Build commands, results, and issues
└── Testing/
├── TestRunner.cs # Runs tests via vstest.console or dotnet test, reads TRX
├── AffectedTestFinder.cs # Backward call-graph traversal to find impacted tests
├── ChangedMembers.cs # Identifies symbols altered between two snapshots
├── TestCommands.cs # Selects test host (vstest, dotnet test, Microsoft.Testing.Platform)
├── TestFrameworks.cs # Identifies test attributes (xUnit, NUnit, MSTest, TUnit)
├── TestProjects.cs # Discovers test projects and their dependencies
└── TestResults.cs # Parses TRX XML files, extracts failures and user stack frames
When an agent edits code, a full build takes far longer than a check. Farol's dotnet_check returns compiler feedback in about a second (p95 under 2 s).
Full analyzer suites (such as Microsoft.CodeAnalysis.NetAnalyzers, style rules, and third-party Roslyn analyzers) execute hundreds of complex AST rules. dotnet_check evaluates compiler diagnostics only (syntax, semantic type binding, overload resolution, and declaration errors). Full analyzer warnings are deferred to dotnet_build.
Legacy projects frequently have hundreds of pre-existing warnings. The load snapshot is the baseline; a project's or file's baseline diagnostics are computed on first need and cached until the next reload. When an edit is checked, Farol matches current diagnostics against the baseline using a 4-part fingerprint:
- Pre-existing issues are suppressed.
- Only newly introduced issues are returned to the agent.
- Because line numbers are excluded from the fingerprint, edits that add or remove lines above an existing warning do not falsely mark it as new.
The baseline is only sound for files Farol read before they changed. A file edited while the workspace loads may have been read already edited, so its baseline diagnostics would hide the edit's own errors. WorkspaceSession records such files in WorkspaceLoad.ChangedDuringLoad (see the Workspaces and Loading page). DiagnosticCheck then:
- Moves every diagnostic located in such a file from the existing ones to the new ones (
WithUnseenAsNew). The baseline itself is not changed. - Checks the file in
scope=changedeven when its text equals the text the load read. - Returns the checked files that were changed during the load in
CheckResult.ChangedDuringLoad;CheckRendererwrites achanged while the workspace loaded: <files>line saying that Farol did not see these files before the change, so all of their errors and warnings are listed as new and some may be older.
Only the file's own diagnostics are reported: a caller in another file broken by a declaration the edit changed is not, since the old text was never seen. Like any change since the load, the file's diagnostics stay new until the next reload.
The Claude Code plugin calls dotnet_check with format=hook and edited set to the file just edited (see the Integrations page). CheckTool answers as a PostToolUse hook expects:
-
New errors:
{"decision": "block", "reason": ...}, with the errors in the reason. -
New warnings:
additionalContextwith the warnings. -
Clean edit:
{}. -
Workspace still loading: the hook waits for the load only until the load has run for
Farol:HookLoadWaitSeconds(default 20 s, at most 30 s,0never waits) since its start (AC-49); a load done by then gets the usual answer, and a load that failed is named as added context. Otherwise its answer isadditionalContextsaying the workspace is still loading and that the edit is checked once the load is done, in the answer to the next edit (or by callingdotnet_check). The edit is not lost (AC-48). -
Edits that are not Farol's to check: a file that is not C# or VB, or a path outside the trusted directories, is passed over with
{}before any solution is picked. -
No solution can be picked (
workspace_ambiguousorworkspace_not_found; see AC-44 on the Workspaces and Loading page): the first such answer in a server process isadditionalContextthat says Farol could not tell which solution the file belongs to and how to name one (dotnet_workspacewithaction='load'andworkspaceset to it); later ones are{}. Claude Code never shows an agent a hook's error, which is why the explanation goes in the context. The failure is still recorded in the usage log with its error code.
In large solutions (e.g. DNN Platform: 80 projects, 0.58M lines), recompiling every project that depends on an edited file would be far too slow. Farol uses a two-stage reach analysis:
flowchart TD
Edit["Agent Edits File"] --> Shape{"Same Declarations? (DeclarationShape)"}
Shape -- "Yes (Body-only edit)" --> Fast["Re-check ONLY the edited file (fast path)"]
Shape -- "No (Signatures / Members changed)" --> Impact["EditImpact Analysis"]
Impact --> Reach{"Impact Reach"}
Reach -- "ImpactReach.Files" --> FilesOnly["Re-check edited file + only files referencing changed symbols"]
Reach -- "ImpactReach.Project" --> WholeProject["Re-check the edited project (a global using changed)"]
Reach -- "ImpactReach.Dependents" --> Dependents["Re-check project + dependent projects (Cross-language)"]
-
Syntax-Only Declaration Comparison (
DeclarationShape): Compares the AST declaration shapes before and after the edit. If method bodies or property getters/setters changed but class headers, method signatures, return types, and field declarations remained identical, Farol re-checks only the edited file. -
Selective Reach Analysis (
EditImpact): If declarations changed, Farol identifies the reach:- If a member was modified or deleted, Farol finds only the specific files across the solution that reference that member and re-checks them.
- If an abstract member was added, Farol identifies derived classes needing implementation.
- If a member was added, the files that name it are re-checked too (overloads, hiding, ambiguity). Changes a name cannot bound (type headers, operators, assembly attributes) re-check the dependent projects whole.
- Cross-language propagation works automatically: changing a C# method signature will surface the compilation error inside the calling VB.NET project.
-
Optimized Compilation Reuse (
CheckCompilations): Projects that have no edits of their own are not rebuilt. Instead, Farol re-uses their load-time compilations and updates only the assembly reference pointer to the edited project (Compilation.ReplaceReference). This avoids recompiling the projects the edit cannot affect.
dotnet_code_actions surfaces Roslyn's native IDE quick-fixes and refactorings directly to the AI agent.
-
Compiler Fixes (
fix): Adds missingusing/Importsstatements, generates missing methods/properties, implements interfaces, fixes type mismatches. -
Refactorings (
refactoring): Extracts methods, introduces local variables, converts foreach to LINQ, etc. - Preview Mode: Returns a unified diff showing exact changes across affected files without altering disk state.
-
Apply Mode (
apply=true):- Verifies that the file on disk has not drifted since the snapshot was taken.
- Applies edits atomically using
AtomicFile. - Automatically runs an immediate
dotnet_checkand returns the fresh compiler verification in the same response. - Blocked under
--read-onlymode.
dotnet_build compiles the solution or a specified project using the exact toolchain required for that code:
| Project Type | Toolchain Selected | Arguments & Options |
|---|---|---|
| Modern SDK-Style Projects | dotnet build |
-c Configuration -nologo -v:m -clp:NoSummary -bl:... -p:PreferredUILang=en-US |
| Classic .NET Framework Projects | Visual Studio MSBuild.exe
|
-restore -p:Configuration=… -m -nodeReuse:false -nologo -v:m -clp:NoSummary -bl:… -p:PreferredUILang=en-US (plus -p:RestorePackagesConfig=true with packages.config) |
Farol configures every build to write an MSBuild binary log (.binlog) to a temporary artifacts directory. Farol reads the .binlog directly using MSBuild.StructuredLogger:
- Extracts exact errors and warnings directly from the structured object model.
- Eliminates parsing errors caused by localized console text.
-
Deduplication across Target Frameworks: In multi-targeting projects (
net10.0;net48), an error is emitted once per framework. Farol deduplicates identical errors, displaying them as a single issue with a list of affected frameworks.
Running concurrent MSBuild processes against the same solution results in file locking errors inside intermediate output directories (obj/). BuildRunner enforces a per-workspace concurrency lock (AcquireAsync), serializing builds and test runs. This also holds across Farol processes, through a turn.lock file in Farol's build folder; the second process waits and says so in its progress every 15 seconds. After the build and test timeouts together, it stops waiting with a conflict error.
dotnet_test runs tests and reports failures concisely.
-
Classic .NET Framework Test Projects: Executed via Visual Studio's
vstest.console.exe. -
Modern SDK-Style Projects: Executed via
dotnet test, on VSTest or onMicrosoft.Testing.Platformwhen the nearestglobal.jsonsets"test": { "runner": "Microsoft.Testing.Platform" }.
Passing tests waste context tokens. Farol parses the output TRX files and returns failures only:
- The exact failing test name.
- The assertion message.
- Filtered Stack Trace: Automatically filters out framework and test runner frames (xUnit, NUnit, MSTest internals), surfacing only the stack frames located in user code.
When an agent passes affectedBy='changes' or affectedBy='SymbolName':
- Identifies the modified symbols.
- Traces references backwards through the call graph: from each symbol's callers, through enclosing members, interface implementations, and overrides.
- Stops when it reaches test methods (recognized via
TestFrameworks). - Executes only the impacted tests, allowing agents to verify behavioral changes in seconds rather than running the full test suite.
Welcome to the official technical documentation for Farol, an open-source Model Context Protocol (MCP) server that equips AI coding agents (Claude Code, GitHub Copilot, Google Antigravity, Cursor, Codex) with compiler-accurate understanding of C# and VB.NET solutions.
- Home — Project overview, value proposition, quickstart, and problem statement
- 01. Architecture & Design Philosophy — Layered architecture, snapshot isolation, BuildHost model, design rationale
- 02. Layer: Farol.Core — Zero-Roslyn foundation: path sandbox, process execution, diffing, atomic writes, privacy
- 03. Layer: Farol.Engine — Workspaces & Loading — MSBuildWorkspaceLoader, analyzer copies, Visual Studio toolchain probing, background warmup, file watcher
- 04. Layer: Farol.Engine — Navigation & Markup — Compiler-accurate navigation, symbol search, IOperation classification, WebForms & XAML indexers, decompilation
- 05. Layer: Farol.Engine — Verification & Testing — Diagnostic checks in about a second, baseline fingerprinting, edits during a load, edit impact analysis, Code Actions, build & test runners
- 06. Layer: Farol.Engine — Legacy Modernization & Packages — Legacy inventory, config inspector, target surface portability, migration planner, NuGet API inspector
- 07. Layer: Farol.Tools & MCP Contract — Comprehensive reference for all 23 MCP tools, 7 prompts, the skill resources and MCP tasks
- 08. Layer: Farol.Host & CLI — Stdio transport, stream isolation, configuration precedence, privacy-first usage telemetry
- 09. Integrations & Plugins — Claude Code plugin (hook & skill), Visual Studio 2026, Copilot, Antigravity, VS Code, NuGet distribution
- 10. Benchmarks & Evals — Performance benchmarks (Umbraco & DNN Platform), evaluation suite and Phase 2 round, compiler oracle
- 11. Phase 2: Refactorings, Analyzers, Loaders & Index — Refactoring write path, analyzers in checks, heuristic and binlog loaders, persistent index, structured output, MCP Registry
- 12. Phase 3: MCP Tasks & Skills — Build, test, load and convert as MCP tasks; the playbook as three skills served by the server; exit results