{"record":{"id":"4100395464a72b12","repo":"unoplatform/uno","slug":"namespaceresolver","errorCode":null,"errorMessage":"namespaceResolver","messagePattern":"namespaceResolver","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/System.Xaml/System.Xaml.Schema/XamlTypeName.cs","lineNumber":47,"sourceCode":"namespace Uno.Xaml.Schema\n{\n\t[UnconditionalSuppressMessage(\"Trimming\", \"IL2026\", Justification = \"Types manipulated here have been marked earlier\")]\n\tpublic class XamlTypeName\n\t{\n\t\tpublic static XamlTypeName Parse (string typeName, IXamlNamespaceResolver namespaceResolver)\n\t\t{\n\t\t\tXamlTypeName n;\n\t\t\tif (!TryParse (typeName, namespaceResolver, out n))\n\t\t\t\tthrow new FormatException (String.Format (CultureInfo.InvariantCulture, \"Invalid typeName: '{0}'\", typeName));\n\t\t\treturn n;\n\t\t}\n\n\t\tpublic static bool TryParse (string typeName, IXamlNamespaceResolver namespaceResolver, out XamlTypeName result)\n\t\t{\n\t\t\tif (typeName == null)\n\t\t\t\tthrow new ArgumentNullException (\"typeName\");\n\t\t\tif (namespaceResolver == null)\n\t\t\t\tthrow new ArgumentNullException (\"namespaceResolver\");\n\n\t\t\tresult = null;\n\t\t\tIList<XamlTypeName> args = null;\n\t\t\tint nArray = 0;\n\t\t\tint idx;\n\n\t\t\tif (typeName.Length > 2 && typeName [typeName.Length - 1] == ']') {\n\t\t\t\tidx = typeName.LastIndexOf ('[');\n\t\t\t\tif (idx < 0)\n\t\t\t\t\treturn false; // mismatch brace\n\t\t\t\tnArray = 1;\n\t\t\t\tfor (int i = idx + 1; i < typeName.Length - 1; i++) {\n\t\t\t\t\tif (typeName [i] != ',')\n\t\t\t\t\t\treturn false; // only ',' is expected\n\t\t\t\t\tnArray++;\n\t\t\t\t}\n\t\t\t\tif (!TryParse (typeName.Substring (0, idx), namespaceResolver, out result))\n\t\t\t\t\treturn false;","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/System.Xaml/System.Xaml.Schema/XamlTypeName.cs#L29-L65","documentation":"Thrown by XamlTypeName.TryParse when the `namespaceResolver` argument is null. The parser must resolve every prefix to a namespace via the resolver, so a null resolver makes type resolution impossible. It is rejected up front rather than failing later inside prefix lookup.","triggerScenarios":"Calling XamlTypeName.TryParse(typeName, null, out _); passing null where an IXamlNamespaceResolver is expected because the caller had no namespace context available.","commonSituations":"Ad-hoc parsing calls outside a XAML reader where no namespace resolver was constructed; refactors that dropped the resolver argument; tests that passed null and expected graceful handling.","solutions":["Construct and pass a valid IXamlNamespaceResolver (e.g. from a XamlXmlReader's namespace table or a custom implementation) before parsing.","If no namespace resolution is needed, build a trivial resolver that maps the empty prefix to your default namespace.","Null-check before calling and fail fast with your own context-rich error."],"exampleFix":"// before\nXamlTypeName.TryParse(typeName, null, out var name);\n\n// after\nvar resolver = new NamespaceTableLookup(); // implements IXamlNamespaceResolver\nresolver.Register(\"\", \"http://schemas.example.com/default\");\nXamlTypeName.TryParse(typeName, resolver, out var name);","handlingStrategy":"validation","validationCode":"// before TryParse\nif (namespaceResolver == null) throw new InvalidOperationException(\"A namespace resolver is required to parse XAML type names.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always construct an IXamlNamespaceResolver (or reuse a reader's) before parsing.","Build a trivial resolver mapping the empty prefix to your default namespace if nothing else."],"tags":["xaml","schema","parsing","type-name","argument-validation","namespace"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}