{"record":{"id":"5a6c3beab3d1e1d3","repo":"dotnet/maui","slug":"xc0043","errorCode":"XC0043","errorMessage":"Binding: Unsupported indexer index type: \"{0}\".","messagePattern":"Binding: Unsupported indexer index type: \"(.+?)\"\\.","errorType":"exception","errorClass":"BuildException","httpStatus":null,"severity":"error","filePath":"src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs","lineNumber":904,"sourceCode":"\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t&& pd.GetMethod != null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t&& TypeRefComparer.Default.Equals(pd.GetMethod.Parameters[0].ParameterType.ResolveGenericParameters(previousPartTypeRef), module.ImportReference(context.Cache, (\"mscorlib\", \"System\", \"Object\")))\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t&& pd.GetMethod.IsPublic, out indexerDeclTypeRef);\n\t\t\t\t\t// Try to find an indexer with an enum parameter type\n\t\t\t\t\tindexer ??= previousPartTypeRef.GetProperty(context.Cache,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpd => pd.Name == indexerName\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t&& pd.GetMethod != null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t&& pd.GetMethod.Parameters[0].ParameterType.ResolveGenericParameters(previousPartTypeRef).ResolveCached(context.Cache)?.IsEnum == true\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t&& pd.GetMethod.IsPublic, out indexerDeclTypeRef);\n\n\t\t\t\t\tproperties.Add((indexer, indexerDeclTypeRef, indexArg));\n\t\t\t\t\tif (indexer != null) //the case when we index on an array, not a list\n\t\t\t\t\t{\n\t\t\t\t\t\tvar indexType = indexer.GetMethod.Parameters[0].ParameterType.ResolveGenericParameters(indexerDeclTypeRef);\n\t\t\t\t\t\tvar indexTypeDef = indexType.ResolveCached(context.Cache);\n\t\t\t\t\t\tif (!TypeRefComparer.Default.Equals(indexType, module.TypeSystem.String) \n\t\t\t\t\t\t\t&& !TypeRefComparer.Default.Equals(indexType, module.TypeSystem.Int32)\n\t\t\t\t\t\t\t&& indexTypeDef?.IsEnum != true)\n\t\t\t\t\t\t\tthrow new BuildException(BindingIndexerTypeUnsupported, lineInfo, null, indexType.FullName);\n\t\t\t\t\t\tpreviousPartTypeRef = indexer.PropertyType.ResolveGenericParameters(indexerDeclTypeRef);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tif (previousPartTypeRef.IsArray)\n\t\t\t\t\t\t\tpreviousPartTypeRef = previousPartTypeRef.GetElementType();\n\n\t\t\t\t\t\tpreviousPartTypeRef.ResolveCached(context.Cache);\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t}\n\t\t\tpathProperties = properties;\n\t\t\treturn true;\n\t\t}\n\n\t\tstatic IEnumerable<Instruction> DigProperties(IEnumerable<(PropertyDefinition property, TypeReference propDeclTypeRef, string indexArg)> properties, Dictionary<TypeReference, VariableDefinition> locs, Func<Instruction> fallback, IXmlLineInfo lineInfo, ModuleDefinition module, XamlCache cache = null)\n\t\t{","sourceCodeStart":886,"sourceCodeEnd":922,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs#L886-L922","documentation":"Thrown when a compiled-binding indexer is resolved but its parameter type is neither string, Int32, nor an enum. The compiler only knows how to emit index lookups for those key types, so any other key type (Guid, double, custom struct, etc.) is rejected.","triggerScenarios":"Binding to an indexer whose key type is unsupported, e.g. `{Binding Map[someGuid]}` where the indexer is keyed by Guid.","commonSituations":"Using a dictionary keyed by a non-primitive/custom type in a compiled binding; exposing an indexer with an unusual parameter type.","solutions":["Expose or bind to a string-, int-, or enum-keyed indexer instead.","Reshape the source so the data is reachable via a property or a supported key.","Fall back to a non-compiled (reflection) binding by removing x:DataType from that element."],"exampleFix":"<!-- before (Guid-keyed indexer, unsupported) -->\n<Label Text=\"{Binding Items[item.Guid], x:DataType=vm:Vm}\" />\n\n<!-- after: use a string key -->\n<Label Text=\"{Binding Items[item.Key], x:DataType=vm:Vm}\" />","handlingStrategy":"validation","validationCode":"// Compiled bindings support only string/int/enum indexer keys\nstatic bool IsSupportedIndexKey(Type keyType)\n    => keyType == typeof(string) || keyType == typeof(int) || keyType.IsEnum;","typeGuard":"static bool IsCompiledBindingIndexable(Type collectionType, out Type keyType)\n{\n    keyType = collectionType.GetDefaultMembers()?.SelectMany(\n        t => collectionType.GetProperties().Where(p => p.GetIndexParameters().Length == 1))\n        .Select(p => p.GetIndexParameters()[0].ParameterType).FirstOrDefault();\n    return keyType != null && IsSupportedIndexKey(keyType);\n}","tryCatchPattern":null,"preventionTips":["Expose string/int/enum-keyed indexers for compiled-binding sources.","Avoid Guid/double/custom-struct keys when using x:DataType.","If you must use unsupported keys, omit x:DataType to use reflection binding."],"tags":["xaml","xamlc","compiled-bindings","indexer","binding-path"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}