orleans icon indicating copy to clipboard operation
orleans copied to clipboard

Add support for [Id] annotations on record primary constructor parameters

Open kzu opened this issue 2 months ago • 1 comments

Now that proper support for records (in referenced assemblies too) is implemented, it would be great to be able to annotate the ctor parameter itself, rather than the more verbose (and harder to discover) syntax for annotating the backing property generated for it. This would allow to go from this:

public record Deposit([property: Id(0)] decimal Amount)

to this:

public record Deposit([Id(0)] decimal Amount)

The generator could just treat an Id attribute on a same-name ctor parameter as a property of the type as if was applied to the property, simplifying its usage in this particular scenario and saving non-trivial amount of keystrokes (for even just a few parameters, having to add property: to every property can quickly become annoying).

Related: https://github.com/dotnet/orleans/issues/9092

kzu avatar Nov 16 '25 19:11 kzu

This would be great, if someone can make it work. It might involve finding the primary ctor for a record and matching the attributes on the ctor params with the resulting properties.

ReubenBond avatar Nov 16 '25 19:11 ReubenBond