The CallerMemberName attribute
The System.Runtime.CompilerServices.CallerMemberNameAttribute is allowed on optional parameters when there is a standard implicit conversion (§6.3.1) from string to the parameter’s type. If a function invocation from a location within the body of a function member or within an attribute applied to the function member itself or its return type, parameters or type parameters in source code omits an optional parameter with the CallerMemberNameAttribute, then a string literal representing the name of that member is used as an argument to the invocation instead of the default parameter value. For invocations that occur within generic methods, only the method name itself is used, without the type parameter list. For invocations that occur within explicit interface member implementations, only the method name itself is used, without the preceding interface qualification. For invocations that occur within property or event accessors, the member name used is that of the property or event itself. For invocations that occur within indexer accessors, the member name used is that supplied by an IndexerNameAttribute (§17.5.2.1) on the indexer member, if present, or the default name Item otherwise. For invocations that occur within declarations of instance constructors, static constructors, destructors and operators the member name used is implementation-dependent.
|