mirror of https://github.com/icsharpcode/ILSpy.git
Browse Source
C# cannot declare a named property with parameters: only the type's default member gets indexer syntax, and reusing it via [IndexerName] collapses for types with several differently-named indexed properties, static properties, or explicit interface implementations. Emitting the accessors as ordinary methods is the only fully general compilable form, matches how C# consumes such properties (Roslyn exposes the accessors of properties it cannot bind as regular methods, the same pattern C# 14 made user-facing for extension-member disambiguation), and round-trips call sites to identical IL. Call sites already lower to direct accessor calls. The property-level attributes are kept on the first accessor under the 'property:' attribute target: it is not valid on methods, so csc emits nothing for it (CS0657 warning) and recompilation neither loses the attributes from the source nor misapplies them to the accessor. A comment on the first accessor documents the deliberate deviation. Visual Studio's metadata-as-source view drops such properties' attributes entirely. The assembly tree and tooltips are unaffected: they keep rendering the property node with its parameter list. Known limitation, inherent to any C# projection: recompiling the output produces plain methods, so VB.NET consumers of the recompiled assembly lose property syntax. Assisted-by: Claude:claude-fable-5:Claude Codepull/3925/head
5 changed files with 103 additions and 31 deletions
Loading…
Reference in new issue