{"record":{"id":"26c8ef1f200d0ee9","repo":"unoplatform/uno","slug":"schemacontext-26c8ef","errorCode":null,"errorMessage":"schemaContext","messagePattern":"schemaContext","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/System.Xaml/System.Xaml/XamlType.cs","lineNumber":91,"sourceCode":"\t\t\t\tName = GetXamlName (type);\n\t\t\t\tPreferredXamlNamespace = schemaContext.GetXamlNamespace (type.Namespace) ?? String.Format (CultureInfo.InvariantCulture, \"clr-namespace:{0};assembly={1}\", type.Namespace, type.Assembly.GetName ().Name);\n\t\t\t}\n\t\t\tif (type.IsGenericType) {\n\t\t\t\tTypeArguments = new List<XamlType> ();\n\t\t\t\tforeach (var gta in type.GetGenericArguments ())\n\t\t\t\t\tTypeArguments.Add (schemaContext.GetXamlType (gta));\n\t\t\t}\n\t\t}\n\n\t\tpublic XamlType (string unknownTypeNamespace, string unknownTypeName, IList<XamlType> typeArguments, XamlSchemaContext schemaContext)\n\t\t\t: this (schemaContext, null)\n\t\t{\n\t\t\tif (unknownTypeNamespace == null)\n\t\t\t\tthrow new ArgumentNullException (\"unknownTypeNamespace\");\n\t\t\tif (unknownTypeName == null)\n\t\t\t\tthrow new ArgumentNullException (\"unknownTypeName\");\n\t\t\tif (schemaContext == null)\n\t\t\t\tthrow new ArgumentNullException (\"schemaContext\");\n\n\t\t\ttype = typeof (object);\n\t\t\tName = unknownTypeName;\n\t\t\tPreferredXamlNamespace = unknownTypeNamespace;\n\t\t\tTypeArguments = typeArguments != null && typeArguments.Count == 0 ? null : typeArguments;\n//\t\t\texplicit_ns = unknownTypeNamespace;\n\t\t}\n\n\t\tprotected XamlType (string typeName, IList<XamlType> typeArguments, XamlSchemaContext schemaContext)\n\t\t\t: this (String.Empty, typeName, typeArguments, schemaContext)\n\t\t{\n\t\t}\n\n\t\tXamlType (XamlSchemaContext schemaContext, XamlTypeInvoker invoker)\n\t\t{\n\t\t\tif (schemaContext == null)\n\t\t\t\tthrow new ArgumentNullException (\"schemaContext\");\n\t\t\tSchemaContext = schemaContext;","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/System.Xaml/System.Xaml/XamlType.cs#L73-L109","documentation":"The XamlType(string unknownTypeNamespace, ...) constructor throws ArgumentNullException('schemaContext') when the XamlSchemaContext is null. The schema context owns type/member resolution and is stored on the XamlType; every XamlType requires one, and downstream calls (GetXamlType on generic arguments) would NRE without it.","triggerScenarios":"Constructing a XamlType without a schema context — typically when a caller built the context lazily and it was null, or in tests that omitted the dependency.","commonSituations":"Dependency-injection misconfiguration where the schema context was not provided; refactoring that removed context creation; shared static context not yet initialized at construction time.","solutions":["Construct or obtain a XamlSchemaContext (e.g. new XamlSchemaContext()) before building any XamlType.","Inject the schema context as a required constructor dependency and fail fast in your factory if it is missing.","Reuse a single cached XamlSchemaContext across all XamlType instances for a parse session to keep resolution consistent."],"exampleFix":"// before\nvar xt = new XamlType(ns, name, typeArgs, null);\n\n// after\nvar sctx = new XamlSchemaContext();\nvar xt = new XamlType(ns, name, typeArgs, sctx);","handlingStrategy":"validation","validationCode":"if (schemaContext == null) schemaContext = new XamlSchemaContext();\nvar xt = new XamlType(unknownTypeNamespace, unknownTypeName, typeArguments, schemaContext);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Inject the XamlSchemaContext as a required dependency and fail fast if missing.","Cache and reuse one schema context per parse session to keep type resolution consistent."],"tags":["xaml","argument-null","xamltype","schema-context"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}