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

[FEATURE]: Add partial keyword to properties #2647

Open
justindbaur opened this issue Sep 5, 2024 · 0 comments
Open

[FEATURE]: Add partial keyword to properties #2647

justindbaur opened this issue Sep 5, 2024 · 0 comments

Comments

@justindbaur
Copy link

Add a setting to allow the partial keyword to be added to generated property.

Context (Input, Language)

Output Language: C#

Description

The partial keyword is added to class definitions in the outputted C# code, this enables you to add properties/methods to classes without having to make changes to the outputted code. But since the resulting properties don't also have the partial keyword you aren't able to make change to the properties. Having the properties be partial would mean you can add attributes to the properties like [Obsolete].

Current Behaviour / Output

public partial class MyClass
{
    public int MyProp { get; set; }
}

Proposed Behaviour / Output

// <auto-generated />
public partial class MyClass
{
    public partial int MyProp { get; set; }
}

// my code:
public partial class MyClass
{
    [Obsolete("Use AnotherProp instead")]
    public partial int MyProp { get; set; }
}

Solution

Add a setting that turns on adding the partial keyword to properties. This is a new feature added in C# 13 (see). So it should be default off but can be turned on when it is useful.

Alternatives

N/A

Context

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

No branches or pull requests

1 participant