mirror of
https://github.com/icsharpcode/ILSpy.git
synced 2026-10-12 02:15:58 +00:00
The decompiler already reconstructs primary constructor syntax for most non-record shapes (UsePrimaryConstructorSyntaxForNonRecordTypes, C# 12); Issue3598.cs pins the ctor-vs-primary-ctor decision matrix. The new green PrimaryConstructors fixture pins the remaining shapes: parameter capture in methods, iterators, async methods, lambdas, and local functions; double use of a parameter in a field initializer and a method body (CS9124); a parameter both passed to the base constructor and captured (CS9107); mutation of a captured parameter in classes and structs; parameter-member shadowing in both directions; generic types; readonly structs; in parameters; attributes on primary constructor parameters; unsafe pointer parameters; statics and nested types beside a captured parameter. An empty primary constructor prints as a plain class declaration (equivalent), pinned via EXPECTED_OUTPUT. PrimaryConstructorAttributes is Assert.Ignore'd: attributes applied to the primary constructor via the [method:] target are present on the .ctor in metadata but silently dropped from the decompiled output for both classes and structs, losing semantics (e.g. [Obsolete]). The fixture is the desired output; all four Roslyn 4.14/latest debug/opt configs compile it and fail only at the output comparison. Assisted-by: Claude:claude-fable-5:Claude Code