unoplatform/uno · error · ArgumentNullException

type

Error message

type

What it means

GetTSType converts a Roslyn ITypeSymbol into its TypeScript type name for the WebAssembly Emscripten (EM) interop bindings that Uno generates from C# structs. It throws ArgumentNullException(nameof(type)) — which surfaces as the bare message 'type' — when the type symbol passed in is null. A null symbol normally means a struct field's type could not be resolved by the Roslyn compilation, e.g. the field type lives in an assembly that is not referenced, or a recursive GetTSType(array.ElementType) received an unresolved element type.

Source

Thrown at src/SourceGenerators/Uno.UI.SourceGenerators.Internal/TSBindings/TSBindingsGenerator.cs:521

			else if (fieldType.SpecialType == SpecialType.System_Single)
			{
				return "HEAPF32";
			}
			else if (fieldType.SpecialType == SpecialType.System_Double)
			{
				return "HEAPF64";
			}
			else
			{
				throw new NotSupportedException($"Unsupported EM type conversion [{fieldType}]");
			}
		}

		private static string GetTSType(ITypeSymbol type)
		{
			if (type == null)
			{
				throw new ArgumentNullException(nameof(type));
			}

			if (type is IArrayTypeSymbol array)
			{
				return $"Array<{GetTSType(array.ElementType)}>";
			}
			else if (type.SpecialType == SpecialType.System_String)
			{
				return "String";
			}
			else if (
				type.SpecialType == SpecialType.System_Int32 ||
				type.SpecialType == SpecialType.System_UInt32 ||
				type.SpecialType == SpecialType.System_Single ||
				type.SpecialType == SpecialType.System_Double ||
				type.SpecialType == SpecialType.System_Byte ||
				type.SpecialType == SpecialType.System_Int16 ||
				type.SpecialType == SpecialType.System_IntPtr ||

View on GitHub (pinned to 0418340488)

Solutions

  1. Locate the struct/field named in the build error and ensure the assembly declaring that field's type is referenced by the project.
  2. Run dotnet restore then rebuild so the Roslyn compilation can resolve every field type.
  3. If the field type is not meant for WASM interop, replace it with a supported primitive or move the struct out of the EM-bindings set.

Example fix

// before
public struct MyInteropData { public CustomType Value; } // CustomType unresolved
// after
public struct MyInteropData { public int Value; }
Defensive patterns

Strategy: validation

Validate before calling

// Before exposing a struct to WASM EM bindings, ensure every field type is resolvable
// by referencing the declaring assemblies. A practical pre-flight (unit test):
foreach (var f in typeof(MyInteropData).GetFields())
{
    if (f.FieldType == null) throw new InvalidOperationException($"{f.Name}: unresolved type");
}

Prevention

When it happens

Trigger: The generator calls GetTSType(field.Type) on a field of a struct being processed for EM bindings (TSBindingsGenerator.cs:317/333) or GetTSType(elementType) for array elements (TSBindingsGenerator.cs:273), and that ITypeSymbol resolves to null.

Common situations: Adding a WASM-interop struct whose fields reference a type from an assembly the generator project does not reference; a broken/incomplete NuGet restore leaving the Roslyn compilation unable to bind a field type.

Related errors


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