.NET

Choose the Ansight .NET package, initialize the runtime, and branch into JPEG screenshots, touch input, screen views, telemetry, app lifecycle, pairing, configuration, artifacts, and remote tool suites including live reflection.

The .NET SDK is the current primary Ansight runtime integration.

Supported Targets

The core package targets:

  • net9.0
  • net9.0-android
  • net9.0-ios
  • net9.0-maccatalyst

Package ids:

PackageNuGet
AnsightNuGet
Ansight.MauiNuGet
Ansight.CoreNuGet

Use the package that matches the app:

  • Ansight for non-MAUI apps that want the standard runtime and all non-MAUI remote tools.
  • Ansight.Maui for .NET MAUI apps that want the standard runtime, all non-MAUI tools, MAUI tools, and MauiAppBuilder setup.
  • Ansight.Core for apps that want manual registration and no bundled concrete tool packages.

See .NET Setup Packages for the full package matrix.

Non-MAUI All-In-One Setup

using Ansight;

var options = Options.CreateBuilder()
    .WithAnsightSdk(ansight =>
    {
        ansight.WithBundledHostConnection(typeof(AppBootstrap).Assembly);
    })
    .Build();

Runtime.InitializeAndActivate(options);

WithAnsightSdk(...) applies the standard runtime defaults, host auto-probe, bundled host connection, JPEG capture, platform pairing where supported, all non-MAUI remote tools, and full tool access. Its callback runs before default tool-suite registration, so deny-all suites can be configured there:

using Ansight;
using Ansight.Tools.SecureStorage;

var options = Options.CreateBuilder()
    .WithAnsightSdk(ansight =>
    {
        ansight.WithSecureStorageTools(secure =>
        {
            secure.WithStorageIdentifier("MyApp");
            secure.AllowKeyPrefix("ansight.secure.");
        });
    })
    .Build();

MAUI All-In-One Setup

using Ansight.Maui;
using Ansight.Tools.SecureStorage;

public static MauiApp CreateMauiApp()
{
    var builder = MauiApp.CreateBuilder();

    builder
        .UseMauiApp<App>()
        .UseAnsight<App>(ansight =>
        {
            ansight.WithSecureStorageTools(secure =>
            {
                secure.WithStorageIdentifier("MyMauiApp");
                secure.AllowKeyPrefix("ansight.secure.");
            });
        });

    return builder.Build();
}

What the Core Package Covers

Ansight.Core includes:

  • sampling and retention configuration
  • built-in memory and FPS metrics
  • opt-in battery level metrics
  • screen-view and lifecycle events
  • runtime log callbacks
  • custom channels
  • optional session JPEG capture
  • optional touch input capture
  • app artifact providers and streamed artifact requests
  • runtime-owned host connection and reconnection
  • tool abstractions, custom tools, and tool guard policy
  • build-time remote tool enforcement

Common Next Steps

  • Use Setup Packages to choose Ansight, Ansight.Maui, or Ansight.Core.
  • Use Pairing to connect the app to Ansight Studio.
  • Use Configuration to tune sampling, capture, and pairing behavior.
  • Use JPEG Screenshots to choose between periodic session capture and on-demand VisualTree screenshots.
  • Use Performance Telemetry to capture built-in FPS, memory, and battery metrics.
  • Use Touch Input to capture taps, drags, long presses, and gesture cancellations in session replay.
  • Use Screen Views to record page and screen navigation events.
  • Use Capturing Logs to capture runtime logs and receive third-party logs into Ansight.
  • Use App Lifecycle to track foreground and background transitions.
  • Use Artifacts to expose app-owned diagnostic exports as discoverable, requestable files.
  • Use Tools to add VisualTree, reflection, database, file-system, preferences, secure-storage, or custom app-defined tools.

Tool Packages

Warning: Keep tool packages scoped to local development builds only.

Install tool packages separately only when you are using Ansight.Core. The all-in-one packages already include their respective tool sets.

Examples:

dotnet add package Ansight.Tools.VisualTree --prerelease
dotnet add package Ansight.Tools.Maui --prerelease
dotnet add package Ansight.Tools.Reflection --prerelease
dotnet add package Ansight.Tools.Database --prerelease

Available tool packages:

ToolPackageNuGet
VisualTreeAnsight.Tools.VisualTreeNuGet
MAUIAnsight.Tools.MauiNuGet
ReflectionAnsight.Tools.ReflectionNuGet
DatabaseAnsight.Tools.DatabaseNuGet
FileSystemAnsight.Tools.FileSystemNuGet
PreferencesAnsight.Tools.PreferencesNuGet
SecureStorageAnsight.Tools.SecureStorageNuGet