{"record":{"id":"131ad1f1962b9e5b","repo":"unoplatform/uno","slug":"name-property-is-not-set-131ad1","errorCode":null,"errorMessage":"Name property is not set","messagePattern":"Name property is not set","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/System.Xaml/System.Windows.Markup/Reference.cs","lineNumber":57,"sourceCode":"\n\t\tpublic Reference (string name)\n\t\t{\n\t\t\tName = name;\n\t\t}\n\n\t\t[ConstructorArgument (\"name\")]\n\t\tpublic string Name { get; set; }\n\n\t\tpublic override object ProvideValue (IServiceProvider serviceProvider)\n\t\t{\n\t\t\tif (serviceProvider == null)\n\t\t\t{\n\t\t\t\tthrow new ArgumentNullException (\"serviceProvider\");\n\t\t\t}\n\n\t\t\tif (Name == null)\n\t\t\t{\n\t\t\t\tthrow new InvalidOperationException (\"Name property is not set\");\n\t\t\t}\n\n\t\t\tvar r = serviceProvider.GetService (typeof (IXamlNameResolver)) as IXamlNameResolver;\n\t\t\tif (r == null)\n\t\t\t{\n\t\t\t\tthrow new InvalidOperationException (\"serviceProvider does not implement IXamlNameResolver\");\n\t\t\t}\n\n\t\t\tvar ret = r.Resolve (Name);\n\t\t\tif (ret == null)\n\t\t\t{\n\t\t\t\tret = r.GetFixupToken (new string [] {Name}, true);\n\t\t\t}\n\n\t\t\treturn ret;\n\t\t}\n\t}\n}","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/System.Xaml/System.Windows.Markup/Reference.cs#L39-L75","documentation":"InvalidOperationException thrown by Reference.ProvideValue (System.Xaml, ported from Mono) when the Name property is null. x:Reference resolves an element by name via IXamlNameResolver; without a name there is nothing to resolve. Name is normally supplied via the Reference(string name) constructor or the constructor argument in markup.","triggerScenarios":"Default-constructing Reference and calling ProvideValue without setting Name, or malformed x:Reference markup omitting the name.","commonSituations":"Programmatic construction that forgets the name, XAML where the x:Reference name attribute is missing/blank, or a binding producing null for the name.","solutions":["Supply Name via the Reference(string name) constructor or set the property before ProvideValue.","In XAML, ensure x:Reference has a name, e.g. {x:Reference MyElement}.","Guard at the call site: if (ref.Name is null) ref.Name = expectedName; before evaluation."],"exampleFix":"// before\nvar r = new Reference();\nr.ProvideValue(sp); // Name is null\n\n// after\nvar r = new Reference(\"MyElement\");\nr.ProvideValue(sp);","handlingStrategy":"validation","validationCode":"static Reference RequireName(Reference r) => r.Name is null ? throw new InvalidOperationException(\"Reference.Name is required.\") : r;","typeGuard":"static bool IsReady(Reference r) => !string.IsNullOrEmpty(r.Name);","tryCatchPattern":"try { return r.ProvideValue(sp); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"Name property is not set\")) { r.Name = fallbackName; return r.ProvideValue(sp); }","preventionTips":["Always construct Reference with the name argument.","Set Name explicitly when default-constructing.","In XAML, ensure x:Reference carries a name."],"tags":["xaml","markup-extension","x-reference","invalidoperation","system-xaml"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}