Skip to content

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

Closed

Description

@kzu

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: #9092

Activity

  1. ReubenBond commented on Nov 16, 2025

    @ReubenBond
    Member

    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.

  2. locked and limited conversation to collaborators on Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions