{"record":{"id":"5663fa7f008cec07","repo":"dotnet/maui","slug":"xc0008","errorCode":"XC0008","errorMessage":"No Add() method defined on \"{0}{1}\".","messagePattern":"No Add\\(\\) method defined on \"(.+?)(.+?)\"\\.","errorType":"exception","errorClass":"BuildException","httpStatus":null,"severity":"error","filePath":"src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs","lineNumber":188,"sourceCode":"\t\t\t\tvar parentList = node2;\n\t\t\t\tvar parent = Context.Variables[(ElementNode)parentList.Parent];\n\n\t\t\t\tif (skips.Contains(parentList.XmlName))\n\t\t\t\t\treturn;\n\t\t\t\tif (parentNode is ElementNode node3 && node3.SkipProperties.Contains(propertyName))\n\t\t\t\t\treturn;\n\t\t\t\tvar elementType = parent.VariableType;\n\t\t\t\tvar localname = parentList.XmlName.LocalName;\n\n\t\t\t\tContext.IL.Append(GetPropertyValue(parent, parentList.XmlName, Context, node, out TypeReference propertyType));\n\n\t\t\t\tif (CanAddToResourceDictionary(parent, propertyType, node, node, Context))\n\t\t\t\t{\n\t\t\t\t\tContext.IL.Append(AddToResourceDictionary(parent, node, node, Context));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tvar adderTuple = propertyType.GetMethods(Context.Cache, md => md.Name == \"Add\" && md.Parameters.Count == 1, Module).FirstOrDefault() ??\n\t\t\t\t\tthrow new BuildException(AdderMissing, node, null, parent.VariableType, localname);\n\n\t\t\t\tvar adderRef = Module.ImportReference(adderTuple.Item1);\n\t\t\t\tadderRef = Module.ImportReference(adderRef.ResolveGenericParameters(adderTuple.Item2, Module));\n\n\t\t\t\tContext.IL.Append(vardef.LoadAs(Context.Cache, adderRef.Parameters[0].ParameterType.ResolveGenericParameters(adderRef), Module));\n\t\t\t\tContext.IL.Emit(Callvirt, adderRef);\n\t\t\t\tif (adderRef.ReturnType.FullName != \"System.Void\")\n\t\t\t\t\tContext.IL.Emit(Pop);\n\t\t\t}\n\t\t}\n\n\t\tpublic void Visit(RootNode node, INode parentNode)\n\t\t{\n\t\t}\n\n\t\tpublic void Visit(ListNode node, INode parentNode)\n\t\t{\n\t\t}","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs#L170-L206","documentation":"Thrown for a ListNode (a property populated with multiple child elements) when the property's resolved type exposes no public single-parameter Add method. The compiler needs an Add(T) to emit each child-add call and throws when GetMethods finds none.","triggerScenarios":"A collection property whose type lacks Add(T) — e.g. the property is an array, a raw IEnumerable, or the type resolved to something unexpected — so `propertyType.GetMethods(... Add, 1 param)` returns null.","commonSituations":"Property declared as an array or IReadOnlyList without Add; property not initialised; the wrong generic type was resolved; ResourceDictionary path not matching.","solutions":["Make the property type a collection that exposes a public Add(T) (e.g. IList<T>, List<T>, ObservableCollection<T>).","Ensure the property is initialised to a concrete collection instance.","If targeting a ResourceDictionary, confirm the entry is in a ResourceDictionary context and has a valid key."],"exampleFix":"// before (no Add)\npublic string[] Items { get; set; }\n\n// after\npublic IList<string> Items { get; } = new List<string>();","handlingStrategy":"validation","validationCode":"// Ensure the collection property type has a public single-parameter Add\nstatic bool HasAddMethod(Type collectionType)\n    => collectionType.GetMethods()\n        .Any(m => m.Name == \"Add\" && m.IsPublic && m.GetParameters().Length == 1);","typeGuard":"static bool IsXamlCollection(Type t) =>\n    typeof(System.Collections.IEnumerable).IsAssignableFrom(t) && HasAddMethod(t);","tryCatchPattern":null,"preventionTips":["Prefer IList<T>/List<T>/ObservableCollection<T> for XAML-populated properties.","Initialise collection properties to concrete instances.","Avoid arrays or read-only interfaces without Add for XAML-bound collections."],"tags":["xaml","xamlc","collection","add-method"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}