unoplatform/uno · error · ArgumentNullException

schemaContext

Error message

schemaContext

What it means

Thrown by the XamlNodeQueue constructor when schemaContext is null. XamlNodeQueue is an in-memory FIFO of XAML nodes used to bridge a XamlWriter and a XamlReader; it requires a XamlSchemaContext to give the nodes type identity, so a null context is rejected with ArgumentNullException.

Source

Thrown at src/SourceGenerators/System.Xaml/System.Xaml/XamlNodeQueue.cs:41

using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Windows.Markup;

namespace Uno.Xaml
{
	public class XamlNodeQueue
	{
		Queue<XamlNodeLineInfo> queue = new Queue<XamlNodeLineInfo> ();
		XamlSchemaContext ctx;
		XamlReader reader;
		XamlWriter writer;

		public XamlNodeQueue (XamlSchemaContext schemaContext)
		{
			if (schemaContext == null)
				throw new ArgumentNullException ("schemaContext");
			this.ctx = schemaContext;
			reader = new XamlNodeQueueReader (this);
			writer = new XamlNodeQueueWriter (this);
		}
		
		internal IXamlLineInfo LineInfoProvider { get; set; }

		internal XamlSchemaContext SchemaContext {
			get { return ctx; }
		}

		public int Count {
			get { return queue.Count; }
		}

		public bool IsEmpty {
			get { return queue.Count == 0; }
		}

View on GitHub (pinned to 0418340488)

Solutions

  1. Pass a valid XamlSchemaContext: new XamlNodeQueue(new XamlSchemaContext()).
  2. Reuse an existing schema context from your reader/writer rather than passing null.
  3. Add a null guard before construction and create a default context if needed.

Example fix

// before
var queue = new XamlNodeQueue(schemaContext); // schemaContext is null

// after
var queue = new XamlNodeQueue(schemaContext ?? new XamlSchemaContext());
Defensive patterns

Strategy: validation

Validate before calling

var ctx = schemaContext ?? new XamlSchemaContext();
var queue = new XamlNodeQueue(ctx);

Try / catch

try { var q = new XamlNodeQueue(sctx); }
catch (ArgumentNullException) { var q = new XamlNodeQueue(new XamlSchemaContext()); }

Prevention

When it happens

Trigger: Constructing new XamlNodeQueue(null). This typically happens when code passes a schema context variable that was never initialized or was conditionally set to null.

Common situations: XAML writer-to-reader bridging code (e.g. XamlWriter back into XamlReader) where the schema context comes from an optional field or a factory that returned null. Pipeline construction that omits the schema context argument.

Related errors


AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13). Data as JSON: /api/errors/d552e3b0022bbc0b. Report an issue: GitHub.