NeVeSpl / NTypewriter

File/code generator using Scriban text templates populated with C# code metadata from Roslyn API.
https://nevespl.github.io/NTypewriter/
MIT License
117 stars 24 forks source link

IEnumValue should implement ISymbolBase #83

Closed xumix closed 11 months ago

xumix commented 1 year ago

Hi! Thanks for your great lib! It looks like IEnumValue lacks ISymbolBase inheritance thus there is no way to get Declaring type info

NeVeSpl commented 1 year ago

The idea was to treat enum values as ordinal constant literals, it is how they are perceived from a programmer's perspective.

IEnum will get EnumUnderlyingType or UnderlyingType property in the next version.

xumix commented 1 year ago

Enum values are Members AFAIR Thanks for your fast reaction!

NeVeSpl commented 1 year ago

Yes, they are implemented as a const field by the runtime, but I preferred to use language-level abstraction.

xumix commented 11 months ago

Wow, looks like I misread your comment: I expected IEnumValue to get DeclaringType but instead you implemented UnderlyingType for IEnum. So I expected ability to get the Type that defines IEnumValue, so I could use it like this:

let someConst = {{enumValue.DeclaringType}}.{{enumValue.Value}};

but actually got the ability to get Enum's base type which is completely different feature

NeVeSpl commented 11 months ago

OMG, I have no idea how I messed up Declaring type with UnderlyingType , I should not write code during summer vacations :D.

Anyway, why would you need DeclaringType on IEnumValue? IEnumValue as I remember is only available in the context of IEnum.Values, thus declaring type should always be known ....