This is another thing that changed from Elements 2409 to 2513 and 2521, and currently breaks my code.
I need to assign a value to some enum, given the string representation of enum value. So far, I solved the problem by defining
{$IFDEF JAVA}
type
EnumType<T> = public T;
{$ELSE} // for .NET
type
EnumType<T> = public extension class(T)
where T is record;
public
class method ValueOf(aStr: String): T;
begin
exit T(&Enum.Parse(typeOf(T), aStr));
end;
end;
{$ENDIF}
This allowed me to make the assignments such as
SomeEnumType e := EnumType<SomeEnumType>.ValueOf("SomeStringValue");
I admit the solution is somewhat tricky, but it worked very well for any enum type, without the need to tamper with typeOf(), strange methods with many arguments, IFDEFS or similar. But now it does not compile any more and I cannot think of a similarly simple solution. Any ideas or suggestions? Is there any existing solution that I keep overlooking in the documentation? If not, I suggest a new feature: platform-independent mapping from string to enum value.