glideapps/quicktype

[FEATURE]: Add `partial` keyword to properties

justindbaur opened this issue · 0 comments

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