Skip to content

GetArgumentValue in AttributeExtensions can not handle enums #12

@robgha01

Description

@robgha01

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions