GGua REFERENCE
DOCS / .NET PACKAGES

.NET packages

Use these packages to launch games and test their UI in C#. Add image comparison, semantic comparison, or replay when you need it.

Install

Add only the features you needpowershell
dotnet add package Gua.Core
dotnet add package Gua.Testing

# Implement an engine adapter
dotnet add package Gua.Runtime

# Launch an engine process from an external test
dotnet add package Gua.Testing.Godot
dotnet add package Gua.Testing.Unity

# Optional capabilities
dotnet add package Gua.Testing.Visual
dotnet add package Gua.Testing.Snapshots
dotnet add package Gua.Testing.Recording

Keep the game integration and all Gua packages in one project on the same version. Visual, Snapshots, and Recording are independent opt-ins.

Check the installed version

Without a version argument, the command selects the latest compatible stable version from the configured NuGet feeds when it runs. A concrete version is recorded in .csproj, or Directory.Packages.props with central management. Later builds do not continually update it to the latest release. Commit those files and align the game integration and related Gua packages. For an existing game or CI, specify its actual version with --version. Official CLI specification

NuGet: Core · Testing · Testing.Godot · Testing.Unity · Runtime · Testing.Visual · Testing.Snapshots · Testing.Recording

Choose a package

GoalAddUse it for
Write ordinary semantic UI testsGua.Testing + engine hostVisibility, enabled state, text, values, and state transitions after actions.
Build a custom engine adapterGua.RuntimePublish semantic frames and implement actions, screenshots, and the Inspector bridge in the game.
Detect rendering regressionsGua.Testing.VisualFind clipping, layout shifts, wrong assets or themes, and unexpected overlays.
Detect semantic regressionsGua.Testing.SnapshotsCompare IDs, hierarchy, text, values, state, and publication order with a JSON baseline.
Save and replay an interactionGua.Testing.RecordingShare regression flows, bug reproductions, and long journeys using semantic targets.

Target frameworks

Packagenet10.0netstandard2.1Primary use
Gua.Core✓✓C ABI bindings for native Gua
Gua.Testing✓✓Locators, waits, assertions, and diagnostics
Gua.Runtime✓✓Shared runtime C ABI wrapper for engine adapters
Gua.Testing.Unity✓✓Build, launch, and connect Unity Editor/Players
Gua.Testing.Visual✓✓PNG baseline comparison
Gua.Testing.Snapshots✓✓Semantic UI and optional World JSON baselines
Gua.Testing.Recording✓✓Semantic action recording and replay
Gua.Testing.Godot✓—Control a Godot process from an external .NET test

Gua.Core

The lowest .NET layer over the native C ABI. It defines the UI-tree, request, and event contracts.

TypeResponsibility
IGuaContextThe common operation boundary shared by local and remote contexts.
GuaContextOwns a native Gua context and its nodes, snapshots, requests, and events.
GuaSelectorRepresents selection by ID, role, text, state, and scope.
GuaNodeStateObserved state such as visible, enabled, value, focused, and checked.
GuaAction / GuaEventAn external request and the result or event observed by the host.
GuaResetThe contract for session epochs and clearing requests, events, and retained history.

Gua.Runtime

Gua.Runtime is for managed engine-adapter authors, not ordinary test authors. It exposes the shared gua_runtime C ABI through typed APIs so adapters do not duplicate P/Invoke declarations, request queues, screenshot timeout handling, version publication, or Inspector WebSocket hosting. Choose it when integrating an engine other than Godot or Unity, or when adapting a custom UI framework. See the Gua.Runtime implementation guide.

Gua.Testing.Unity

UnityPlayerBuilder and UnitySceneTestHost connect external tests to Unity 6 desktop Mono Players on Windows x64, Linux x64, Intel macOS, and Apple Silicon macOS, or to Editor Play Mode. Native Intel macOS Editor support is implemented but unverified. Use the host for Unity executable discovery, free-port allocation, bridge connection, and startup/teardown log capture. See the Unity API reference and support limits.

Gua.Testing

Adds the higher-level API consumed by tests.

TypeResponsibility
GuaAssertionsEntry point for GetById, GetByRole, and WaitFor....
GuaLocatorQueryBuilds selectors with ByRole, ByText, Within, WhereVisible, and related filters.
GuaNodeSnapshotEvidence for a node at the exact frame and revision where a wait succeeded.
GuaTestSessionControls reset and strict leak detection around a test.
GuaAssertionScopeApplies framework failure handling and diagnostic options within a scope.
GuaDiagnosticsWrites the UI tree, logs, history, and environment metadata after a failure.

Gua.Testing.Godot

Starts a Godot process and connects to its in-game WebSocket bridge.

TypeResponsibility
GodotSceneTestHostOwns scene startup, bridge connection, shutdown, process output, and screenshot access.
GodotSceneTestHostOptionsConfigures the executable, project path, headless mode, port, environment, and reset policy.
GuaRemoteContextAn IGuaContext that polls snapshots and sends actions over WebSocket.
GuaRemoteUiTreeConverts a remote JSON snapshot into the .NET node model.
GuaScreenshotRepresents a saved PNG, including its absolute path and dimensions.

Gua.Testing.Visual

An opt-in layer for comparing explicitly captured PNGs with reviewed baselines. A semantic assertion may prove that a button is visible while missing that it is clipped, overlapping another control, using the wrong asset, or covered by an unexpected overlay. Visual testing closes that gap. It supports pixel thresholds, allowed difference ratios, masks, explicit OS/renderer variants, and dimension mismatch detection. See the visual testing guide for setup and CI policy.

Compare a screen with its baselinecsharp
var result = await GuaVisualAssertions.ExpectScreenshotAsync(
    host.Context, "title-screen", new()
    {
        BaselineDirectory = "baselines",
        ArtifactDirectory = "artifacts/gua",
        BaselineVariant = "windows-unity-mono",
        PixelThreshold = 0.02f,
        MaxDifferentPixelRatio = 0.001,
    });
Failure reasonFiles written
pixel_differenceexpected.png, actual.png, diff.png, and comparison.json
baseline_missingactual.png and comparison.json
dimension_mismatchexpected.png, actual.png, and comparison.json

comparison.json records the comparison name, variant, actual dimensions, different-pixel metrics, thresholds, masks, failure reason, and diagnostic absolute baselinePath. The package does not generate HTML; the gua-tester visual-report action owns rendering and publication. Normal CI must not update its own baselines. Keep resolution, DPI, fonts, locale, theme, engine, and renderer deterministic, and mask only genuinely nondeterministic regions.

Gua.Testing.Snapshots

An independent opt-in layer that normalizes UI and optional World JSON before comparison with a baseline. CompareSnapshot returns a typed result; ExpectSnapshot throws an assertion exception carrying that result on failure. IDs, hierarchy, semantic properties, and array publication order remain significant. Geometry and runtime metadata are excluded by default; use Visual for PNG comparison.

Compare a semantic baselinecsharp
using Gua.Testing.Snapshots;

var options = new SemanticSnapshotOptions
{
    BaselineDirectory = "baselines/semantic",
    ArtifactDirectory = "artifacts/semantic",
    BaselineVariant = "english",
    Rules = new[]
    {
        new SemanticSnapshotRule("/ui/nodes/*/text",
            SemanticSnapshotRuleAction.Mask, "account/name"),
    },
};
GuaSemanticSnapshots.ExpectSnapshot(host.Context, "settings", options);

Missing baselines fail without creating one. Update explicitly with UpdateBaselines = true or exactly GUA_UPDATE_SEMANTIC_BASELINES=1. Keep updates disabled in regular CI and review baseline diffs before committing them. Visual's GUA_UPDATE_BASELINES does not approve semantic baselines.

Configure mask/ignore rules before capture and cover every representation of sensitive data; there is no automatic secret detection. These rules do not redact screenshots or separate Trace observations. Each comparison retains actual.json, optional expected.json, diff.json, and comparison.json. An optional WorldTreeProvider is read sequentially with UI; callers must supply stable trees when a coordinated frame matters. See the 1.1.0 API and rule contract.

Gua.Testing.Recording

Stores multi-step journeys such as login, settings changes, or purchase confirmation as semantic actions for regression testing and bug reproduction. It records IDs and roles instead of coordinates, and waits for request-ID-correlated host completion on replay, making it more reliable than a fixed-delay macro. See the recording guide for complete workflows.

Record and replay a journeycsharp
var recorder = new GuaRecorder(host.Context);
await recorder.ClickAsync(new(Id: "open-login"));
await recorder.SetValueAsync(new(Id: "password"), password,
    sensitive: true, secretKey: "login-password");
GuaRecordingFile.Save("recordings/login.json", recorder.Recording);

var recording = GuaRecordingFile.Load("recordings/login.json");
await GuaReplayer.ReplayAsync(host.Context, recording, new()
{
    SecretResolver = key => key == "login-password" ? password : null,
});

GuaRecorder, GuaReplayer, and GuaRecordingFile support semantic wait conditions in place of fragile delays. Sensitive set_value steps store only a secretKey, never plaintext. Coordinate fallback is disabled by default.

See the Runtime guide for observations and the testing guide for Trace and action waits. For TypeScript values, see Value tools; for AI connections, see npm packages.

Choose the API for the task

TaskPackage / APIExample
Read typed observationsGua.Runtime registration; Gua.Testing.GuaWebSocketContext subscriptionsObserve
Record test evidence and write offline HTMLGua.Testing.GuaTraceSession / GuaTraceReport.WriteHtmlTrace
Check semantic structureGua.Core.GuaSemanticLinter.AnalyzeSemantic lint
Query authorized physicsGua.Runtime.GuaRuntimeSpatialClient; Gua.Testing.GuaWebSocketContextSpatial queries
Replay finite input offsetsGua.Testing.Recording.GuaReplayer.ReplayTimedSegmentAsyncTimed Segment
Read packaged schemas offlineGua.Testing.GuaDistribution.ReadSchema / ValidateJsonResource API