{"record":{"id":"8495055001dc446d","repo":"dotnet/maui","slug":"xc0003-849505","errorCode":"XC0003","errorMessage":"Missing mandatory property \"{0}\" on \"{1}\".","messagePattern":"Missing mandatory property \"(.+?)\" on \"(.+?)\"\\.","errorType":"exception","errorClass":"BuildException","httpStatus":null,"severity":"error","filePath":"src/Controls/src/Build.Tasks/CreateObjectVisitor.cs","lineNumber":168,"sourceCode":"\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t md.HasParameters &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t md.Parameters.All(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t pd =>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t pd.CustomAttributes.Any(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ca =>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ca.AttributeType.FullName ==\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \"Microsoft.Maui.Controls.ParameterAttribute\")));\n\t\t\t}\n\t\t\tstring missingCtorParameter = null;\n\t\t\tif (parameterizedCtorInfo != null && ValidateCtorArguments(parameterizedCtorInfo, node, out missingCtorParameter))\n\t\t\t{\n\t\t\t\tctorInfo = parameterizedCtorInfo;\n\t\t\t\t//\t\t\t\tIL_0000:  ldstr \"foo\"\n\t\t\t\tContext.IL.Append(PushCtorArguments(parameterizedCtorInfo.ResolveGenericParameters(typeref, Module), node));\n\t\t\t}\n\t\t\tctorInfo ??= typedef.Methods.FirstOrDefault(md => md.IsConstructor && !md.HasParameters && !md.IsStatic);\n\t\t\tif (parameterizedCtorInfo != null && ctorInfo == null)\n\t\t\t\t//there was a parameterized ctor, we didn't use it\n\t\t\t\tthrow new BuildException(BuildExceptionCode.PropertyMissing, node, null, missingCtorParameter, typedef.FullName);\n\t\t\tvar ctorinforef = ctorInfo?.ResolveGenericParameters(typeref, Module);\n\t\t\tvar factorymethodinforef = factoryMethodInfo?.ResolveGenericParameters(typeref, Module);\n\t\t\tvar implicitOperatorref = typedef.Methods.FirstOrDefault(md =>\n\t\t\t\tmd.IsPublic &&\n\t\t\t\tmd.IsStatic &&\n\t\t\t\tmd.IsSpecialName &&\n\t\t\t\tmd.Name == \"op_Implicit\" && md.Parameters[0].ParameterType.FullName == \"System.String\");\n\n\t\t\t// The old Forms.Color was a struct, so the following BuildException wasn't thrown because IsValueType returned true.\n\t\t\t// MGColor is a class, so IsValueType is false, but there's no parameterless constructor or factory; there's a \n\t\t\t// TypeConverter. So adding this bool as a check for this condition temporarily.\n\t\t\tbool isColor = typedef.FullName == \"Microsoft.Maui.Graphics.Color\";\n\n\t\t\tif (!isColor && !typedef.IsValueType && ctorInfo == null && factoryMethodInfo == null)\n\t\t\t{\n\t\t\t\tthrow new BuildException(BuildExceptionCode.ConstructorDefaultMissing, node, null, typedef.FullName);\n\t\t\t}\n","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Build.Tasks/CreateObjectVisitor.cs#L150-L186","documentation":"Thrown when a type exposes a parameterized constructor whose parameters are all decorated with [Parameter] (the Maui parameterized-ctor convention), ValidateCtorArguments flagged a missing mandatory parameter, and no parameterless fallback constructor exists. The message names the missing property and the type.","triggerScenarios":"Declaring an element in XAML but omitting a required [Parameter]-marked ctor argument; typo in the property name so it isn't recognized; the type relies solely on a parameterized ctor and the XAML didn't supply all params.","commonSituations":"Using Maui controls/types that require constructor arguments (e.g. certain gestures or custom controls); partial XAML where a required attribute was dropped during refactor.","solutions":["Add the missing property/attribute named in the error message to the element.","Check the type's [Parameter]-decorated constructor to see which properties are mandatory.","If the type is yours, add a parameterless constructor or make the parameter optional.","Fix any typos in property names so they bind to the [Parameter] arguments."],"exampleFix":"// before\n<MyControl />\n  <!-- MyControl(..) requires Text via [Parameter] -->\n// after\n<MyControl Text=\"Hello\" />","handlingStrategy":"validation","validationCode":"// List the [Parameter]-mandatory properties of a type's parameterized ctor\nstatic IEnumerable<string> MandatoryCtorParams(Type t) =>\n    t.GetConstructors()\n     .SelectMany(c => c.GetParameters()\n         .Where(p => p.GetCustomAttribute<ParameterAttribute>() != null)\n         .Select(p => p.Name!));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Document [Parameter]-required properties on XAML-usable types.","Supply all mandatory attributes in XAML, or add a parameterless ctor."],"tags":["xaml","xamlc","constructor","parameter-attribute","object-construction","build-time"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}