dotnet/maui · error · BuildException

XC0063

XC0063

Error message

Multi-valued enums are not valid on sbyte enum types.

What it means

Thrown by the XAML compiler (XamlC) when a XAML attribute assigns a comma-separated (flags-style) list of values to an enum whose underlying type is sbyte. The compiler accumulates multi-valued enums with bitwise OR for the byte/short/int/long families, but for sbyte it only assigns a single value (sb = ...), so a second matched value is rejected to avoid silently dropping the first.

Source

Thrown at src/Controls/src/Build.Tasks/NodeILExtensions.cs:379

			if (typeRef == null)
				throw new ArgumentException();

			foreach (var v in value.Split(','))
			{
				foreach (var field in enumDef.Fields)
				{
					if (field.Name == "value__")
						continue;
					if (field.Name == v.Trim())
					{
						switch (typeRef.FullName)
						{
							case "System.Byte":
								b |= (byte)field.Constant;
								break;
							case "System.SByte":
								if (found)
									throw new BuildException(BuildExceptionCode.SByteEnums, lineInfo, null);
								sb = (sbyte)field.Constant;
								break;
							case "System.Int16":
								s |= (short)field.Constant;
								break;
							case "System.UInt16":
								us |= (ushort)field.Constant;
								break;
							case "System.Int32":
								i |= (int)field.Constant;
								break;
							case "System.UInt32":
								ui |= (uint)field.Constant;
								break;
							case "System.Int64":
								l |= (long)field.Constant;
								break;
							case "System.UInt64":

View on GitHub (pinned to f377ff1c5e)

Solutions

  1. Remove the comma and use a single enum member value.
  2. If you genuinely need flag combination, change the enum's underlying type to one that supports OR-accumulation (byte, short, int, uint, long, ulong).
  3. Avoid sbyte as the underlying type for any enum you intend to combine in XAML.

Example fix

// before
<View Flags="Read,Write" />

// after (single value, or change underlying type)
<View Flags="ReadWrite" />
Defensive patterns

Strategy: validation

Validate before calling

// Before combining enum values in XAML, ensure the enum is NOT sbyte-backed
static bool CanCombineInXaml(Type enumType)
    => Enum.GetUnderlyingType(enumType) != typeof(sbyte);

// usage: if (!CanCombineInXaml(typeof(MyFlags))) /* don't write "A,B" */

Type guard

static bool IsSByteEnum(Type t) => t.IsEnum && Enum.GetUnderlyingType(t) == typeof(sbyte);

Prevention

When it happens

Trigger: An enum declared as `enum X : sbyte { A, B }` is used in XAML as `Property="A,B"` (or any other multi-member form). On the second matched field, the `found` flag is already true and BuildExceptionCode.SByteEnums is thrown.

Common situations: A developer copies a `[Flags] enum : byte` and changes the underlying type to sbyte; or lists multiple enum members for a property backed by an sbyte enum.

Related errors


AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13). Data as JSON: /api/errors/4ca1b0da136672c7. Report an issue: GitHub.