{"record":{"id":"cfe4ab3087faf980","repo":"icsharpcode/ILSpy","slug":"definitions","errorCode":null,"errorMessage":"definitions","messagePattern":"definitions","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs","lineNumber":1369,"sourceCode":"\t\t{\r\n\t\t\treturn SyntaxTreeToString(DecompileType(fullTypeName));\r\n\t\t}\r\n\r\n\t\t/// <summary>\r\n\t\t/// Decompile the specified types and/or members.\r\n\t\t/// </summary>\r\n\t\tpublic SyntaxTree Decompile(params EntityHandle[] definitions)\r\n\t\t{\r\n\t\t\treturn Decompile((IEnumerable<EntityHandle>)definitions);\r\n\t\t}\r\n\r\n\t\t/// <summary>\r\n\t\t/// Decompile the specified types and/or members.\r\n\t\t/// </summary>\r\n\t\tpublic SyntaxTree Decompile(IEnumerable<EntityHandle> definitions)\r\n\t\t{\r\n\t\t\tif (definitions == null)\r\n\t\t\t\tthrow new ArgumentNullException(nameof(definitions));\r\n\t\t\tsyntaxTree = new SyntaxTree();\r\n\t\t\tvar namespaces = new HashSet<string>();\r\n\t\t\tforeach (var entity in definitions)\r\n\t\t\t{\r\n\t\t\t\tif (entity.IsNil)\r\n\t\t\t\t\tthrow new ArgumentException(\"definitions contains null element\");\r\n\t\t\t\tRequiredNamespaceCollector.CollectNamespaces(entity, module, namespaces);\r\n\t\t\t}\r\n\t\t\tvar decompileRun = CreateDecompileRun(namespaces);\r\n\r\n\t\t\tbool first = true;\r\n\t\t\tITypeDefinition? parentTypeDef = null;\r\n\t\t\tforeach (var entity in definitions)\r\n\t\t\t{\r\n\t\t\t\tswitch (entity.Kind)\r\n\t\t\t\t{\r\n\t\t\t\t\tcase HandleKind.TypeDefinition:\r\n\t\t\t\t\t\tITypeDefinition typeDef = module.GetDefinition((TypeDefinitionHandle)entity);\r","sourceCodeStart":1351,"sourceCodeEnd":1387,"githubUrl":"https://github.com/icsharpcode/ILSpy/blob/60c08fcb74fcc183130f73c861ed35cf944d0bf1/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs#L1351-L1387","documentation":"ArgumentNullException(nameof(definitions)) from Decompile(IEnumerable<EntityHandle>) when the definitions sequence is null. The public Decompile(params EntityHandle[]) overload forwards to this one, so passing null there lands here too.","triggerScenarios":"Calling Decompile((IEnumerable<EntityHandle>)null), Decompile((EntityHandle[])null), or passing a variable that is null because a preceding lookup returned no array.","commonSituations":"A LINQ/mapping step returns null on the empty case instead of an empty collection; an uninitialized EntityHandle[] field passed straight through.","solutions":["Pass a non-null collection; use Array.Empty<EntityHandle>() instead of null for the empty case.","Null-coalesce at the call site: decompiler.Decompile(handles ?? Array.Empty<EntityHandle>())."],"exampleFix":"// before\nSyntaxTree tree = decompiler.Decompile(handles); // handles may be null\n\n// after\nSyntaxTree tree = decompiler.Decompile(handles ?? Array.Empty<EntityHandle>());","handlingStrategy":"validation","validationCode":"var tree = decompiler.Decompile(handles ?? Array.Empty<EntityHandle>());","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Return Array.Empty<EntityHandle>() instead of null from lookup helpers.","Prefer the params overload with no args over passing an explicit null."],"tags":["decompilation","validation","argument","null-reference"],"backgroundTag":null,"analyzedSha":"60c08fcb74fcc183130f73c861ed35cf944d0bf1","analyzedAt":"2026-08-13T11:34:51.223Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}