{"record":{"id":"3e1f07d2a14adc2b","repo":"unoplatform/uno","slug":"xamlnamespace","errorCode":null,"errorMessage":"xamlNamespace","messagePattern":"xamlNamespace","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/System.Xaml/System.Xaml/XamlSchemaContext.cs","lineNumber":176,"sourceCode":"\t\t{\n\t\t\tlock (gate)\n\t\t\t{\n\t\t\t\tif (xaml_nss == null)\n\t\t\t\t{\n\t\t\t\t\txaml_nss = new Dictionary<string, string>();\n\t\t\t\t\tforeach (var ass in AssembliesInScope)\n\t\t\t\t\t\tFillXamlNamespaces(ass);\n\t\t\t\t}\n\t\t\t\treturn xaml_nss.Values.Distinct();\n\t\t\t}\n\t\t}\n\n\t\tpublic virtual ICollection<XamlType> GetAllXamlTypes (string xamlNamespace)\n\t\t{\n\t\t\tlock (gate)\n\t\t\t{\n\t\t\t\tif (xamlNamespace == null)\n\t\t\t\t\tthrow new ArgumentNullException(\"xamlNamespace\");\n\t\t\t\tif (all_xaml_types == null)\n\t\t\t\t{\n\t\t\t\t\tall_xaml_types = new Dictionary<string, List<XamlType>>();\n\t\t\t\t\tforeach (var ass in AssembliesInScope)\n\t\t\t\t\t\tFillAllXamlTypes(ass);\n\t\t\t\t}\n\n\t\t\t\tList<XamlType> l;\n\t\t\t\tif (all_xaml_types.TryGetValue(xamlNamespace, out l))\n\t\t\t\t\treturn l;\n\t\t\t\telse\n\t\t\t\t\treturn empty_xaml_types;\n\t\t\t}\n\t\t}\n\n\t\tpublic virtual string GetPreferredPrefix (string xmlns)\n\t\t{\n\t\t\tlock (gate)","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/System.Xaml/System.Xaml/XamlSchemaContext.cs#L158-L194","documentation":"Thrown by XamlSchemaContext.GetAllXamlTypes when the xamlNamespace argument is null. GetAllXamlTypes enumerates all XamlTypes registered under a given XAML namespace; a null namespace cannot index the internal dictionary, so it fails fast with an ArgumentNullException.","triggerScenarios":"Calling `schemaContext.GetAllXamlTypes(null)` — typically from code that derived a namespace string that came back null (e.g. a lookup that returned null and was not checked).","commonSituations":"Programmatic callers passing an unresolved namespace; helper methods forwarding a nullable namespace without null-checking; test code passing null deliberately.","solutions":["Pass a non-null namespace string to GetAllXamlTypes.","Null-check the namespace at the source (the lookup that produced it) before forwarding.","Return early or use a sentinel/empty string if the namespace is optional in your flow."],"exampleFix":"// before\nvar types = ctx.GetAllXamlTypes(ns); // ns may be null\n// after\nif (ns != null)\n    var types = ctx.GetAllXamlTypes(ns);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(xamlNamespace))\n    throw new InvalidOperationException(\"xamlNamespace must be non-null before calling GetAllXamlTypes.\");\nvar types = ctx.GetAllXamlTypes(xamlNamespace);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Null-check namespaces at the source (the lookup that produced them).","Treat namespace strings as nullable until validated.","Add a helper wrapper that guards nulls before delegating to schema-context APIs."],"tags":["xaml","null-argument","schema-context","validation"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}