Replies: 1 comment 1 reply
-
Hi Steve, First I'd like to say thank you for making this library, its absolutely fantastic! I've recently worked with it in my project steam-lancache-prefill and it works very well. I'd like to give you some feedback by trying to answer your question When I first heard about source generators and what they were capable of doing, my immediate thought was to implement something like Intellenum. For context, I've been using my own smart enum implementation (source) that uses reflection. I've also been playing around with publishing trimmed assemblies as well as Ahead of Time compilation. My aim with having a source generator smart enum implementation is that it would allow me to remove the usage of Reflection throughout my codebase, thus enabling better compatibility with Trimming and AOT. For a command line application removing reflection could mean that the trimmer could be more aggressive, reducing the executable size even further. A smaller file size could mean potentially faster startup times, thus increasing the responsiveness of the app. Now in reality, its actually likely that there are other usages of reflection throughout the codebase and libraries that it uses, so using Intellenum might not have as large of an impact. Despite the fact that there may only be a small set of scenarios where the usage of Intellenum has an advantage, I see no scenarios where there are any disadvantages either. Beyond the cost of implementation and maintenance, there aren't any drawbacks to consider and balance. I hope that you can find some of my thoughts helpful. Again, thank you for the great work! Cheers! |
Beta Was this translation helpful? Give feedback.
-
We have libraries like SmartEnum. With these, all enums are classes and derive from a base class.
With Intellenum, you can have structs as well as as classes and don't need to derive from anything (it's attribute driven, like Vogen)
Intellenum is based off the Vogen source generator which is a fast wrapper around primitives. Vogen brings the following benefits to wrapping primitives:
struct
, then your ValueObject can be a structdefault
a ValueObjectVogen is beneficial because there could be thousands or millions of instances of these ValueObjects.
I think there is less benefit for Intellenum because:
The only benefit I can see for Intellenum over other such libraries is the use of the analyzers. To recap, in Vogen, we have the following analyzers:
Those don't make particular sense with enums, however, I could see different analyzers that would be useful for enums (I'll think in the background about what those might be, but suggestions more than welcome!)
My question is: do we need a source generate for enums? We could, and this project goes about 75% of the way there, but is there any value over similar libraries like
SmartEnums
orFastEnums
?Beta Was this translation helpful? Give feedback.
All reactions