Configure Value Object behavior with UnitGenerateOptions
masterYou can customize the generated code by passing UnitGenerateOptions flags to the [UnitOf] attribute. This allows you to enable specific features like arithmetic operators, comparison, or serialization support.
Commonly used options include:
ArithmeticOperator: Enables arithmetic operations between the value object and itself.ValueArithmeticOperator: Enables arithmetic operations between the value object and its underlying primitive type.Comparable: Enables comparison operators (>,<, etc.).MinMaxMethod: GeneratesMinandMaxstatic methods.JsonConverter/MessagePackFormatter/DapperTypeHandler/EntityFrameworkValueConverter: Enables native serialization/persistence for the specific framework.
[UnitOf<int>(UnitGenerateOptions.ArithmeticOperator | UnitGenerateOptions.Comparable)]
public readonly partial struct Hp;