question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add EnumValueObject

See original GitHub issue

Hey together,

before creating a pull request I wanted to retrieve some feedback for the following new type: EnumValueObject The basic idea is that have a better enumeration type in the eco-system of the CSharpFunctionalExtensions.

It has the following construct when used:

public class Language : EnumValueObject<Language>
{
   public static readonly Language German = new Language("de");

   public static readonly Language English = new Language("en");

   protected Language(string key) : base(key)
   {
   }
}

The main advantage over a “normal” enum would be:

  • Type-Safety (the Create method returns a Result<TEnumValueObject>)
  • Extendable without extension methods

To see the reference implementation which I would like to merge in this repository head over to my repository: EnumValueObject

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:22 (18 by maintainers)

github_iconTop GitHub Comments

5reactions
vkhorikovcommented, May 5, 2021

Yes, I plan to do a full-blown documentation of all features, including this one. Issue for tracking: https://github.com/vkhorikov/CSharpFunctionalExtensions/issues/255

1reaction
vkhorikovcommented, Mar 8, 2021

Great! Pushing this with v2.15.0.

Not closing the issue as a reminder to see if the code can be refactored toward inheritance.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use object literal as TypeScript enum values
TypeScript supports numeric or string-based enums only, so you have to emulate object enums with a class (which will allow you to use...
Read more >
Attaching Values to Java Enum
The Enum constructor can accept multiple values.​​ Similarly, we can add any values we want to the enum, such as the proper case...
Read more >
TypeScript: Handbook - Enums
Enums allow a developer to define a set of named constants. Using enums can make it easier to document intent, or create a...
Read more >
Enum in TypeScript
Enum in TypeScript supports reverse mapping. It means we can access the value of a member and also a member name from its...
Read more >
How To Use Enums in TypeScript
Enums in TypeScript are usually used to represent a determined number of options for a given value. This data is arranged in a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found