Skip to content

Support EnC on records and with expressions #44877

@jcouv

Description

@jcouv

This issue is referenced in code.

We should either report rude edit whenever a record type is edited in any way or implement full support for EnC.

This needs to include

  • symbol matching record symbols

  • adding new non-predefined members

  • adding/removing predefined members: EqualityContract, Equals(R), GetHashCode(), ToString(), PrintMembers() and copy-constructor
    User defined one can be added and removed, which should result in updating the compiler generated one and vice versa. EnC already implements similar logic for parameter-less constructors. Inherited members also need to be considered.

    Spec:

    In addition to the members declared in the record body, a record type has additional synthesized members. Members are synthesized unless a member with a "matching" signature is declared in the record body or an accessible concrete non-virtual member with a "matching" signature is inherited. Two members are considered matching if they have the same signature or would be considered "hiding" in an inheritance scenario.

  • Primary constructor

    • Synthesized Deconstruct vs user-defined
    • Using parameters and expression variables of the primary constructor in a closure
record D(int X)
{
    public int Y { get; set; } = new Func<int, int>(a => a + X).Invoke(1);
}
record C(int X)
{
    public C(int x, Func<int> f)
        : this(x)
    {
    }
}

record D(int X) : C(F(out int z), () => z)
{
}

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions