Refactor metadata attribute support and add support for [EnumMember]
#163
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In this PR, you can only choose one source of "metadata attribute" to use for enums:
[Display][Description][EnumMember]<- NewYou can select the source to use by setting the
MetadataSourceproperty on the[EnumExtensions]attribute e.g.Alternatively, you can use
MetadataSource.Noneto choose none of the metadata attributes. In this case, the overloads that take auseMetadataAttributesparameter will not be emitted.You can set the default metadata source to use for a whole project by setting the
EnumGenerator_EnumMetadataSourceproperty in your project:The default value is
EnumMemberAttribute- TBC, I'm torn between the default being[Display]and[EnumMember]:[Display]and against[EnumMember]:[Display]is already being used by people with the generator, and is often used in a web context for decorating properties as it's a standard DataAnnotations attribute .[EnumMember]is an entirely new attribute, so making that the default would be breaking for literally everyone upgrading the package.[EnumMember]and against[Display]:[EnumMember]is available out of the box, whereas[Display]requires a package for .NET FX and .NET Standard 2.0. Arguably it makes more sense as being the default as it's specifically about serialization.Fixes #73