DEV Community

Discussion on: Value-Based Attributes in C#

Collapse
 
entomy profile image
Patrick Kelly

While the implementation is handy, the naming doesn't fit with established conventions nor what this is doing. "value attribute" proposes the attribute is a value type, as is the case with ValueTuple, ValueTask, ValueStringBuilder, and more. What you have, is an attribute defining key-value pairs: an association.

Collapse
 
zacharypatten profile image
Zachary Patten

Agreed. I couldn't think of a name... if you have ideas I'm all ears. :) I don't really like ValueAttribute

Collapse
 
entomy profile image
Patrick Kelly

First thing that comes to mind is "data". It's general enough and makes sense for what is a "data entry". If I think of anything more clear I'll let you know.

Thread Thread
 
zacharypatten profile image
Zachary Patten

Another user sugguested TagAttribute so a use case would be [Tag("Name", "My Name")] and the extension method could just be GetTag rather than GetTagAttribute as GetTag is probably clear enough what it is doing. I think I decided to go with that and will update the code and this article when available.