Fully-qualified names with nameof
#5483
-
SummaryI suggest that C# include a variant of
MotivationI often find myself wanting to map my namespace hierarchy to certain runtime hierarchies. For example, in the Unity game engine, I can define public methods for designers that appear nested within toolbar menus, and I typically like the nesting of the menus to match the nesting of my namespaces for easier maintenance. So if I have a method with fully qualified name [MenuItem($"{nameof(MyNamespace)}/{nameof(MyNamespace.SubNamespace)}/{nameof(MyType)}/{nameof(DoStuff)}")]
public static void DoStuff() => // ... As you can see, I have to put a separate Other scenarios where getting a fully-qualified type/member name might be useful include reflection, or really any scenario where someone doesn't want to "hard code" an identifier's namespaces. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
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.
Duplicate of #5200 and #701.