{"record":{"id":"05d0d7cf7bfbeade","repo":"unoplatform/uno","slug":"either-of-convertertype-targettype-or-name-must-b","errorCode":null,"errorMessage":"Either of converterType, targetType or name must be non-null","messagePattern":"Either of converterType, targetType or name must be non-null","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/System.Xaml/System.Xaml.Schema/XamlValueConverter.cs","lineNumber":44,"sourceCode":"using System.Diagnostics.CodeAnalysis;\nusing System.Globalization;\n\nnamespace Uno.Xaml.Schema\n{\n\tpublic class XamlValueConverter<[DynamicallyAccessedMembers(TConverterBaseRequirements)] TConverterBase> : IEquatable<XamlValueConverter<TConverterBase>>\n\t\twhere TConverterBase : class\n\t{\n\t\tinternal const DynamicallyAccessedMemberTypes TConverterBaseRequirements = DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | DynamicallyAccessedMemberTypes.NonPublicConstructors;\n\n\t\tpublic XamlValueConverter ([DynamicallyAccessedMembers(TConverterBaseRequirements)] Type converterType, XamlType targetType)\n\t\t\t: this (converterType, targetType, null)\n\t\t{\n\t\t}\n\n\t\tpublic XamlValueConverter ([DynamicallyAccessedMembers(TConverterBaseRequirements)] Type converterType, XamlType targetType, string name)\n\t\t{\n\t\t\tif (converterType == null && targetType == null && name == null)\n\t\t\t\tthrow new ArgumentException (\"Either of converterType, targetType or name must be non-null\");\n\t\t\tConverterType = converterType;\n\t\t\tTargetType = targetType;\n\t\t\tName = name;\n\t\t}\n\n\t\tTConverterBase converter_instance;\n\t\tpublic TConverterBase ConverterInstance {\n\t\t\tget {\n\t\t\t\tif (converter_instance == null)\n\t\t\t\t\tconverter_instance = CreateInstance ();\n\t\t\t\treturn converter_instance;\n\t\t\t}\n\t\t}\n\t\t[DynamicallyAccessedMembers(TConverterBaseRequirements)]\n\t\tpublic Type ConverterType { get; private set; }\n\t\tpublic string Name { get; private set; }\n\t\tpublic XamlType TargetType { get; private set; }\n","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/System.Xaml/System.Xaml.Schema/XamlValueConverter.cs#L26-L62","documentation":"Thrown by the XamlValueConverter<TConverterBase> constructor when all three of converterType, targetType, and name are null. XamlValueConverter needs at least one non-null identity component to be meaningful (it represents a value converter keyed by converter type, target type, and/or a display name); an all-null instance is degenerate and is rejected.","triggerScenarios":"Constructing new XamlValueConverter<TypeConverter>(null, null, null). Or calling the two-argument overload new XamlValueConverter<T>(null, null) which forwards name=null, hitting the same guard.","commonSituations":"Schema-building code that resolves a value converter from metadata where all three fields were unresolved (e.g. a TypeConverterAttribute and TargetType both missing from a reflected member). Reflection-driven XAML schema context construction with incomplete type info.","solutions":["Ensure at least one of converterType, targetType, or name is non-null when constructing XamlValueConverter.","Fix upstream resolution logic: if you expected a converter type from a TypeConverterAttribute, verify the attribute was present and resolved.","Return null from your lookup function instead of constructing a degenerate XamlValueConverter when nothing resolves."],"exampleFix":"// before\nvar vc = new XamlValueConverter<TypeConverter>(resolvedConverterType, resolvedTargetType, name);\n// all three resolved null\n\n// after\nif (resolvedConverterType == null && resolvedTargetType == null && name == null)\n    return null; // no converter applicable\nvar vc = new XamlValueConverter<TypeConverter>(resolvedConverterType, resolvedTargetType, name);","handlingStrategy":"validation","validationCode":"if (converterType == null && targetType == null && string.IsNullOrEmpty(name))\n    return null; // no converter applicable\nvar vc = new XamlValueConverter<TypeConverter>(converterType, targetType, name);","typeGuard":"static bool HasIdentity(Type ct, XamlType tt, string n)\n    => ct != null || tt != null || !string.IsNullOrEmpty(n);","tryCatchPattern":"try { return new XamlValueConverter<T>(ct, tt, name); }\ncatch (ArgumentException) { return null; }","preventionTips":["Ensure at least one of converterType/targetType/name resolves before constructing.","Return null from lookup functions instead of constructing degenerate converters."],"tags":["xaml","schema","argument","value-converter","uno-xaml"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}