Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for NRT #511

Open
fiseni opened this issue Apr 5, 2024 · 1 comment
Open

Add support for NRT #511

fiseni opened this issue Apr 5, 2024 · 1 comment

Comments

@fiseni
Copy link

fiseni commented Apr 5, 2024

Hi,

It would be nice to enable the NRT in the library. It will offer a better experience for the consumers and fix some subtle issues.
But. I don't think we'll be able to do that with the current structure (at least I couldn't). I'd suggest constraining the TValue generic parameter to struct.

public abstract class SmartEnum<TEnum, TValue> :
    ISmartEnum,
    IEquatable<SmartEnum<TEnum, TValue>>,
    IComparable<SmartEnum<TEnum, TValue>>
    where TEnum : SmartEnum<TEnum, TValue>
    where TValue : struct, IEquatable<TValue>, IComparable<TValue>

Conceptually, that makes sense. But, it would require some substantial refactoring and will be a major breaking change. I'm not sure if anyone is using reference types as enum values, but there are such users probably.

@fiseni
Copy link
Author

fiseni commented Apr 5, 2024

Ok, I see a lot of consumers are using string as the enum value. It's even provided as a sample in docs here. So, constraining to struct won't be a good idea. I'll give it another try enabling the NRT in the current form.

@fiseni fiseni changed the title Define the TValue as struct and enable NRT Add support for NRT Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant