Skip to content

Missing features compared to Enums.NET (feature parity discussion) #247

@simonebortolin

Description

@simonebortolin

Hi 👋

while evaluating NetEscapades.EnumGenerators as an alternative to Enums.NET, I noticed that several advanced enum/flags features are currently missing.

This is not necessarily a problem (the goals of the library are different), but I think it would be useful to document or discuss possible gaps — especially for users migrating from Enums.NET.

Below is a list of notable missing APIs with short explanations.

1. Flag operations

Enums.NET provides a rich set of utilities for [Flags] enums, which are currently not available.

Missing APIs (https://github.com/TylerBrinkley/Enums.NET/blob/master/Src/Enums.NET/FlagEnums.cs)

  • HasAnyFlags()
  • HasAnyFlags(otherFlags)
  • HasAllFlags()
  • HasAllFlags(otherFlags)
  • ToggleFlags()
  • GetFlags()
  • GetFlagMembers()
  • GetFlagCount()
  • GetAllFlags()
  • IsValidFlagCombination()

2. Formatting of flag combinations

Missing API

  • FormatFlags(...) (or similat ToString with FormatFlags paramters)
    Current limitation

The generator explicitly falls back to:

  • default ToString() for non-trivial flag combinations:
if (enumToGenerate.HasFlags)
        {
            // We currently don't handle ToString of custom flag-combinations, so lets fall back to the default
            sb.Append(
                """

                                _ => value.ToString(),
                            };
                """);
        }

This means:

  • no control over delimiter (, vs custom)
  • no deterministic formatting
  • no handling of invalid combinations

3. Advanced parsing & validation

Missing capabilities

  • Validation strategies (e.g. reject undefined values)
  • Safe conversion with overflow checks
  • Differentiation between:
    • undefined values
    • invalid flag combinations

4. Reflection-like enum metadata APIs

Missing APIs

  • GetMembers()
  • GetNames()
  • GetValues()
  • GetMemberCount()

5. Handling of edge cases

Enums.NET explicitly handles:

  • non-contiguous enums
  • duplicated values (aliases)
  • “primary” enum members
  • invalid / undefined values
  • mixed flag combinations

I got a bit of help from Copilot to write this issue; I know there was a similar issue at https://github.com/andrewlock/NetEscapades. EnumGenerators/issues/240 and, to be honest, I fully agree with the statement

I’ve been very hesitant to add new features to the library ‘just because I can’, especially where there are simple alternatives that don’t force everyone to deal with the noise of new methods

but I also think there should be a library that has everything, not five different libraries for the same thing, perhaps with an opt-in/opt-out mechanism so that the generation of certain things can be enabled or disabled via attributes. Also with a view to libraries governance and reducing their excessive use....

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