Is your feature request related to a problem? Please describe.
C# records already generate a PrintMembers method and ToString() override, but their output format is fixed by the compiler. Users who want a different format (matching the ClassName { Prop = val } style used by this generator) or who want to exclude specific properties from the record's ToString() cannot use the generator today since it only targets ClassDeclarationSyntax.
Describe the solution you'd like
Support record and record struct declarations by:
- Allowing
GenerateToStringAttribute on record types (AttributeTargets.Class | AttributeTargets.Struct).
- Detecting
RecordDeclarationSyntax in the pipeline.
- Generating a
sealed override of PrintMembers(StringBuilder) or a direct ToString() override as appropriate.
Describe alternatives you've considered
- Telling users to manually override
PrintMembers, but this negates the generator's value.
- Ignoring records since they already have a
ToString(), but the exclusion and formatting features are still valuable.
Additional context
Records use PrintMembers internally. The generator should decide whether to override PrintMembers (preserving the record contract) or override ToString() directly (potentially with sealed to prevent further overrides in derived records).
Is your feature request related to a problem? Please describe.
C# records already generate a
PrintMembersmethod andToString()override, but their output format is fixed by the compiler. Users who want a different format (matching theClassName { Prop = val }style used by this generator) or who want to exclude specific properties from the record'sToString()cannot use the generator today since it only targetsClassDeclarationSyntax.Describe the solution you'd like
Support
recordandrecord structdeclarations by:GenerateToStringAttributeon record types (AttributeTargets.Class | AttributeTargets.Struct).RecordDeclarationSyntaxin the pipeline.sealed overrideofPrintMembers(StringBuilder)or a directToString()override as appropriate.Describe alternatives you've considered
PrintMembers, but this negates the generator's value.ToString(), but the exclusion and formatting features are still valuable.Additional context
Records use
PrintMembersinternally. The generator should decide whether to overridePrintMembers(preserving the record contract) or overrideToString()directly (potentially withsealedto prevent further overrides in derived records).