# Xui.Core.Debug

Assembly: **Xui.Core** · [C# declarations](index.cs) · [Assembly overview](../index.md)

## Types

- [`interface IInstruments`](#api-6ad1a12ab69efd49)
- [`interface IInstrumentsSink`](#api-8d33d8977a2800b2)
- [`interface IRenderSurfaceInstrumentsSink`](#api-d498bc33674231f0)
- [`interface IViewInstrumentsSink`](#api-ccad9617d605a5a4)
- [`class Instruments`](#api-80ea4c356cfc91a1)
- [`readonly struct InstrumentsAccessor`](#api-f1b408070667d7b0)
- [`class InstrumentsAccessorExtensions`](#api-100a939cbbccc0e5)
- [`ref struct InstrumentsInterpolatedStringHandler`](#api-1bc24f1a6c22d8e5)
- [`enum LevelOfDetail`](#api-c3e8b593462bcb09)
- [`enum Scope`](#api-296e83a2604caaeb)
- [`ref struct TraceScope`](#api-1823ca65459ac1c6)

<a id="api-6ad1a12ab69efd49"></a>

## `interface IInstruments`

Factory interface for creating instrumentation sinks. Register in the DI container at startup. Implementations are swappable (console, file, network, E2E test).

```csharp
public interface IInstruments
{
    IInstrumentsSink CreateSink();
}
```

<a id="api-863175e356565c1e"></a>

### [`IInstrumentsSink IInstruments.CreateSink()`](#api-863175e356565c1e)


```csharp
IInstrumentsSink CreateSink();
```

Creates a new per-run-loop sink for receiving instrumentation events.


<a id="api-8d33d8977a2800b2"></a>

## `interface IInstrumentsSink`

Per-run-loop instrumentation sink that receives fully-formatted messages. Thread-aligned — must not be shared across run loops or threads.

```csharp
public interface IInstrumentsSink : IViewInstrumentsSink, IDisposable
{
    IRenderSurfaceInstrumentsSink CreateRenderSurface(string name);
    bool IsEnabled(IRenderSurfaceInstrumentsSink surface, Scope scope, LevelOfDetail lod);
    void TrackView(IRenderSurfaceInstrumentsSink surface, Scope scope, View view);
    void TrackTextMeasure(IRenderSurfaceInstrumentsSink surface, long elapsedTicks);
    void Log(IRenderSurfaceInstrumentsSink surface, Scope scope, LevelOfDetail lod, ReadOnlySpan<char> message);
    void BeginTrace(IRenderSurfaceInstrumentsSink surface, Scope scope, LevelOfDetail lod, ReadOnlySpan<char> message);
    void EndTrace(IRenderSurfaceInstrumentsSink surface);
}
```

<a id="api-bbdb6cf3f6ffb62c"></a>

### [`void IInstrumentsSink.BeginTrace(IRenderSurfaceInstrumentsSink surface, Scope scope, LevelOfDetail lod, ReadOnlySpan<char> message)`](#api-bbdb6cf3f6ffb62c)


```csharp
void BeginTrace(IRenderSurfaceInstrumentsSink surface, Scope scope, LevelOfDetail lod, ReadOnlySpan<char> message);
```

Begins a named trace scope. Must be paired with [`Xui.Core.Debug.IViewInstrumentsSink.EndTrace`](../xui-core-debug/index.md#api-8c762fa5c854edd5).

<a id="api-7281cdc556495089"></a>

### [`IRenderSurfaceInstrumentsSink IInstrumentsSink.CreateRenderSurface(string name)`](#api-7281cdc556495089)


```csharp
IRenderSurfaceInstrumentsSink CreateRenderSurface(string name);
```

Creates a dedicated sink for one window, popup, or other render surface.

<a id="api-ff44b1026b8f7f34"></a>

### [`void IInstrumentsSink.EndTrace(IRenderSurfaceInstrumentsSink surface)`](#api-ff44b1026b8f7f34)


```csharp
void EndTrace(IRenderSurfaceInstrumentsSink surface);
```

Ends the most recently opened trace scope.

<a id="api-a71511c03745bb03"></a>

### [`bool IInstrumentsSink.IsEnabled(IRenderSurfaceInstrumentsSink surface, Scope scope, LevelOfDetail lod)`](#api-a71511c03745bb03)


```csharp
bool IsEnabled(IRenderSurfaceInstrumentsSink surface, Scope scope, LevelOfDetail lod);
```

Writes a surface event while retaining its source identity for aggregation.

<a id="api-f5c864a9388d75f6"></a>

### [`void IInstrumentsSink.Log(IRenderSurfaceInstrumentsSink surface, Scope scope, LevelOfDetail lod, ReadOnlySpan<char> message)`](#api-f5c864a9388d75f6)


```csharp
void Log(IRenderSurfaceInstrumentsSink surface, Scope scope, LevelOfDetail lod, ReadOnlySpan<char> message);
```

Writes a single log message to the sink.

<a id="api-24dbd46d3aa52009"></a>

### [`void IInstrumentsSink.TrackTextMeasure(IRenderSurfaceInstrumentsSink surface, long elapsedTicks)`](#api-24dbd46d3aa52009)


```csharp
void TrackTextMeasure(IRenderSurfaceInstrumentsSink surface, long elapsedTicks);
```

Reports one text measurement and the elapsed underlying-context ticks.

<a id="api-c65ba196ddb87a91"></a>

### [`void IInstrumentsSink.TrackView(IRenderSurfaceInstrumentsSink surface, Scope scope, View view)`](#api-c65ba196ddb87a91)


```csharp
void TrackView(IRenderSurfaceInstrumentsSink surface, Scope scope, View view);
```

Reports structured traversal of a view in the specified scope.


<a id="api-d498bc33674231f0"></a>

## `interface IRenderSurfaceInstrumentsSink`

Per-surface instrumentation sink. A window or native popup owns one instance; its view tree receives it through [`Xui.Core.Debug.IViewInstrumentsSink`](../xui-core-debug/index.md#api-ccad9617d605a5a4).

```csharp
public interface IRenderSurfaceInstrumentsSink : IViewInstrumentsSink, IDisposable
{
    string Name { get; }

    void BeginFrame();
    void EndFrame();
}
```

<a id="api-81ad08fb41804fc6"></a>

### [`void IRenderSurfaceInstrumentsSink.BeginFrame()`](#api-81ad08fb41804fc6)


```csharp
void BeginFrame();
```

Begins one update frame for this render surface.

<a id="api-5b4d476787e2abdf"></a>

### [`void IRenderSurfaceInstrumentsSink.EndFrame()`](#api-5b4d476787e2abdf)


```csharp
void EndFrame();
```

Completes one update frame for this render surface.

<a id="api-a61bfbc9e39f65dc"></a>

### [`string IRenderSurfaceInstrumentsSink.Name`](#api-a61bfbc9e39f65dc)


```csharp
string Name { get; }
```

Stable diagnostic name of the surface, such as its owning window type.


<a id="api-ccad9617d605a5a4"></a>

## `interface IViewInstrumentsSink`

Instrumentation API exposed to a visual tree. A view receives one instance for the render surface that owns its tree.

```csharp
public interface IViewInstrumentsSink
{
    bool IsEnabled(Scope scope, LevelOfDetail lod);
    void TrackView(Scope scope, View view);
    void TrackTextMeasure(long elapsedTicks);
    void Log(Scope scope, LevelOfDetail lod, ReadOnlySpan<char> message);
    void BeginTrace(Scope scope, LevelOfDetail lod, ReadOnlySpan<char> message);
    void EndTrace();
}
```

<a id="api-c0bed6704fe11ca0"></a>

### [`void IViewInstrumentsSink.BeginTrace(Scope scope, LevelOfDetail lod, ReadOnlySpan<char> message)`](#api-c0bed6704fe11ca0)


```csharp
void BeginTrace(Scope scope, LevelOfDetail lod, ReadOnlySpan<char> message);
```

Begins a named trace scope. Must be paired with [`Xui.Core.Debug.IViewInstrumentsSink.EndTrace`](../xui-core-debug/index.md#api-8c762fa5c854edd5).

<a id="api-8c762fa5c854edd5"></a>

### [`void IViewInstrumentsSink.EndTrace()`](#api-8c762fa5c854edd5)


```csharp
void EndTrace();
```

Ends the most recently opened trace scope.

<a id="api-a42ea2d19dfb36fa"></a>

### [`bool IViewInstrumentsSink.IsEnabled(Scope scope, LevelOfDetail lod)`](#api-a42ea2d19dfb36fa)


```csharp
bool IsEnabled(Scope scope, LevelOfDetail lod);
```

Returns `true` if this sink should receive events at the given scope and level of detail.

<a id="api-a0764e18e784fc71"></a>

### [`void IViewInstrumentsSink.Log(Scope scope, LevelOfDetail lod, ReadOnlySpan<char> message)`](#api-a0764e18e784fc71)


```csharp
void Log(Scope scope, LevelOfDetail lod, ReadOnlySpan<char> message);
```

Writes a single log message to the sink.

<a id="api-3c861232fed2c7dd"></a>

### [`void IViewInstrumentsSink.TrackTextMeasure(long elapsedTicks)`](#api-3c861232fed2c7dd)


```csharp
void TrackTextMeasure(long elapsedTicks);
```

Reports one text measurement and the elapsed underlying-context ticks.

<a id="api-6af7a71198863106"></a>

### [`void IViewInstrumentsSink.TrackView(Scope scope, View view)`](#api-6af7a71198863106)


```csharp
void TrackView(Scope scope, View view);
```

Reports structured traversal of a view in the specified scope.


<a id="api-80ea4c356cfc91a1"></a>

## `class Instruments`

Factory for creating instrumentation sinks.

```csharp
public static partial class Instruments
{
}
public static partial class Instruments
{
    public static IInstruments File(string path);
}
public static partial class Instruments
{
    public static readonly IInstruments Console;
}
```

<a id="api-7ab23b4cd5f6081a"></a>

### [`IInstruments Instruments.Console`](#api-7ab23b4cd5f6081a)


```csharp
public static readonly IInstruments Console;
```

Returns an instrumentation sink that writes to the console.

<a id="api-b0e0de35537cb43b"></a>

### [`IInstruments Instruments.File(string path)`](#api-b0e0de35537cb43b)


```csharp
public static IInstruments File(string path);
```

Returns an instrumentation sink that writes to a file at the given path.

- **`path`** — The path of the log file to write to.


<a id="api-f1b408070667d7b0"></a>

## `readonly struct InstrumentsAccessor`

Lightweight zero-allocation facade over an [`Xui.Core.Debug.IInstrumentsSink`](../xui-core-debug/index.md#api-8d33d8977a2800b2) for logging and tracing. All formatting is skipped when the sink is disabled for the given scope and level.

```csharp
public readonly struct InstrumentsAccessor
{
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public InstrumentsAccessor(IViewInstrumentsSink? sink);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void BeginFrame();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void EndFrame();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void TrackView(Scope scope, View view);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void TrackTextMeasure(long elapsedTicks);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void Log(Scope scope, LevelOfDetail lod, [InterpolatedStringHandlerArgument("", "scope", "lod")] ref InstrumentsInterpolatedStringHandler message);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public TraceScope Trace(Scope scope, LevelOfDetail lod, [InterpolatedStringHandlerArgument("", "scope", "lod")] ref InstrumentsInterpolatedStringHandler message);
}
```

<a id="api-f45d2b68028dfd24"></a>

### [`InstrumentsAccessor.InstrumentsAccessor(IViewInstrumentsSink? sink)`](#api-f45d2b68028dfd24)


```csharp
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public InstrumentsAccessor(IViewInstrumentsSink? sink);
```

Initializes a new accessor backed by the given sink.

- **`sink`** — The sink to write to, or `null` to produce a no-op accessor.

<a id="api-2da902a536c8024d"></a>

### [`void InstrumentsAccessor.BeginFrame()`](#api-2da902a536c8024d)


```csharp
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void BeginFrame();
```

Begins a render-surface update frame when supported by the current sink.

<a id="api-952c4b46c8127706"></a>

### [`void InstrumentsAccessor.EndFrame()`](#api-952c4b46c8127706)


```csharp
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void EndFrame();
```

Completes a render-surface update frame when supported by the current sink.

<a id="api-4abf89ac40722b24"></a>

### [`void InstrumentsAccessor.Log(Scope scope, LevelOfDetail lod, ref InstrumentsInterpolatedStringHandler message)`](#api-4abf89ac40722b24)


```csharp
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Log(Scope scope, LevelOfDetail lod, [InterpolatedStringHandlerArgument("", "scope", "lod")] ref InstrumentsInterpolatedStringHandler message);
```

Logs a formatted message at the given scope and level of detail.

- **`scope`** — The instrumentation scope.

- **`lod`** — The level of detail for filtering.

- **`message`** — The interpolated message string. Not evaluated when the sink is disabled.

<a id="api-862834c7ffa09bbe"></a>

### [`TraceScope InstrumentsAccessor.Trace(Scope scope, LevelOfDetail lod, ref InstrumentsInterpolatedStringHandler message)`](#api-862834c7ffa09bbe)


```csharp
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TraceScope Trace(Scope scope, LevelOfDetail lod, [InterpolatedStringHandlerArgument("", "scope", "lod")] ref InstrumentsInterpolatedStringHandler message);
```

Begins a named trace scope and returns a [`Xui.Core.Debug.TraceScope`](../xui-core-debug/index.md#api-1823ca65459ac1c6) that ends it when disposed.

- **`scope`** — The instrumentation scope.

- **`lod`** — The level of detail for filtering.

- **`message`** — The interpolated trace label. Not evaluated when the sink is disabled.

**Returns:** A [`Xui.Core.Debug.TraceScope`](../xui-core-debug/index.md#api-1823ca65459ac1c6) that calls [`Xui.Core.Debug.IInstrumentsSink.EndTrace(Xui.Core.Debug.IRenderSurfaceInstrumentsSink)`](../xui-core-debug/index.md#api-ff44b1026b8f7f34) on dispose.

<a id="api-49983d4f7b32d63c"></a>

### [`void InstrumentsAccessor.TrackTextMeasure(long elapsedTicks)`](#api-49983d4f7b32d63c)


```csharp
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void TrackTextMeasure(long elapsedTicks);
```

Reports an underlying text measurement without formatting a message.

<a id="api-a8a6087b73eb2ae2"></a>

### [`void InstrumentsAccessor.TrackView(Scope scope, View view)`](#api-a8a6087b73eb2ae2)


```csharp
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void TrackView(Scope scope, View view);
```

Reports structured traversal of `view` without formatting a message.


<a id="api-100a939cbbccc0e5"></a>

## `class InstrumentsAccessorExtensions`

Extension methods on [`Xui.Core.Debug.InstrumentsAccessor`](../xui-core-debug/index.md#api-f1b408070667d7b0) for visual tree diagnostics.

```csharp
public static class InstrumentsAccessorExtensions
{
    public static void DumpVisualTree(this InstrumentsAccessor instruments, View root, LevelOfDetail lod = LevelOfDetail.Info);
}
```

<a id="api-7400e4f8911fcd1d"></a>

### [`void InstrumentsAccessorExtensions.DumpVisualTree(InstrumentsAccessor instruments, View root, LevelOfDetail lod = LevelOfDetail.Info)`](#api-7400e4f8911fcd1d)


```csharp
public static void DumpVisualTree(this InstrumentsAccessor instruments, View root, LevelOfDetail lod = LevelOfDetail.Info);
```

Logs the full visual tree rooted at `root` at the given level of detail.

- **`instruments`** — The accessor to log through.

- **`root`** — The root view to dump.

- **`lod`** — The level of detail threshold.


<a id="api-1bc24f1a6c22d8e5"></a>

## `ref struct InstrumentsInterpolatedStringHandler`

Low-allocation interpolated string handler used by [`Xui.Core.Debug.InstrumentsAccessor.Log(Xui.Core.Debug.Scope,Xui.Core.Debug.LevelOfDetail,Xui.Core.Debug.InstrumentsInterpolatedStringHandler@)`](../xui-core-debug/index.md#api-4abf89ac40722b24) and [`Xui.Core.Debug.InstrumentsAccessor.Trace(Xui.Core.Debug.Scope,Xui.Core.Debug.LevelOfDetail,Xui.Core.Debug.InstrumentsInterpolatedStringHandler@)`](../xui-core-debug/index.md#api-862834c7ffa09bbe). The compiler selects this handler automatically when the sink is disabled, skipping all formatting entirely.

```csharp
[InterpolatedStringHandler]
public ref struct InstrumentsInterpolatedStringHandler
{
    public InstrumentsInterpolatedStringHandler(int literalLength, int formattedCount, InstrumentsAccessor accessor, Scope scope, LevelOfDetail lod, out bool shouldAppend);
    public void AppendLiteral(string s);
    public void AppendFormatted<T>(T value)
        where T : ISpanFormattable;
    public void AppendFormatted<T>(T value, ReadOnlySpan<char> format)
        where T : ISpanFormattable;
    public void AppendFormatted(ReadOnlySpan<char> value);
    public void AppendFormatted(string? value);
    public void AppendFormatted(object? value);
    public readonly ReadOnlySpan<char> AsSpan();
    public void Dispose();
}
```

<a id="api-c67a0bae80d8f81a"></a>

### [`InstrumentsInterpolatedStringHandler.InstrumentsInterpolatedStringHandler(int literalLength, int formattedCount, InstrumentsAccessor accessor, Scope scope, LevelOfDetail lod, out bool shouldAppend)`](#api-c67a0bae80d8f81a)


```csharp
public InstrumentsInterpolatedStringHandler(int literalLength, int formattedCount, InstrumentsAccessor accessor, Scope scope, LevelOfDetail lod, out bool shouldAppend);
```

Called by the compiler to initialize the handler and decide whether formatting is needed.

- **`literalLength`** — Total character count of all literal string segments.

- **`formattedCount`** — Number of interpolated holes in the string.

- **`accessor`** — The accessor used to check whether the sink is enabled.

- **`scope`** — The instrumentation scope.

- **`lod`** — The level of detail.

- **`shouldAppend`** — Set to `true` if formatting should proceed; `false` to skip.

<a id="api-24081bfeb97e1501"></a>

### [`void InstrumentsInterpolatedStringHandler.AppendFormatted(object? value)`](#api-24081bfeb97e1501)


```csharp
public void AppendFormatted(object? value);
```

Appends any object by calling `ToString()`.

<a id="api-b96ddf81740f14b8"></a>

### [`void InstrumentsInterpolatedStringHandler.AppendFormatted(ReadOnlySpan<char> value)`](#api-b96ddf81740f14b8)


```csharp
public void AppendFormatted(ReadOnlySpan<char> value);
```

Appends a `System.ReadOnlySpan`1` of characters directly.

<a id="api-7d6ac2e76fcfed57"></a>

### [`void InstrumentsInterpolatedStringHandler.AppendFormatted(string? value)`](#api-7d6ac2e76fcfed57)


```csharp
public void AppendFormatted(string? value);
```

Appends a string value.

<a id="api-80ee8130999f5f6f"></a>

### [`void InstrumentsInterpolatedStringHandler.AppendFormatted<T>(T value)`](#api-80ee8130999f5f6f)


```csharp
public void AppendFormatted<T>(T value)
    where T : ISpanFormattable;
```

Appends a span-formattable value using its default format.

<a id="api-7dc7cfb0b4418fcc"></a>

### [`void InstrumentsInterpolatedStringHandler.AppendFormatted<T>(T value, ReadOnlySpan<char> format)`](#api-7dc7cfb0b4418fcc)


```csharp
public void AppendFormatted<T>(T value, ReadOnlySpan<char> format)
    where T : ISpanFormattable;
```

Appends a span-formattable value using the specified format string.

<a id="api-8acbcc3287a3b2cc"></a>

### [`void InstrumentsInterpolatedStringHandler.AppendLiteral(string s)`](#api-8acbcc3287a3b2cc)


```csharp
public void AppendLiteral(string s);
```

Appends a literal string segment to the buffer.

<a id="api-187a35d04a604829"></a>

### [`readonly ReadOnlySpan<char> InstrumentsInterpolatedStringHandler.AsSpan()`](#api-187a35d04a604829)


```csharp
public readonly ReadOnlySpan<char> AsSpan();
```

Returns the currently accumulated characters as a read-only span.

<a id="api-f954003dd5f37699"></a>

### [`void InstrumentsInterpolatedStringHandler.Dispose()`](#api-f954003dd5f37699)


```csharp
public void Dispose();
```

Returns any rented array buffer back to the pool.


<a id="api-c3e8b593462bcb09"></a>

## `enum LevelOfDetail`

Controls the verbosity threshold for instrumentation output.

```csharp
public enum LevelOfDetail : uint
{
    Quiet = 0,
    Essential = 100,
    Normal = 200,
    Info = 300,
    Diagnostic = 400,
}
```

<a id="api-88f31e8aa1ad0f6f"></a>

### [`LevelOfDetail.Diagnostic`](#api-88f31e8aa1ad0f6f)


```csharp
Diagnostic = 400
```

Fine-grained diagnostic detail for debugging.

<a id="api-54692db5e214300e"></a>

### [`LevelOfDetail.Essential`](#api-54692db5e214300e)


```csharp
Essential = 100
```

Only the most critical events (start, stop, fatal errors).

<a id="api-f9fafdd26713e517"></a>

### [`LevelOfDetail.Info`](#api-f9fafdd26713e517)


```csharp
Info = 300
```

Additional informational context useful for understanding behavior.

<a id="api-49b174e15843f78b"></a>

### [`LevelOfDetail.Normal`](#api-49b174e15843f78b)


```csharp
Normal = 200
```

Standard operational events.

<a id="api-5be62ddebd3b3766"></a>

### [`LevelOfDetail.Quiet`](#api-5be62ddebd3b3766)


```csharp
Quiet = 0
```

No output. Silences all instrumentation.


<a id="api-296e83a2604caaeb"></a>

## `enum Scope`

Identifies the subsystem or category of an instrumentation event.

```csharp
[Flags]
public enum Scope : uint
{
    Application = 1 << 0,
    Input = 1 << 1,
    Rendering = 1 << 2,
    ViewLifecycle = 1 << 3,
    ViewAnimation = 1 << 4,
    ViewMeasure = 1 << 5,
    ViewArrange = 1 << 6,
    ViewRendering = 1 << 7,
    ViewState = 1 << 8,
}
```

<a id="api-8769d4fbf00304e2"></a>

### [`Scope.Application`](#api-8769d4fbf00304e2)


```csharp
Application = 1 << 0
```

Application lifecycle events (startup, shutdown, window open/close).

<a id="api-0dc6c8374860633d"></a>

### [`Scope.Input`](#api-0dc6c8374860633d)


```csharp
Input = 1 << 1
```

Input event processing (pointer, keyboard, touch).

<a id="api-a4a95abab81fc5ad"></a>

### [`Scope.Rendering`](#api-a4a95abab81fc5ad)


```csharp
Rendering = 1 << 2
```

Top-level rendering pipeline events.

<a id="api-7a688507d4311b04"></a>

### [`Scope.ViewAnimation`](#api-7a688507d4311b04)


```csharp
ViewAnimation = 1 << 4
```

View animation frame callbacks.

<a id="api-8c8b649f84a906ed"></a>

### [`Scope.ViewArrange`](#api-8c8b649f84a906ed)


```csharp
ViewArrange = 1 << 6
```

View arrange pass events.

<a id="api-a992eaefc955d60e"></a>

### [`Scope.ViewLifecycle`](#api-a992eaefc955d60e)


```csharp
ViewLifecycle = 1 << 3
```

View attach, detach, activate, and deactivate events.

<a id="api-3e2c53938f75d4e4"></a>

### [`Scope.ViewMeasure`](#api-3e2c53938f75d4e4)


```csharp
ViewMeasure = 1 << 5
```

View measure pass events.

<a id="api-c11b74d6425a30f4"></a>

### [`Scope.ViewRendering`](#api-c11b74d6425a30f4)


```csharp
ViewRendering = 1 << 7
```

View render pass events.

<a id="api-4bade1c3d2152688"></a>

### [`Scope.ViewState`](#api-4bade1c3d2152688)


```csharp
ViewState = 1 << 8
```

View state changes (invalidation, focus, flags).


<a id="api-1823ca65459ac1c6"></a>

## `ref struct TraceScope`

A ref struct returned by [`Xui.Core.Debug.InstrumentsAccessor.Trace(Xui.Core.Debug.Scope,Xui.Core.Debug.LevelOfDetail,Xui.Core.Debug.InstrumentsInterpolatedStringHandler@)`](../xui-core-debug/index.md#api-862834c7ffa09bbe) that closes the active trace scope when disposed. Intended for use with `using`.

```csharp
public ref struct TraceScope : IDisposable
{
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public TraceScope(IViewInstrumentsSink? sink);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void Dispose();
}
```

<a id="api-9f84c51f3b226d3e"></a>

### [`TraceScope.TraceScope(IViewInstrumentsSink? sink)`](#api-9f84c51f3b226d3e)


```csharp
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TraceScope(IViewInstrumentsSink? sink);
```

Initializes a new [`Xui.Core.Debug.TraceScope`](../xui-core-debug/index.md#api-1823ca65459ac1c6) that will call [`Xui.Core.Debug.IInstrumentsSink.EndTrace(Xui.Core.Debug.IRenderSurfaceInstrumentsSink)`](../xui-core-debug/index.md#api-ff44b1026b8f7f34) on the given sink when disposed.

- **`sink`** — The sink to notify on dispose, or `null` for a no-op scope.

<a id="api-5fe502c138950d0d"></a>

### [`void TraceScope.Dispose()`](#api-5fe502c138950d0d)


```csharp
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Dispose();
```

Ends the active trace scope on the sink.

