C
C#10mo ago
Dongle

❔ [Trimming] Enum.Parse

What do I have to specify in [DynamicallyAccessedMembers] to make sure that Enum.Parse(Type, String) works properly in trimming?
7 Replies
Dongle
Dongle10mo ago
For instance, take this code
public class SomeReflectionThing
{
private Type _enumType;
public SomeReflectionThing(Type enumType)
{
// We assume it's an enum.
_enumType = enumType;
}
public object Parse(string input)
=> Enum.Parse(_enumType, input);
}
public class SomeReflectionThing
{
private Type _enumType;
public SomeReflectionThing(Type enumType)
{
// We assume it's an enum.
_enumType = enumType;
}
public object Parse(string input)
=> Enum.Parse(_enumType, input);
}
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
Dongle
Dongle10mo ago
It involved quite some other reflection stuff as well, I was just trying to give some kind of minimal sample
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
Dongle
Dongle10mo ago
Well, in the .NET source code, the Enum(Type, string) function also isn't annotated
reflectronic
reflectronic10mo ago
my guess is that enum members are not trimmed
Accord
Accord9mo ago
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.