-
Notifications
You must be signed in to change notification settings - Fork 1
Migration from v7 to v8
Pawel Gerr edited this page Aug 13, 2024
·
2 revisions
- Use named parameters in Switch/Map methods
// OLD (Switch)
productType.Switch(ProductType.Groceries, () => logger.Information("Switch with Action: Groceries"),
ProductType.Housewares, () => logger.Information("Switch with Action: Housewares"));
// NEW (Switch)
productType.Switch(groceries: () => logger.Information("Switch with Action: Groceries"),
housewares: () => logger.Information("Switch with Action: Housewares"));
// OLD (Map)
var returnValue = productType.Map(ProductType.Groceries, "Map: Groceries",
ProductType.Housewares, "Map: Housewares");
// NEW (Map)
var returnValue = productType.Map(groceries: "Map: Groceries",
housewares: "Map: Housewares");
- Use
SwitchMethods
/SkipMapMethods
to control the generation of the methodsSwitch
/Map
// OLD
[SmartEnum<string>(SkipSwitchMethods = true,
SkipMapMethods = true)]
public sealed partial class ProductType
{
...
}
// NEW
[SmartEnum<string>(SwitchMethods = SwitchMapMethodsGeneration.None,
MapMethods = SwitchMapMethodsGeneration.None)]
public sealed partial class ProductType
{
...
}