{"record":{"id":"643c9cbf83a5c84a","repo":"unoplatform/uno","slug":"xmlns","errorCode":null,"errorMessage":"xmlns","messagePattern":"xmlns","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/System.Xaml/System.Xaml/XamlSchemaContext.cs","lineNumber":197,"sourceCode":"\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)\n\t\t\t{\n\t\t\t\tif (xmlns == null)\n\t\t\t\t\tthrow new ArgumentNullException(\"xmlns\");\n\t\t\t\tif (xmlns == XamlLanguage.Xaml2006Namespace)\n\t\t\t\t\treturn \"x\";\n\t\t\t\tif (prefixes == null)\n\t\t\t\t{\n\t\t\t\t\tprefixes = new Dictionary<string, string>();\n\t\t\t\t\tforeach (var ass in AssembliesInScope)\n\t\t\t\t\t\tFillPrefixes(ass);\n\t\t\t\t}\n\t\t\t\tstring ret;\n\t\t\t\treturn prefixes.TryGetValue(xmlns, out ret) ? ret : \"p\"; // default\n\t\t\t}\n\t\t}\n\n\t\tprotected internal XamlValueConverter<TConverterBase> GetValueConverter<\n\t\t\t[DynamicallyAccessedMembers(XamlValueConverter<TConverterBase>.TConverterBaseRequirements)] TConverterBase\n\t\t> ([DynamicallyAccessedMembers(XamlValueConverter<TConverterBase>.TConverterBaseRequirements)] Type converterType, XamlType targetType)\n\t\t\twhere TConverterBase : class\n\t\t{","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/System.Xaml/System.Xaml/XamlSchemaContext.cs#L179-L215","documentation":"Thrown by XamlSchemaContext.GetPreferredPrefix when the xmlns argument is null. GetPreferredPrefix returns the preferred XML prefix for a namespace ('x' for Xaml2006, else a registered prefix or 'p'); a null namespace cannot be looked up, so it fails fast.","triggerScenarios":"Calling `schemaContext.GetPreferredPrefix(null)` — usually a caller that passed a namespace obtained from an unresolved declaration.","commonSituations":"Serialization/round-tripping code forwarding a nullable namespace; namespace lookups that returned null and were not guarded.","solutions":["Pass a non-null namespace string to GetPreferredPrefix.","Guard nullable namespaces at the call site before invoking the method.","Default to XamlLanguage.Xaml2006Namespace when the intended namespace is the XAML language namespace."],"exampleFix":"// before\nvar prefix = ctx.GetPreferredPrefix(ns); // ns may be null\n// after\nvar prefix = ns != null ? ctx.GetPreferredPrefix(ns) : \"p\";","handlingStrategy":"validation","validationCode":"if (xmlns == null)\n    throw new InvalidOperationException(\"xmlns must be non-null before calling GetPreferredPrefix.\");\nvar prefix = ctx.GetPreferredPrefix(xmlns);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Guard nullable namespaces before calling GetPreferredPrefix.","Default to a sensible prefix ('p') when the namespace is unknown rather than null.","Centralize namespace handling so null never reaches the schema context."],"tags":["xaml","null-argument","schema-context","validation"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}