Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support EnC on records and with expressions #44877

Closed
jcouv opened this issue Jun 5, 2020 · 4 comments · Fixed by #51926
Closed

Support EnC on records and with expressions #44877

jcouv opened this issue Jun 5, 2020 · 4 comments · Fixed by #51926

Comments

@jcouv
Copy link
Member

jcouv commented Jun 5, 2020

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)
{
}
@jinujoseph jinujoseph added the Bug label Jun 7, 2020
@jinujoseph jinujoseph added this to the 16.7 milestone Jun 7, 2020
@jinujoseph jinujoseph modified the milestones: 16.7, Backlog, 16.8 Jun 19, 2020
@jcouv
Copy link
Member Author

jcouv commented Jul 25, 2020

@tmat Is there bandwidth to address this in 16.8? If yes, who should we assign this to?

@tmat
Copy link
Member

tmat commented Jul 25, 2020

Unlikely. We still don't have support for switch expressions.

@tmat
Copy link
Member

tmat commented Jul 25, 2020

I think we would just update the analyzer to report rude edits for all C# 9 features, unless they just work.

@tmat
Copy link
Member

tmat commented Oct 15, 2020

Updated description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants