icsharpcode/ILSpy · error · ArgumentNullException
v
Error message
v
What it means
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.
Source
Thrown at ICSharpCode.Decompiler/CSharp/Annotations.cs:257
return node;
}
}
/// <summary>
/// Represents a reference to a local variable.
/// </summary>
public class ILVariableResolveResult : ResolveResult
{
public readonly ILVariable Variable;
public ILVariableResolveResult(ILVariable v) : base(v.Type)
{
this.Variable = v;
}
public ILVariableResolveResult(ILVariable v, IType type) : base(type)
{
this.Variable = v ?? throw new ArgumentNullException(nameof(v));
}
}
/// <summary>
/// Annotates a <see cref="ForeachStatement"/> with the instructions for the GetEnumerator, MoveNext
/// and get_Current calls.
/// </summary>
public class ForeachAnnotation
{
public readonly ILInstruction GetEnumeratorCall;
public readonly ILInstruction MoveNextCall;
public readonly ILInstruction GetCurrentCall;
public ForeachAnnotation(ILInstruction getEnumeratorCall, ILInstruction moveNextCall,
ILInstruction getCurrentCall)
{
GetEnumeratorCall = getEnumeratorCall;
MoveNextCall = moveNextCall;
View on GitHub (pinned to 60c08fcb74)
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.
Example fix
// before var rr = new ILVariableResolveResult(variable, type); // variable may be null // after if (variable == null) throw new ArgumentNullException(nameof(variable)); var rr = new ILVariableResolveResult(variable, type);
Defensive patterns
Strategy: validation
Validate before calling
if (variable == null)
throw new ArgumentNullException(nameof(variable));
var rr = new ILVariableResolveResult(variable, type); Try / catch
try {
var rr = new ILVariableResolveResult(variable, type);
} catch (ArgumentNullException ex) when (ex.ParamName == "v") {
// upstream transform yielded a null variable; treat as decompiler bug
} Prevention
- Never construct ILVariableResolveResult with an unresolved variable; resolve or skip instead.
When it happens
Trigger: 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.
Common situations: A decompiler transform/analyse pass could not allocate an ILVariable for a stack slot/parameter/local and passed null through.
Related errors
- error
- typeSystem
- types
- Cannot use an uncached type system in the decompiler.
- Error decompiling module and assembly attributes of {module.
AI-assisted analysis of icsharpcode/ILSpy@60c08fcb74 (2026-08-13).
Data as JSON: /api/errors/fc861ed41dc45f12.
Report an issue: GitHub.