Skip to content

Rename tracking doesn't work on positional members #44560

@jcouv

Description

@jcouv

image

Scenario 1 (trigger rename from parameter list in declaration):

record Person(string First, string Second); // change `Second` to `Renamed`

// corresponding synthesized code
class Person
{
     public Person(string First, string Second) { this.First = First; this.Second = Second; } // synthesized primary constructor
     string First { get; init; } 
     string Second { get; init; } 
     ...
}

Expected:

Person p = new Person(First: "", Second: ""); // `Second` should be renamed here (works!)
_ = p.Second; // property `Second` should be renamed too

record Student(string First, string Second, int Id) : Base(First: First, Second: Second); // `Second:` should renamed too, like `Student.Second` should be renamed as well (same property, but good to confirm with IDE design)

Scenario 2 (trigger rename from parameter list in declaration, with user-defined property):

record Person(string First, string Second) // `Second` here is just a parameter, no longer refers to property
{
    public string Second { get { ... } init { ... } } = Second /* parameter */;
}

Expected:

// same changes as in scenario 1
// we should rename the user-defined property as well (need to confirm with IDE design review)

Scenario 3 (trigger from usage site):

Person p = new Person(First: "", Second: ""); // trigger the rename from `Second:`
_ = p.Second; // trigger the rename from usage of the property
record Person(string First, string Second)
{
    public string Second { get { ... } init { ... } } = Second /* parameter */; // trigger rename from property declaration
}

Misc

How do link parameter and property symbols?

  1. add a compiler API (for example .AssociateSymbol, problematic because of language design and metadata)
  2. do it manually (syntax shows that we have "record", you can tell which constructor is primary, allows us to find corresponding properties)

Relates to #40726 (test plan for "records")

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions