{"record":{"id":"fc861ed41dc45f12","repo":"icsharpcode/ILSpy","slug":"v","errorCode":null,"errorMessage":"v","messagePattern":"v","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"ICSharpCode.Decompiler/CSharp/Annotations.cs","lineNumber":257,"sourceCode":"\t\t\treturn node;\r\n\t\t}\r\n\t}\r\n\r\n\t/// <summary>\r\n\t/// Represents a reference to a local variable.\r\n\t/// </summary>\r\n\tpublic class ILVariableResolveResult : ResolveResult\r\n\t{\r\n\t\tpublic readonly ILVariable Variable;\r\n\r\n\t\tpublic ILVariableResolveResult(ILVariable v) : base(v.Type)\r\n\t\t{\r\n\t\t\tthis.Variable = v;\r\n\t\t}\r\n\r\n\t\tpublic ILVariableResolveResult(ILVariable v, IType type) : base(type)\r\n\t\t{\r\n\t\t\tthis.Variable = v ?? throw new ArgumentNullException(nameof(v));\r\n\t\t}\r\n\t}\r\n\r\n\t/// <summary>\r\n\t/// Annotates a <see cref=\"ForeachStatement\"/> with the instructions for the GetEnumerator, MoveNext\r\n\t/// and get_Current calls.\r\n\t/// </summary>\r\n\tpublic class ForeachAnnotation\r\n\t{\r\n\t\tpublic readonly ILInstruction GetEnumeratorCall;\r\n\t\tpublic readonly ILInstruction MoveNextCall;\r\n\t\tpublic readonly ILInstruction GetCurrentCall;\r\n\r\n\t\tpublic ForeachAnnotation(ILInstruction getEnumeratorCall, ILInstruction moveNextCall,\r\n\t\t\tILInstruction getCurrentCall)\r\n\t\t{\r\n\t\t\tGetEnumeratorCall = getEnumeratorCall;\r\n\t\t\tMoveNextCall = moveNextCall;\r","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/icsharpcode/ILSpy/blob/60c08fcb74fcc183130f73c861ed35cf944d0bf1/ICSharpCode.Decompiler/CSharp/Annotations.cs#L239-L275","documentation":"Thrown by the two-argument ILVariableResolveResult constructor: this.Variable = v ?? throw new ArgumentNullException(nameof(v)). The message is just the parameter name 'v'. It is a programming-contract failure: the caller passed a null ILVariable when also supplying an explicit IType.","triggerScenarios":"Code constructs new ILVariableResolveResult(variable, type) where variable is null. This is internal decompiler-transform code, so a hit indicates a decompiler bug that resolved an ILVariable to null and still tried to build a resolve result.","commonSituations":"A decompiler transform/analyse pass could not allocate an ILVariable for a stack slot/parameter/local and passed null through.","solutions":["Check the stack trace to find which transform produced the null ILVariable and report it as a decompiler bug.","Update to a newer ILSpy/ILSpyX build; include the offending assembly in the report.","If you call this constructor yourself, guard v before constructing."],"exampleFix":"// before\nvar rr = new ILVariableResolveResult(variable, type); // variable may be null\n\n// after\nif (variable == null) throw new ArgumentNullException(nameof(variable));\nvar rr = new ILVariableResolveResult(variable, type);","handlingStrategy":"validation","validationCode":"if (variable == null)\n    throw new ArgumentNullException(nameof(variable));\nvar rr = new ILVariableResolveResult(variable, type);","typeGuard":null,"tryCatchPattern":"try {\n    var rr = new ILVariableResolveResult(variable, type);\n} catch (ArgumentNullException ex) when (ex.ParamName == \"v\") {\n    // upstream transform yielded a null variable; treat as decompiler bug\n}","preventionTips":["Never construct ILVariableResolveResult with an unresolved variable; resolve or skip instead."],"tags":["decompiler","csharp","argument-null","internal"],"backgroundTag":null,"analyzedSha":"60c08fcb74fcc183130f73c861ed35cf944d0bf1","analyzedAt":"2026-08-13T11:34:51.223Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}