Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Flag Enums are not supported #8

Open
MichaelHancock opened this issue Feb 19, 2020 · 0 comments
Open

Flag Enums are not supported #8

MichaelHancock opened this issue Feb 19, 2020 · 0 comments
Assignees

Comments

@MichaelHancock
Copy link

Flag Enums produce an empty string when calling GetDisplayName(). It might be preferable if it produced a comma separated list in this case.

e.g. "Walk, Drive"

If we don't want to support it we could through an exception so this doesn't fail quietly.

using System;
using Enable.EnumDisplayName;

namespace ConsoleApp
{
    [Flags]
    public enum Commute
    {
        [EnumDisplayName("Cycle")]
        Bike = 1,
        [EnumDisplayName("Drive")]
        Car = 2,
        [EnumDisplayName("Walk")]
        Walk = 4
    }

    class Program
    {
        static void Main(string[] args)
        {
            var commuteWalk = Commute.Walk;

            Console.WriteLine(commuteWalk.GetDisplayName()); // "Walk"

            var commuteWalkDrive = Commute.Walk | Commute.Car;

            Console.WriteLine(commuteWalkDrive.GetDisplayName()); // ""
        }
    }
}
@MichaelHancock MichaelHancock self-assigned this Feb 19, 2020
MichaelHancock pushed a commit that referenced this issue Apr 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant