{"record":{"id":"eeb6d9f4d475657c","repo":"unoplatform/uno","slug":"descriptor","errorCode":null,"errorMessage":"descriptor","messagePattern":"descriptor","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/System.Xaml/System.Windows.Markup/ValueSerializer.cs","lineNumber":53,"sourceCode":"\t// [System.Runtime.CompilerServices.TypeForwardedFrom (Consts.AssemblyWindowsBase)]\n\tpublic abstract class ValueSerializer\n\t{\n\t\tpublic static ValueSerializer GetSerializerFor (PropertyDescriptor descriptor)\n\t\t{\n\t\t\treturn GetSerializerFor (descriptor, null);\n\t\t}\n\n\t\tpublic static ValueSerializer GetSerializerFor (Type type)\n\t\t{\n\t\t\treturn GetSerializerFor (type, null);\n\t\t}\n\n\t\t// untested\n\t\tpublic static ValueSerializer GetSerializerFor (PropertyDescriptor descriptor, IValueSerializerContext context)\n\t\t{\n\t\t\tif (descriptor == null)\n\t\t\t{\n\t\t\t\tthrow new ArgumentNullException (\"descriptor\");\n\t\t\t}\n\n\t\t\tif (context != null)\n\t\t\t{\n\t\t\t\treturn context.GetValueSerializerFor (descriptor);\n\t\t\t}\n\n\t\t\tvar tc = descriptor.Converter;\n\t\t\tif (tc != null && tc.GetType () != typeof (TypeConverter))\n\t\t\t{\n\t\t\t\treturn new TypeConverterValueSerializer (tc);\n\t\t\t}\n\n\t\t\treturn null;\n\t\t}\n\n\t\tpublic static ValueSerializer GetSerializerFor (Type type, IValueSerializerContext context)\n\t\t{","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/System.Xaml/System.Windows.Markup/ValueSerializer.cs#L35-L71","documentation":"Thrown by ValueSerializer.GetSerializerFor(PropertyDescriptor, IValueSerializerContext) when the descriptor argument is null. The descriptor is used to obtain the TypeConverter and to delegate to the context, so it must be present.","triggerScenarios":"Calling GetSerializerFor((PropertyDescriptor)null, context), typically from a custom XAML serialization pipeline that passed a descriptor obtained from a failed TypeDescriptor.GetDescriptor lookup.","commonSituations":"Custom serializers that obtain PropertyDescriptor dynamically and do not null-check; serialization of members without an associated descriptor; reflection-based binding failures.","solutions":["Obtain the PropertyDescriptor via a non-failing lookup (e.g. TypeDescriptor.GetProperties(type)[name]) and verify non-null before calling.","Use the GetSerializerFor(Type, context) overload when only a type is available.","Null-check the descriptor at the call site and handle the missing case explicitly."],"exampleFix":"// before\nvar desc = TypeDescriptor.GetProperties(obj)[\"BadName\"];\nvar ser = ValueSerializer.GetSerializerFor(desc, ctx); // throws\n\n// after\nvar desc = TypeDescriptor.GetProperties(obj)[\"RealName\"];\nif (desc != null)\n    var ser = ValueSerializer.GetSerializerFor(desc, ctx);","handlingStrategy":"validation","validationCode":"var desc = TypeDescriptor.GetProperties(obj)[memberName];\nif (desc == null)\n    throw new InvalidOperationException($\"No descriptor for {memberName}\");\nvar ser = ValueSerializer.GetSerializerFor(desc, ctx);","typeGuard":"static bool HasDescriptor(PropertyDescriptor d) => d != null;","tryCatchPattern":null,"preventionTips":["Always validate PropertyDescriptor lookups before forwarding to GetSerializerFor.","Prefer the GetSerializerFor(Type, context) overload when only a type is known.","Wrap dynamic descriptor resolution in a helper that returns null instead of propagating null."],"tags":["xaml","value-serializer","argument-null","uno"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}