❔ Encapsulate an enum from legacy code.

Hi everyone,

I'd like to encapsulate (?) an enum which had a lot of implements in legacy code. I want to modify and add more elements to the enum.
The problem is the legacy code is not ... in a good shape and modifying it directly produces a handful of bugs and time-consuming errors.
I have tried using 2 methods:
- The first one is to make the class that hold the enum become an abstract class and migrate all its code to a derived class. This method helps me a lot with other enum-free classes. But as you know, enum can't be abstract. (Or is it?)
- The second one is to convert the enum to an IComparable class (Like this https://learn.microsoft.com/en-us/dotnet/architecture/microservices/microservice-ddd-cqrs-patterns/enumeration-classes-over-enum-types). But the problem is legacy codes use switch/case which requires constants to compare.

If anyone has experience with this or has some tips or ideas, I would really appreciate your help.
Thank you for taking the time to read my question.
you can use names as strings
or map strings to unique ids
or make those ids constants
and increment the constants manually in the code
there's no other way
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.