AvaloniaUI/Avalonia · info · ArgumentNullException
stack
Error message
stack
What it means
Constructor null guard in the internal StackDebugView<T> debugger proxy: `stack ?? throw new ArgumentNullException(nameof(stack))`. Like ICollectionDebugView, this is a DebuggerTypeProxy used by the IDE to render a PooledStack; it is not part of the user-facing runtime API. It only fires when the proxy is constructed for a null stack.
Source
Thrown at src/Avalonia.Base/Collections/Pooled/StackDebugView.cs:16
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics;
namespace Avalonia.Collections.Pooled
{
internal sealed class StackDebugView<T>
{
private readonly PooledStack<T> _stack;
public StackDebugView(PooledStack<T> stack)
{
_stack = stack ?? throw new ArgumentNullException(nameof(stack));
}
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
public T[] Items
{
get
{
return _stack.ToArray();
}
}
}
}
View on GitHub (pinned to 11c5427268)
Solutions
- Initialize the stack field so it is non-null before inspection.
- Ignore it — this originates from the debugger proxy, not your executed code path.
- In a test that builds the proxy directly, pass a non-null PooledStack.
Defensive patterns
Strategy: validation
Validate before calling
// Debugger-only proxy; ensure PooledStack fields are non-null before inspection. // No runtime validation path in product code.
Prevention
- Initialize PooledStack fields at declaration.
- Recognize StackDebugView throws are debugger-scoped, not runtime.
- Do not construct this internal proxy in product code.
When it happens
Trigger: The debugger instantiates StackDebugView for a PooledStack field/variable that is null while browsing Locals/Watch, or direct construction `new StackDebugView<T>(null)` in a test.
Common situations: Inspecting an uninitialized/null PooledStack field in the debugger; a debug session showing a stack before assignment. The throw is debugger-scoped and does not occur in a normal run.
Related errors
- collection
- array
- Destination span is shorter than the list to be copied.
- Stack was empty.
- Collection was modified during enumeration.
AI-assisted analysis of AvaloniaUI/Avalonia@11c5427268 (2026-08-13).
Data as JSON: /api/errors/02e8bd86e8348f25.
Report an issue: GitHub.