How Glass recovers C# primary constructor parameters from compiled IL
C# 12 primary constructors let a class header double as its constructor, but the compiler treats each parameter differently. Parameters used only to initialize members are consumed inside the constructor, while those read by method bodies are captured into synthesized private fields. These synthesized fields carry angle-bracketed names that never appear in source code. The Glass.NET decompiler recognizes this pattern by checking that such a field is assigned once from a constructor argument and read elsewhere. It then restores the field as a parameter in the class header.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in