-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Description
I was recently playing with positional records and overriding the property declarations, e.g.:
public record Person(string FirstName, string LastName) {
public string FirstName { get; set; }
public string LastName { get; set; }
}I was surprised to find that the constructor that is emitted in this case does not actually wire up the primary constructor parameters with the explicitly declared properties. I understand that this is because the implicit property declarations which are being overridden include an initializer which wires up the property.
In my opinion this would be an easy detail to miss and there is currently no indication that it's happening. I think it would be useful if the compiler would warn (or otherwise indicate) when the primary constructor parameter is unused.
Reactions are currently unavailable