Entity Framework Core Support
Renamed extension method AddEnumAndValueObjectConverters to AddValueObjectConverters
Use SmartEnumAttribute<T> instead of EnumGenerationAttribute
Use SmartEnumAttribute<T> instead of IEnum<T>
// OLD
[ EnumGeneration ( KeyPropertyName = "Name" ) ]
public sealed partial class ProductCategory : IEnum < string >
{
public static readonly ProductCategory Fruits = new ( "Fruits" ) ;
public static readonly ProductCategory Dairy = new ( "Dairy" ) ;
}
// NEW
[ SmartEnum < string > ( KeyPropertyName = "Name" ) ]
public sealed partial class ProductCategory
{
public static readonly ProductCategory Fruits = new ( "Fruits" ) ;
public static readonly ProductCategory Dairy = new ( "Dairy" ) ;
}
Use SmartEnumAttribute<T>(IsValidatable = true) instead of IValidatableEnum<T>
// OLD
public sealed partial class ProductCategory : IValidatableEnum < string >
{
public static readonly ProductCategory Fruits = new ( "Fruits" ) ;
public static readonly ProductCategory Dairy = new ( "Dairy" ) ;
}
// NEW
[ SmartEnum < string > ( IsValidatable = true ) ]
public sealed partial class ProductCategory
{
public static readonly ProductCategory Fruits = new ( "Fruits" ) ;
public static readonly ProductCategory Dairy = new ( "Dairy" ) ;
}
Use KeyMemberName instead of KeyPropertyName to change the name of the key member.
// OLD
[ SmartEnum < string > ( KeyPropertyName = "Name" ) ]
public sealed partial class ProductCategory
{
}
// NEW
[ SmartEnum < string > ( KeyMemberName = "Name" ) ]
public sealed partial class ProductCategory
{
}
Use ValueObjectKeyMemberEqualityComparerAttribute instead of static IEqualityComparer<string> KeyEqualityComparer to change the equality comparer.
// OLD
[ SmartEnum < string > ]
public sealed partial class ProductCategoryWithCaseSensitiveComparer
{
public static IEqualityComparer < string > KeyEqualityComparer => StringComparer . Ordinal ;
}
// NEW
[ SmartEnum < string > ]
[ ValueObjectKeyMemberEqualityComparer < ComparerAccessors . StringOrdinal , string > ]
public sealed partial class ProductCategoryWithCaseSensitiveComparer
{
}
Use ValueObjectAttribute<T> for simple value objects and remove the key member, where T is the type of the key member.
Optional: Use KeyMemberName, KeyMemberAccessModifier and KeyMemberKind to change the generation of the key member.
// OLD
[ ValueObject ]
public sealed partial class ProductName
{
private string Value { get ; }
}
[ ValueObject < string > ]
public sealed partial class ProductName
{
}
Use ComplexValueObjectAttribute for complex value object
// OLD
[ ValueObject ]
public sealed partial class Boundary
{
public decimal Lower { get ; }
public decimal Upper { get ; }
}
// NEW
[ ComplexValueObject ]
public sealed partial class Boundary
{
public decimal Lower { get ; }
public decimal Upper { get ; }
}
Use ValueObjectKeyMemberComparerAttribute/ValueObjectKeyMemberEqualityComparerAttribute instead of ValueObjectMemberEqualityComparer/ ValueObjectMemberComparer to change the equality comparer and comparer.
// OLD
[ ValueObject ]
public sealed partial class ProductName
{
[ ValueObjectMemberEqualityComparer < ComparerAccessors . StringOrdinalIgnoreCase , string > ]
[ ValueObjectMemberComparer < ComparerAccessors . StringOrdinalIgnoreCase , string > ]
private string Value { get ; }
}
// NEW
[ ValueObject < string > ]
[ ValueObjectKeyMemberComparer < ComparerAccessors . StringOrdinal , string > ]
[ ValueObjectKeyMemberEqualityComparer < ComparerAccessors . StringOrdinal , string > ]
public sealed partial class ProductName
{
}
Use ValidationError instead of ValidationResult
// OLD
[ ValueObject ]
public sealed partial class Boundary
{
public decimal Lower { get ; }
public decimal Upper { get ; }
static partial void ValidateFactoryArguments ( ref ValidationResult ? validationResult , ref decimal lower , ref decimal upper )
{
if ( lower <= upper )
return ;
validationResult = new ValidationResult ( $ "Lower boundary '{ lower } ' must be less than upper boundary '{ upper } '",
new [ ] { nameof ( Lower ) , nameof ( Upper ) } ) ;
}
}
// NEW
[ ComplexValueObject ]
public sealed partial class Boundary
{
public decimal Lower { get ; }
public decimal Upper { get ; }
static partial void ValidateFactoryArguments ( ref ValidationError ? validationError , ref decimal lower , ref decimal upper )
{
if ( lower <= upper )
return ;
validationError = new ValidationError ( $ "Lower boundary '{ lower } ' must be less than upper boundary '{ upper } '") ;
}
}