unoplatform/uno · error · NotSupportedException

GetTSFieldType: The type {type} is not supported (SpecialTyp

Error message

GetTSFieldType: The type {type} is not supported (SpecialType: {type.SpecialType}, original type: {type.OriginalDefinition})

What it means

GetTSFieldType emits lowercase TS types (string/number/boolean) for struct fields in the EM bindings. It throws NotSupportedException for any type outside its allow-list (string, numeric primitives, IntPtr/UIntPtr, bool, arrays), including the SpecialType and OriginalDefinition in the message for diagnosis.

Source

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

				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 ||
				type.SpecialType == SpecialType.System_UIntPtr
			)
			{
				return "number";
			}
			else if (type.SpecialType == SpecialType.System_Boolean)
			{
				return "boolean";
			}
			else
			{
				throw new NotSupportedException($"GetTSFieldType: The type {type} is not supported (SpecialType: {type.SpecialType}, original type: {type.OriginalDefinition})");
			}
		}

	}
}

View on GitHub (pinned to 0418340488)

Solutions

  1. Change the offending field (named via its SpecialType/OriginalDefinition) to a supported primitive or an array of one.
  2. Serialize complex types to a supported primitive before exposing them.
  3. Remove the struct from TS binding generation if the type cannot be represented.

Example fix

// before
public struct MyInteropData { public MyEnum State; }
// after
public struct MyInteropData { public int State; }
Defensive patterns

Strategy: type-guard

Type guard

static bool IsSupportedEmFieldType(Type t)
{
    var set = new HashSet<Type>
    {
        typeof(string), typeof(int), typeof(uint), typeof(float), typeof(double),
        typeof(byte), typeof(short), typeof(IntPtr), typeof(UIntPtr), typeof(bool)
    };
    return set.Contains(t) || (t.IsArray && IsSupportedEmFieldType(t.GetElementType()));
}

Prevention

When it happens

Trigger: A struct field exposed for EM bindings has a type outside the supported set: enum, custom value type, decimal, DateTime, Guid, Nullable<T>, etc.

Common situations: Adding a field of an unsupported type to an EM-bound struct; switching a field from int to an enum or decimal.

Related errors


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