Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Test for Enum.IsDefined in TypeConverter.ToEnum is broken in the face of [Flags] #599

Copy link
Copy link
@ryanmolden

Description

@ryanmolden
Issue body actions

The test in CommandLine.Core.TypeConverter.ToEnum which calls Enum.IsDefined is broken if the given enum has the Flags attribute (i.e it ONLY checks if the EXACT given value maps to an enum member, that will never be true for flag combinations of enum members).

This prevents having strongly types enum arguments that are passed on the command line, which is not an uncommon thing (especially in Windows where TONS of interesting data is described via flag style enums).

A workaround is to pass as a raw int/uint/ulong/whatever and just cast inside the program, but thats less ideal than just typing the command line param as what it actually is.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.