{"record":{"id":"a21646edb87ad220","repo":"unoplatform/uno","slug":"type-a21646","errorCode":null,"errorMessage":"type","messagePattern":"type","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/System.Xaml/System.Xaml.Schema/XamlTypeInvoker.cs","lineNumber":51,"sourceCode":"{\n\t[UnconditionalSuppressMessage(\"Trimming\", \"IL2067\", Justification = \"Types manipulated here have been marked earlier\")]\n\t[UnconditionalSuppressMessage(\"Trimming\", \"IL2072\", Justification = \"Types manipulated here have been marked earlier\")]\n\t[UnconditionalSuppressMessage(\"Trimming\", \"IL2075\", Justification = \"Types manipulated here have been marked earlier\")]\n\tpublic class XamlTypeInvoker\n\t{\n\t\tstatic readonly XamlTypeInvoker unknown = new XamlTypeInvoker ();\n\t\tpublic static XamlTypeInvoker UnknownInvoker {\n\t\t\tget { return unknown; }\n\t\t}\n\n\t\tprotected XamlTypeInvoker ()\n\t\t{\n\t\t}\n\t\t\n\t\tpublic XamlTypeInvoker (XamlType type)\n\t\t{\n\t\t\tif (type == null)\n\t\t\t\tthrow new ArgumentNullException (\"type\");\n\t\t\tthis.type = type;\n\t\t}\n\t\t\n\t\tXamlType type;\n\n\t\tvoid ThrowIfUnknown ()\n\t\t{\n\t\t\tif (type == null || type.UnderlyingType == null)\n\t\t\t\tthrow new NotSupportedException (String.Format (CultureInfo.InvariantCulture, \"Current operation is valid only when the underlying type on a XamlType is known, but it is unknown for '{0}'\", type));\n\t\t}\n\n\t\tpublic EventHandler<XamlSetMarkupExtensionEventArgs> SetMarkupExtensionHandler {\n\t\t\tget { return type == null ? null : type.SetMarkupExtensionHandler; }\n\t\t}\n\n\t\tpublic EventHandler<XamlSetTypeConverterEventArgs> SetTypeConverterHandler {\n\t\t\tget { return type == null ? null : type.SetTypeConverterHandler; }\n\t\t}","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/System.Xaml/System.Xaml.Schema/XamlTypeInvoker.cs#L33-L69","documentation":"Thrown by the XamlTypeInvoker(XamlType type) constructor when `type` is null. The invoker must wrap a known XamlType to perform reflection; a null type leaves it with nothing to bind to. This guards against constructing an invoker in an invalid state.","triggerScenarios":"Constructing `new XamlTypeInvoker(null)` directly, or passing a XamlType that resolved to null from XamlSchemaContext.GetXamlType when type resolution failed.","commonSituations":"Custom XAML writers that build an invoker from a type lookup that silently returned null; type-resolution failures (missing assembly/namespace) where the null propagates into invoker construction.","solutions":["Null-check the XamlType before constructing the invoker: `if (xamlType == null) throw/log;`.","Use XamlType.Invoker property instead of `new XamlTypeInvoker(type)` — it handles the lookup correctly.","Fix the upstream type resolution so GetXamlType returns a non-null XamlType (check assembly references and xmlns mappings)."],"exampleFix":"// before\nvar invoker = new XamlTypeInvoker(resolvedType); // resolvedType may be null\n\n// after\nvar invoker = resolvedType != null ? resolvedType.Invoker : XamlTypeInvoker.UnknownInvoker;","handlingStrategy":"validation","validationCode":"// before constructing\nif (type == null) throw new InvalidOperationException(\"XamlType resolution returned null.\");\nvar invoker = type.Invoker; // prefer the property over the constructor","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use XamlType.Invoker instead of `new XamlTypeInvoker(type)`.","Verify type resolution succeeded (non-null) before building an invoker."],"tags":["xaml","schema","invoker","argument-validation","type-resolution"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}