Skip to content

EnumeratedValueArgument w/ Enum #56

@Kritner

Description

@Kritner

At a glance, I'm not seeing a method of using an enum along with EnumeratedValueArgument, specifically when using a attribute style parsing target.

I was hoping for something like:

        public enum MyEnum
        {
            One,
            Two
        }

        [EnumeratedValueArgument(typeof(MyEnum), 'm', "myEnum")]
        public MyEnum ParsedEnum;

or perhaps:

public enum MyEnum
        {
            One,
            Two
        }

        public static Dictionary<MyEnum, string> EnumMapping = new Dictionary<MyEnum, string>()
        {
            { MyEnum.One, "do something with one" },
            { MyEnum.Two, "do something with two" },
        };

        [EnumeratedValueArgument(typeof(string), 'm', "myEnum", AllowedValues = string.Join(";", EnumMapping.Keys)]
        public string ParsedEnum;

but that gives:

An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type

any ideas on this sort of functionality?

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