{"record":{"id":"698bd5f314695a4a","repo":"dotnet/wpf","slug":"type","errorCode":null,"errorMessage":"type","messagePattern":"type","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Schema/XamlTypeInvoker.cs","lineNumber":31,"sourceCode":"    public class XamlTypeInvoker\n    {\n        private static XamlTypeInvoker s_Unknown;\n\n        private Dictionary<XamlType, MethodInfo> _addMethods;\n        internal MethodInfo EnumeratorMethod { get; set; }\n        private XamlType _xamlType;\n\n        private Action<object> _constructorDelegate;\n\n        private ThreeValuedBool _isPublic;\n\n        protected XamlTypeInvoker()\n        {\n        }\n\n        public XamlTypeInvoker(XamlType type)\n        {\n            _xamlType = type ?? throw new ArgumentNullException(nameof(type));\n        }\n\n        public static XamlTypeInvoker UnknownInvoker\n        {\n            get\n            {\n                if (s_Unknown is null)\n                {\n                    s_Unknown = new XamlTypeInvoker();\n                }\n\n                return s_Unknown;\n            }\n        }\n\n        public EventHandler<XamlSetMarkupExtensionEventArgs> SetMarkupExtensionHandler\n        {\n            get { return _xamlType?.SetMarkupExtensionHandler; }","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Schema/XamlTypeInvoker.cs#L13-L49","documentation":"The public XamlTypeInvoker(XamlType type) constructor requires a non-null XamlType; passing null throws ArgumentNullException with parameter name 'type'. An invoker cannot operate without its owning XamlType.","triggerScenarios":"Calling `new XamlTypeInvoker(null)`, typically when a preceding lookup like schemaContext.GetXamlType(clrType) or XamlType returned null and the result flows into the constructor.","commonSituations":"Custom type mapping/extension code constructing invokers for types resolved at runtime; assemblies removed or renamed so the type lookup silently returns null.","solutions":["Null-check the XamlType before constructing; handle the unresolved-type case explicitly.","Use the type's existing invoker: XamlType.Invoker already returns a correctly constructed XamlTypeInvoker.","Use XamlTypeInvoker.UnknownInvoker for unknown-type scenarios instead of constructing an invoker."],"exampleFix":"// before\nvar invoker = new XamlTypeInvoker(schemaContext.GetXamlType(clrType)); // throws if null\n// after\nvar xamlType = schemaContext.GetXamlType(clrType);\nif (xamlType is null) { /* type not mapped */ return; }\nvar invoker = xamlType.Invoker;","handlingStrategy":"type-guard","validationCode":"if (xamlType is null) return; // type not resolvable in schema context","typeGuard":"static bool TryGetInvoker(XamlType? t, out XamlTypeInvoker? invoker) { invoker = t?.Invoker; return invoker is not null; }","tryCatchPattern":"try { var invoker = new XamlTypeInvoker(xamlType); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"type\") { /* type lookup failed */ }","preventionTips":["Prefer xamlType.Invoker over manual construction","Check GetXamlType results for null before using them","Use XamlTypeInvoker.UnknownInvoker for unresolved types"],"tags":["wpf","system-xaml","argument-null-exception","constructor"],"backgroundTag":"null-argument","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}