{"record":{"id":"463a5d7229297446","repo":"unoplatform/uno","slug":"typearguments-array-contains-one-or-more-null-xaml","errorCode":null,"errorMessage":"typeArguments array contains one or more null XamlTypeName","messagePattern":"typeArguments array contains one or more null XamlTypeName","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/System.Xaml/System.Xaml.Schema/XamlTypeName.cs","lineNumber":222,"sourceCode":"\t\t\t\tvar l = new List<XamlTypeName> ();\n\t\t\t\tl.AddRange (xamlType.TypeArguments.Select (x => new XamlTypeName (x)));\n\t\t\t\tTypeArguments = l;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic XamlTypeName (string xamlNamespace, string name)\n\t\t\t: this (xamlNamespace, name, null)\n\t\t{\n\t\t}\n\n\t\tpublic XamlTypeName (string xamlNamespace, string name, IEnumerable<XamlTypeName> typeArguments)\n\t\t\t: this ()\n\t\t{\n\t\t\tNamespace = xamlNamespace;\n\t\t\tName = name;\n\t\t\tif (typeArguments != null) {\n\t\t\t\tif (typeArguments.Any (t => t == null))\n\t\t\t\t\tthrow new ArgumentNullException (\"typeArguments\", \"typeArguments array contains one or more null XamlTypeName\");\n\t\t\t\tvar l = new List<XamlTypeName> ();\n\t\t\t\tl.AddRange (typeArguments);\n\t\t\t\tTypeArguments = l;\n\t\t\t}\n\t\t}\n\n\t\tpublic string Name { get; set; }\n\t\tpublic string Namespace { get; set; }\n\t\tpublic IList<XamlTypeName> TypeArguments { get; private set; }\n\n\t\tpublic override string ToString ()\n\t\t{\n\t\t\treturn ToString (null);\n\t\t}\n\n\t\tpublic string ToString (INamespacePrefixLookup prefixLookup)\n\t\t{\n\t\t\tif (Namespace == null)","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/System.Xaml/System.Xaml.Schema/XamlTypeName.cs#L204-L240","documentation":"Thrown by the XamlTypeName(string,string,IEnumerable<XamlTypeName>) constructor when the supplied typeArguments collection contains at least one null element. XamlTypeName models a fully-qualified XAML type with optional generic type arguments; a null entry in that list would produce malformed type strings and corrupt the XAML node stream, so the constructor rejects it eagerly.","triggerScenarios":"Constructing an XamlTypeName with a non-null typeArguments enumerable that itself contains a null entry, e.g. new XamlTypeName(\"ns\",\"List\", new XamlTypeName[]{ null }). Also fires when a LINQ Select producing type arguments yields null for any element (e.g. mapping an unresolved type).","commonSituations":"Programmatic XAML schema construction where generic type arguments are resolved from metadata at runtime and some resolution returns null. Copying a type-argument list from a partially-populated dictionary. Reflection-driven XAML generation where a reflected generic parameter could not be mapped to an XAML namespace.","solutions":["Filter nulls out of the typeArguments collection before passing it: typeArguments.Where(t => t != null).","Fix the upstream code that produces null XamlTypeName entries (e.g. a mapping dictionary lookup returning null) rather than just filtering downstream.","Pass null as typeArguments when you have no generic parameters, instead of an empty or partially-null list."],"exampleFix":"// before\nvar args = types.Select(t => MapOrNull(t));\nvar name = new XamlTypeName(ns, typeName, args);\n\n// after\nvar args = types.Select(t => MapOrNull(t)).Where(t => t != null);\nvar name = new XamlTypeName(ns, typeName, args);","handlingStrategy":"validation","validationCode":"var filtered = typeArguments?.Where(t => t != null).ToList();\nvar name = new XamlTypeName(xamlNamespace, nameStr, filtered);","typeGuard":"static IEnumerable<XamlTypeName> SafeArgs(IEnumerable<XamlTypeName> args)\n    => args?.Where(t => t != null) ?? Enumerable.Empty<XamlTypeName>();","tryCatchPattern":"try { var tn = new XamlTypeName(ns, n, args); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"typeArguments\")\n{ /* log and filter nulls, retry */ }","preventionTips":["Never pass a collection that may contain null XamlTypeName entries — filter first.","Validate type-argument sources (dictionaries, LINQ Select) for null results before constructing XamlTypeName."],"tags":["xaml","schema","argument-null","type-arguments","uno-xaml"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}