{"record":{"id":"4ca1b0da136672c7","repo":"dotnet/maui","slug":"xc0063","errorCode":"XC0063","errorMessage":"Multi-valued enums are not valid on sbyte enum types.","messagePattern":"Multi-valued enums are not valid on sbyte enum types\\.","errorType":"exception","errorClass":"BuildException","httpStatus":null,"severity":"error","filePath":"src/Controls/src/Build.Tasks/NodeILExtensions.cs","lineNumber":379,"sourceCode":"\t\t\tif (typeRef == null)\n\t\t\t\tthrow new ArgumentException();\n\n\t\t\tforeach (var v in value.Split(','))\n\t\t\t{\n\t\t\t\tforeach (var field in enumDef.Fields)\n\t\t\t\t{\n\t\t\t\t\tif (field.Name == \"value__\")\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif (field.Name == v.Trim())\n\t\t\t\t\t{\n\t\t\t\t\t\tswitch (typeRef.FullName)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcase \"System.Byte\":\n\t\t\t\t\t\t\t\tb |= (byte)field.Constant;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase \"System.SByte\":\n\t\t\t\t\t\t\t\tif (found)\n\t\t\t\t\t\t\t\t\tthrow new BuildException(BuildExceptionCode.SByteEnums, lineInfo, null);\n\t\t\t\t\t\t\t\tsb = (sbyte)field.Constant;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase \"System.Int16\":\n\t\t\t\t\t\t\t\ts |= (short)field.Constant;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase \"System.UInt16\":\n\t\t\t\t\t\t\t\tus |= (ushort)field.Constant;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase \"System.Int32\":\n\t\t\t\t\t\t\t\ti |= (int)field.Constant;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase \"System.UInt32\":\n\t\t\t\t\t\t\t\tui |= (uint)field.Constant;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase \"System.Int64\":\n\t\t\t\t\t\t\t\tl |= (long)field.Constant;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase \"System.UInt64\":","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Build.Tasks/NodeILExtensions.cs#L361-L397","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Remove the comma and use a single enum member value.","If you genuinely need flag combination, change the enum's underlying type to one that supports OR-accumulation (byte, short, int, uint, long, ulong).","Avoid sbyte as the underlying type for any enum you intend to combine in XAML."],"exampleFix":"// before\n<View Flags=\"Read,Write\" />\n\n// after (single value, or change underlying type)\n<View Flags=\"ReadWrite\" />","handlingStrategy":"validation","validationCode":"// Before combining enum values in XAML, ensure the enum is NOT sbyte-backed\nstatic bool CanCombineInXaml(Type enumType)\n    => Enum.GetUnderlyingType(enumType) != typeof(sbyte);\n\n// usage: if (!CanCombineInXaml(typeof(MyFlags))) /* don't write \"A,B\" */","typeGuard":"static bool IsSByteEnum(Type t) => t.IsEnum && Enum.GetUnderlyingType(t) == typeof(sbyte);","tryCatchPattern":null,"preventionTips":["Never use sbyte as the underlying type for a flags enum used in XAML.","Prefer int or byte for enums you combine in markup.","Audit existing enums before listing multiple members in a single XAML attribute."],"tags":["xaml","xamlc","enum","flags","sbyte"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}