[API Proposal]: Create fullnameof(element)
expression
#5200
-
Background and motivationWe have an excellent timesaving and error avoidance expression called In some other cases (usually logging-related events, debugging, even some errors validations) developers need the full name of a class with the namespace or the full name of a member with the class name. The first thing require a hard-coded string (which you'll have to update every time you rename the class or the namespace, or even if you modify the hierarchy of namespaces) or a smelly API ProposalAn expression like said: fullnameof(ElementToGetName) API Usage// A example class
namespace Store.Shelf.Box { class Potato { int Quality {get;} } }
// A example call;
var box_fullName = fullnameof(Box); //It returns "Store.Shelf.Box"
var potato_fullName = fullnameof(Potato); //It returns "Store.Shelf.Box.Potato"
var quality_fullName = fullnameof(Potato.Quality); //It returns "Potato.Quality", right now nameof(Potato.Quality) returns "Quality" RisksAt first sight, no one i can see. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
This is quite similar to and a partial duplicate of #701. |
Beta Was this translation helpful? Give feedback.
-
I'm proposing making It would be great to hear in that thread about real-world use cases that support doing this, as well as real-world use cases for |
Beta Was this translation helpful? Give feedback.
This is quite similar to and a partial duplicate of #701.