SteveDunn / Vogen

A semi-opinionated library which is a source generator and a code analyser. It Source generates Value Objects
Apache License 2.0
781 stars 45 forks source link

Handle C# 12 primary constructors for classes #563

Closed SteveDunn closed 3 months ago

SteveDunn commented 6 months ago

Describe the feature

Vogen should handle primary constructors in classes. It handles them in records. In particular, look at the analyzers to see if they currently allow a back door into creating a non-valid value object.

SteveDunn commented 3 months ago

This code...

[ValueObject<int>]
public partial class MyVo(int Value);

...results in this...

Error VOG008 : Cannot have user defined constructors, please use the From method for creation.

Same for record class and record struct and struct