{"record":{"id":"6a1bf7a4e9b71c1a","repo":"unoplatform/uno","slug":"value-must-be-non-null-string","errorCode":null,"errorMessage":"Value must be non-null string.","messagePattern":"Value must be non-null string\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/System.Xaml/System.Windows.Markup/NameReferenceConverter.cs","lineNumber":60,"sourceCode":"\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tvar p = context.GetService (typeof (IXamlNameProvider)) as IXamlNameProvider;\n\t\t\treturn p != null && destinationType == typeof (string);\n\t\t}\n\n\t\tpublic override object ConvertFrom (ITypeDescriptorContext context, CultureInfo culture, object value)\n\t\t{\n\t\t\tif (context == null)\n\t\t\t{\n\t\t\t\tthrow new ArgumentNullException (\"context\");\n\t\t\t}\n\n\t\t\tvar s = value as string;\n\t\t\tif (String.IsNullOrEmpty (s))\n\t\t\t{\n\t\t\t\tthrow new InvalidOperationException (\"Value must be non-null string.\");\n\t\t\t}\n\n\t\t\treturn s;\n\t\t}\n\n\t\tpublic override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)\n\t\t{\n\t\t\tif (context == null)\n\t\t\t{\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tvar p = context.GetService (typeof (IXamlNameProvider)) as IXamlNameProvider;\n\t\t\treturn p?.GetName (value);\n\t\t}\n\t}\n}\n","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/System.Xaml/System.Windows.Markup/NameReferenceConverter.cs#L42-L78","documentation":"InvalidOperationException thrown by NameReferenceConverter.ConvertFrom (System.Xaml, ported from Mono) when the input value is null or an empty string. The converter returns a name reference string, so it requires a non-empty string input; null/empty is a usage error rather than an argument-null case (context was already validated).","triggerScenarios":"Passing null, string.Empty, or whitespace-only value to ConvertFrom once a valid context is present.","commonSituations":"A bound/config value that resolves to null or empty being fed to the converter, XAML where the reference is omitted, or default(string) passed programmatically.","solutions":["Validate the input is a non-empty string before invoking ConvertFrom.","Coerce null/empty to a sensible default name upstream of the converter.","In XAML, ensure the name reference attribute has a value."],"exampleFix":"// before\nvar name = (string)converter.ConvertFrom(ctx, culture, maybeEmpty);\n\n// after\nif (string.IsNullOrEmpty(maybeEmpty)) throw new ArgumentException(\"Name reference required.\");\nvar name = (string)converter.ConvertFrom(ctx, culture, maybeEmpty);","handlingStrategy":"validation","validationCode":"static string SafeConvert(NameReferenceConverter c, ITypeDescriptorContext ctx, string value) { if (string.IsNullOrEmpty(value)) throw new ArgumentException(\"Name reference required.\", nameof(value)); return (string)c.ConvertFrom(ctx, CultureInfo.InvariantCulture, value); }","typeGuard":"static bool IsNonEmptyName(object value) => value is string s && s.Length > 0;","tryCatchPattern":"try { return (string)converter.ConvertFrom(ctx, culture, value); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"non-null string\")) { return string.Empty; }","preventionTips":["Validate input is a non-empty string before converting.","Coerce null/empty upstream of the converter.","Ensure XAML name-reference attributes always carry a value."],"tags":["xaml","type-converter","namereference","invalidoperation","system-xaml"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}