{"record":{"id":"98a54e25e47feca2","repo":"icsharpcode/ILSpy","slug":"handle","errorCode":null,"errorMessage":"handle","messagePattern":"handle","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs","lineNumber":1459,"sourceCode":"\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse if (parentTypeDef != null)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tparentTypeDef = FindCommonDeclaringTypeDefinition(parentTypeDef, ev.DeclaringTypeDefinition);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tdefault:\r\n\t\t\t\t\t\tthrow new NotSupportedException(entity.Kind.ToString());\r\n\t\t\t\t}\r\n\t\t\t\tfirst = false;\r\n\t\t\t}\r\n\t\t\tRunTransforms(syntaxTree, decompileRun, parentTypeDef != null ? new SimpleTypeResolveContext(parentTypeDef) : new SimpleTypeResolveContext(typeSystem.MainModule));\r\n\t\t\treturn syntaxTree;\r\n\t\t}\r\n\r\n\t\tpublic SyntaxTree DecompileExtension(EntityHandle handle)\r\n\t\t{\r\n\t\t\tif (handle.IsNil)\r\n\t\t\t\tthrow new ArgumentNullException(nameof(handle));\r\n\t\t\tsyntaxTree = new SyntaxTree();\r\n\t\t\tvar namespaces = new HashSet<string>();\r\n\t\t\tRequiredNamespaceCollector.CollectNamespaces(handle, module, namespaces);\r\n\t\t\tvar decompileRun = CreateDecompileRun(namespaces);\r\n\r\n\t\t\tswitch (handle.Kind)\r\n\t\t\t{\r\n\t\t\t\tcase HandleKind.TypeDefinition:\r\n\t\t\t\t\tITypeDefinition typeDef = module.GetDefinition((TypeDefinitionHandle)handle);\r\n\t\t\t\t\tsyntaxTree.Members.Add(DoDecompile(typeDef, decompileRun, new SimpleTypeResolveContext(typeDef), asExtension: true));\r\n\t\t\t\t\tRunTransforms(syntaxTree, decompileRun, new SimpleTypeResolveContext(typeDef));\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase HandleKind.MethodDefinition:\r\n\t\t\t\t\tIMethod methodDef = module.GetDefinition((MethodDefinitionHandle)handle);\r\n\t\t\t\t\tvar extensionInfo = methodDef.ResolveExtensionInfo();\r\n\t\t\t\t\tDebug.Assert(extensionInfo != null);\r\n\t\t\t\t\tvar memberInfo = extensionInfo.InfoOfExtensionMember((IMethod)methodDef.MemberDefinition).GetValueOrDefault();\r\n\t\t\t\t\tvar subst = new TypeParameterSubstitution(memberInfo.ExtensionGroupingTypeParameters, null);\r","sourceCodeStart":1441,"sourceCodeEnd":1477,"githubUrl":"https://github.com/icsharpcode/ILSpy/blob/60c08fcb74fcc183130f73c861ed35cf944d0bf1/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs#L1441-L1477","documentation":"ArgumentNullException(nameof(handle)) from DecompileExtension(EntityHandle) when handle.IsNil. EntityHandle is a struct, so this is the nil sentinel rather than a language null; the library surfaces it as ArgumentNullException to flag an unprovided argument.","triggerScenarios":"Calling DecompileExtension(default(EntityHandle)) or with a handle obtained from a lookup that returned nil.","commonSituations":"A selected extension-member handle that failed to resolve; passing a handle read from an uninitialized struct field.","solutions":["Check handle.IsNil before calling DecompileExtension.","Resolve the extension-member handle from a known-good source (ResolveExtensionInfo) and bail if nil."],"exampleFix":"// before\nvar tree = decompiler.DecompileExtension(handle);\n\n// after\nif (handle.IsNil) throw new ArgumentNullException(nameof(handle));\nvar tree = decompiler.DecompileExtension(handle);","handlingStrategy":"validation","validationCode":"if (handle.IsNil) throw new ArgumentNullException(nameof(handle));\nvar tree = decompiler.DecompileExtension(handle);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve extension-member handles explicitly and bail on nil before calling.","Keep a single validation helper for EntityHandle and reuse it at every entry point."],"tags":["decompilation","validation","argument","extensions"],"backgroundTag":null,"analyzedSha":"60c08fcb74fcc183130f73c861ed35cf944d0bf1","analyzedAt":"2026-08-13T11:34:51.223Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}