Skip to content

NotificationsGenerator: Support record targets #163

@BoBoBaSs84

Description

@BoBoBaSs84

Is your feature request related to a problem? Please describe.
GenerateNotificationsAttribute targets only AttributeTargets.Class and its generator processes field declarations. C# record types (both record class and record struct) are increasingly used as lightweight view-model / DTO bases, and users cannot apply [GenerateNotifications] to them today.

Describe the solution you'd like

  • Extend attribute usage and generator predicate to also accept RecordDeclarationSyntax.
  • For records, generate notification-enabled init-only properties via init setters (or set if the attribute opts in) to keep the record semantic intact.
  • Raise a DiagnosticDescriptor warning when [GenerateNotifications] is applied to a positional record (primary-constructor params cannot easily be intercepted).

Describe alternatives you've considered
Converting records to regular classes — defeats the benefit of the concise record syntax.

Additional context
Affected files: src/BB84.SourceGenerators/NotificationsGenerator.cs, src/BB84.SourceGenerators/Attributes/GenerateNotificationsAttribute.cs, src/BB84.SourceGenerators/Analyzers/DiagnosticDescriptors.cs.

Metadata

Metadata

Assignees

Labels

featureNew feature or request

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions