CodeHaacks icon indicating copy to clipboard operation
CodeHaacks copied to clipboard

GetArgumentValue in AttributeExtensions can not handle enums

Open robgha01 opened this issue 8 years ago • 2 comments

First and foremost, well done and good post i stumbled on youre old post from 2010 👍 "http://haacked.com/archive/2010/08/05/copying-attributes.aspx/" and wanted to pitch in for an update for enums.

To fix proper handlings of enum for a constructors replace: var value = argument.Value; with

object value;
if (argument.ArgumentType.IsEnum)
{
    value = Enum.ToObject(argument.ArgumentType, argument.Value);
}
else
{
    value = argument.Value;
}

robgha01 avatar Feb 15 '17 22:02 robgha01

Why don't you submit that as a Pull Request? :smile:

haacked avatar Feb 15 '17 22:02 haacked

@Haacked done :)

robgha01 avatar Feb 16 '17 10:02 robgha01