Most C# developers never type __arglist, and that is exactly why it is confusing when a decompiler shows it to you. You open a low-level interop shim in Glass.NET, and instead of a tidy params array you see a method whose signature trails off into ... and a body full of ArgIterator. This is the CLR's real variadic calling convention — the same vararg convention C uses for printf — surfaced into C#. Reconstructing it is a good test of a decompiler, because the information a params method keeps in one place, a vararg method deliberately scatters.
The real question
A params int[] method is ordinary. It takes a single array argument; the compiler allocates the array at the call site and the method reads it like any other array. Everything you need to decompile it is in the method definition.
A vararg method is not ordinary. Its definition records the fixed parameters and then a sentinel that says "and some number of extra arguments whose types I don't know." The types of those extra arguments are decided by the caller and recorded only in that call site's signature. So the question a decompiler must answer is: given a method whose definition is deliberately silent about its variadic tail, where does the type information actually live — and how do you get from raw IL back to __arglist(2, 3, 4)?
The method definition keeps a secret
Start with the method. Here is a vararg sum in C#:
using System; static int SumAll(int first, __arglist) { int total = first; var it = new ArgIterator(__arglist); while (it.GetRemainingCount() > 0) total += __refvalue(it.GetNextArg(), int); return total; } The __arglist in the parameter list is not a parameter you can name — it is the marker that makes this a vararg method. When Glass reads the method definition, the signature blob begins with the calling-convention byte 0x05 (VARARG) rather than the usual 0x00 (DEFAULT). ILDASM renders that as a ... after the fixed parameters:
.method private hidebysig static int32 SumAll(int32 first, ...) cil managed Note what is not here: any mention of int, or of three arguments, or of a count. The definition commits to exactly one fixed int32 and then declares itself open. That is the secret — and it is why a decompiler cannot reconstruct the call just by reading the method.
Reading the arguments: arglist and refanyval
The body is the other half. There is no array to index, so the method walks the incoming arguments with three special constructs that map one-to-one onto IL opcodes:
-
__arglist(the expression) emitsarglist(0xFE 0x00), which pushes aRuntimeArgumentHandledescribing the extra arguments the caller passed. -
__refvalue(tr, int)emitsrefanyval(0xC2) to extract a managed pointer of a given type out of aTypedReference, followed by anldindto load through it. - Its siblings
__makerefand__reftypeemitmkrefanyandrefanytype.
The decompiled body comes straight off these:
.locals init (int32 total, valuetype System.ArgIterator it) IL_0000: ldarg.0 IL_0001: stloc.0 IL_0002: ldloca.s it IL_0004: arglist IL_0005: call instance void System.ArgIterator::.ctor(valuetype System.RuntimeArgumentHandle) // loop: IL_000a: ldloca.s it IL_000c: call instance int32 System.ArgIterator::GetRemainingCount() IL_0011: brfalse.s IL_0028 IL_0013: ldloc.0 IL_0014: ldloca.s it IL_0016: call instance valuetype System.TypedReference System.ArgIterator::GetNextArg() IL_001b: refanyval [System.Runtime]System.Int32 IL_0020: ldind.i4 IL_0021: add IL_0022: stloc.0 IL_0023: br.s IL_000a Glass recognises the arglist → ArgIterator::.ctor pairing and renders it as new ArgIterator(__arglist), and the refanyval T + ldind pairing as __refvalue(..., T). That is mechanical. The hard part is still upstream, at the caller.
Where the types really live: the call site
Compile SumAll(1, __arglist(2, 3, 4)) and the call looks like this:
IL_0000: ldc.i4.1 IL_0001: ldc.i4.2 IL_0002: ldc.i4.3 IL_0003: ldc.i4.4 IL_0004: call vararg int32 Program::SumAll(int32, ..., int32, int32, int32) Read that call signature carefully. After the fixed int32 comes a sentinel — ILDASM prints it as ..., the raw blob encodes it as ELEMENT_TYPE_SENTINEL (0x41) — and then the three int32 types of the arguments this particular call passed. Those three types are not in the method definition; they are in the signature blob attached to this call instruction, reached through its MemberRef (or StandAloneSig) token. A second call site elsewhere — SumAll(9, __arglist(1.5, "x")) — would carry a completely different tail (float64, string) after its own sentinel, against the very same method.
So Glass reconstructs a vararg call in two passes: it resolves the call token to find the method name and its fixed parameters, then it parses the call-site signature itself, splits it at the sentinel, and treats everything after the sentinel as the __arglist(...) arguments — matching each trailing type to the value pushed for it on the stack.
Doing it from the CLI
You do not need the UI to see this. Point glass export at the assembly and ask for the member in IL, then in C#:
$ glass export ./Interop.dll --member "M:Program.SumAll(System.Int32)" --il $ glass export ./Interop.dll --member "M:Program.Main" The first dumps the method body with the arglist and refanyval opcodes intact; the second shows the reconstructed caller, where Glass has already resolved the call-site signature and printed SumAll(1, __arglist(2, 3, 4)). Because vararg methods almost always live in interop code, this is the fast way to confirm what a shim actually forwards to a native entry point — all static, nothing executed.
Caveats and where it gets hard
The honest limits are worth stating. A vararg method's documentation-comment ID only lists its fixed parameters, because that is all the definition has — M:Program.SumAll(System.Int32) names the method even though every call passes more. If you want to know what a given call passed, you must look at the call site, not the signature of the method you clicked.
TypedReference, ArgIterator and RuntimeArgumentHandle are restricted types: they cannot be boxed, stored in fields, or used as generic arguments, so the surrounding C# a decompiler can produce around them is constrained, and an aggressively optimised loop over them may not round-trip into the neat while shown above — Glass will fall back to showing the ArgIterator calls more literally rather than invent a foreach that the type system forbids. And vararg is specifically the native variadic convention; it is not the same thing as a params array, a params Span<T>, or a params collection, all of which are ordinary DEFAULT-convention methods that Glass reconstructs without any of this machinery.
Takeaway
A vararg method hides its most interesting information from the place you would look first. The definition declares only the fixed parameters and a sentinel; the types of the variadic arguments live in every individual call site's signature, after an ELEMENT_TYPE_SENTINEL byte, and the body reads them through arglist and refanyval. Glass.NET reconstructs the method from its opcodes and the call from its call-site signature — resolving the token for the name and splitting the signature at the sentinel for the arguments — so you get new ArgIterator(__arglist) and __arglist(2, 3, 4) back from bytes that never spelled either out in one place. It is a small corner of the metadata, but it is a clean illustration of why decompiling well means reading more than the method you are looking at. Grab the free build from the Glass.NET download page and point it at the next interop shim you need to understand.
