C# 12 lets you write a class header that doubles as its constructor:

public class OrderProcessor(int retries, ILogger log) 

It reads as if retries and log are fields of the class. They are not — not necessarily. By the time the compiler is done, one of them may have become a private field and the other may have vanished entirely, inlined into a property initializer with no trace that it was ever a parameter. Which fate each parameter meets is decided by one rule, and a decompiler has to reverse-engineer that rule from the field table and the constructor's IL. It is a precise piece of pattern matching, and a clean way to watch Glass.NET, the free .NET decompiler, turn a language convention back into source.

The real question

A primary constructor parameter is in scope everywhere in the class body. But the compiler does not keep a parameter around just because it is in scope — it keeps it only if some method body actually reads it after the constructor runs. That splits the parameters of OrderProcessor into two categories with two completely different compiled shapes:

public class OrderProcessor(int retries, ILogger log) { public int Retries { get; } = retries; // retries: only initializes a property public void Process(Order order) { for (int attempt = 0; attempt < Retries; attempt++) log.LogInformation("attempt {N} for {Id}", attempt, order.Id); // log: read in a method body } } 

retries is used once, to initialize the Retries property. log is used inside Process, long after the constructor has returned. The compiler captures log and inlines retries, and the decompiler has to recover a header that mentions both from evidence that treats them as opposites.

Capture: the parameter the compiler keeps

A primary constructor parameter that outlives the constructor has to be stored somewhere, because there is no other mechanism to carry a value from the constructor into a later method call. The compiler synthesizes a private instance field for it and has the constructor store the argument into that field. The field gets an unspeakable name — one that is legal in metadata but cannot be written in C# — so it can never collide with a real member:

Field : <log>P // synthesized capture field, note the angle brackets Type : Microsoft.Extensions.Logging.ILogger Flags : private 

The <name>P shape is the tell. Roslyn generates it specifically for captured primary constructor parameters, distinct from the <Prop>k__BackingField form it uses for auto-properties. The angle brackets guarantee you will never see this name in anyone's source.

The constructor's IL

The store happens in the generated instance constructor. Here is .ctor for OrderProcessor, lightly trimmed:

.method public hidebysig specialname rtspecialname instance void .ctor(int32 retries, class ILogger log) cil managed { ldarg.0 ldarg.2 stfld class ILogger OrderProcessor::'<log>P' // capture: log → synthesized field ldarg.0 ldarg.1 stfld int32 OrderProcessor::'<Retries>k__BackingField' // property init: retries used directly ldarg.0 call instance void [System.Runtime]System.Object::.ctor() ret } 

Read the two stfld instructions. The first stores log (ldarg.2) into <log>P — that is the capture. The second stores retries (ldarg.1) straight into the property's backing field — that is the inlined initializer. Crucially, there is no <retries>P field anywhere. retries is consumed inside the constructor and never materialized as a captured field, because nothing outside the constructor ever asks for it.

Then Process reads the capture field like any other field:

 ldarg.0 ldfld class ILogger OrderProcessor::'<log>P' ldstr "attempt {N} for {Id}" ... callvirt instance void ILogger::LogInformation(string, object[]) 

That ldfld '<log>P' inside a method body is the second half of the evidence Glass needs.

How Glass reconstructs the header

Glass puts the two halves together. It walks the field table and finds <log>P — an unspeakable name matching the captured-parameter pattern. It confirms the field is assigned exactly once, in .ctor, by an stfld whose value traces directly to a constructor argument. Then it scans the other method bodies and finds that field read (ldfld '<log>P') inside Process. A field that is written only from a constructor argument and read elsewhere, under a <name>P name, is a captured primary constructor parameter. Glass promotes it: the field disappears from the body and reappears as a parameter in the class header, and every ldfld '<log>P' becomes a plain reference to log.

One parameter leaves a synthesized field and constructor store; the other leaves only an initializer. Glass recovers both into the header, from opposite evidence.

retries takes the other road. There is no <retries>P field to find, so Glass cannot recover it from a capture. Instead it sees retries (ldarg.1) flowing into the property initializer inside the constructor, and it reconstructs public int Retries { get; } = retries; — with retries recovered as a header parameter because that is the only place an ldarg into an initializer can have come from. Both parameters come back in the header; only the mechanism differs.

The naive decompile is the thing to contrast against. Without modeling capture, a decompiler emits what the metadata literally says: a private field <log>P (or a cleaned-up log), a hand-written constructor OrderProcessor(int retries, ILogger log) that assigns it, and a separate Retries property. That is correct C#, and it recompiles, but it throws away the primary constructor syntax entirely and shows plumbing the author never wrote.

Using Glass

Open the assembly in the Visual-Studio-native UI and Glass shows the recovered primary constructor header directly; expanding the type does not resurface the <log>P field, because it has been folded back into the parameter. From the command line the same reconstruction drives batch work and diffing:

glass decompile OrderProcessor.dll --type OrderProcessor 

The CLI and MCP server emit the same source the UI renders, so a review pipeline sees class OrderProcessor(int retries, ILogger log) rather than a synthesized field and a manual constructor. Point it at your own binaries or a dependency you have legitimately obtained and are auditing before you trust it — Glass reads metadata and IL only, never running the target.

When it breaks

The reconstruction is only as strong as the evidence, and two things weaken it.

Names. Without a PDB, the real parameter name lives only in the <name>P field name. That survives a plain release build, so recovery is usually faithful. But an obfuscator that renames synthesized fields — the kind Nebula applies deliberately — erases the name. Glass then still recognizes the shape (single constructor store, reads elsewhere) but has no original identifier, so it synthesizes a stable name or, if even the <name>P pattern is gone, treats it as an ordinary field.

Ambiguity. A captured primary constructor parameter and a hand-written readonly field assigned once in a constructor are nearly indistinguishable at the IL level — both are a field written from a constructor argument and read later. The <name>P naming is what separates them. When that marker is intact Glass prints the primary constructor; when it is not, Glass cannot prove the capture and falls back to the explicit field-plus-constructor form. That fallback is deliberately conservative: it is always correct, compilable C#, just not always the tersest spelling of it. Glass would rather show a true explicit constructor than invent a primary constructor that might misattribute which parameters were captured.

Takeaway

A C# 12 primary constructor is not a runtime feature — it is a compile-time split. A parameter read in a method body becomes a synthesized <name>P field the constructor fills with stfld; a parameter used only to initialize a member is inlined and leaves no field at all. Recovering the original header means reading both signals at once: the unspeakable capture fields and their single constructor stores on one side, the member initializers on the other, and folding them back into one parameter list. Glass.NET does it statically, from metadata and IL, and when the evidence runs out it falls back to a form that still compiles rather than guessing. See the Glass docs for the full decompiler surface.