Skip to content

Quick start - C# / .NET

The C# client targets .NET 8, uses Task/ValueTask for async, exposes push events via IAsyncEnumerable<SubscriptionEvent>, and has zero external NuGet dependencies (everything ships in the BCL).

Prerequisites

  • .NET 8 SDK
  • The veriCue server is running on 127.0.0.1:4242

Install

bash
dotnet add package VeriCue

Minimal example

csharp
using VeriCue;

await using var client = new VeriCueClient();
await client.ConnectAsync("127.0.0.1", 4242);

var obj = await client.FindObjectAsync("MainWindow/centralWidget/okButton");
Console.WriteLine($"Found: {obj.GetProperty("className").GetString()}");

await client.MouseClickAsync("MainWindow/centralWidget/okButton");

var props = await client.GetPropertiesAsync(
    "MainWindow/statusLabel", new[] { "text" });
Console.WriteLine($"Status: {props.GetProperty("text").GetString()}");

With xUnit

csharp
using Xunit;
using VeriCue;

public class LoginTests : IAsyncLifetime
{
    private VeriCueClient _client = null!;

    public async Task InitializeAsync()
    {
        _client = new VeriCueClient();
        await _client.ConnectAsync("127.0.0.1", 4242);
    }

    public async Task DisposeAsync() => await _client.DisposeAsync();

    [Fact]
    public async Task OkButtonClicks()
    {
        var result = await _client.MouseClickAsync(
            "MainWindow/centralWidget/okButton");
        Assert.True(result.GetProperty("clicked").GetBoolean());
    }
}

Push events

csharp
string subId = await client.SubscribeSignalAsync(
    "MainWindow/okButton", "clicked");

await client.MouseClickAsync("MainWindow/okButton");

// Either await one event with a timeout…
var evt = await client.NextEventAsync(TimeSpan.FromSeconds(5));
Console.WriteLine($"Got {evt.EventName} from {evt.Path}");

// …or stream them
await foreach (var e in client.EventsAsync(ct))
    Console.WriteLine($"{e.EventName} on {e.Path}");

// …or register a per-subscription callback
await client.SubscribeSignalAsync(
    "MainWindow/dropZone", "fileDropped",
    callback: e => Console.WriteLine($"file: {e.Data}"));

Multi-process scenarios

When your system has more than one Qt process (main GUI + worker), MultiVeriCueClient manages a name → client map with parallel-aware helpers:

csharp
var fleet = new MultiVeriCueClient(
    new Dictionary<string, (string, int)>
    {
        ["main"]   = ("127.0.0.1", 4242),
        ["worker"] = ("127.0.0.1", 4243),
    });
await fleet.ConnectAllAsync();

await fleet["main"].MouseClickAsync("MainWindow/startWorkerBtn");
await fleet["worker"].WaitForPropertyAsync(
    "WorkerWindow/statusLabel", "text", "Ready");

await fleet.DisconnectAllAsync();

See Clients → C# for the full method reference.

Released under a commercial licence. Privacy · Terms