-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Open
Labels
Area-CompilersConcept-APIThis issue involves adding, removing, clarification, or modification of an API.This issue involves adding, removing, clarification, or modification of an API.Feature Requestapi-needs-workAPI needs work before it is approved, it is NOT ready for implementationAPI needs work before it is approved, it is NOT ready for implementation
Milestone
Description
Background and Motivation
Please, see #76616.
Consider the following source code:
public class Type1
{
public static void f(){}
}
using static Type1;
using Type3 = Type1;
public class Type2
{
public static string X = nameof(f);
public static string Y = nameof(Type1.f);
public static string Z = nameof(Type3.f);
}
It demonstrates three different way to express the same nameof semantics. An important detail - the argument of nameof is a method group:
Type1.f- fully qualified through its parent type Type1Type3.f- fully qualified through an alias Type3f- unqualified, imported into the scope by theusing static Type1directive.
Inspecting the INameOfOperation yields different results for the third case as explained in great detail in the aforementioned issue.
Proposed API
Seems like the only case that needs special attention is when the argument of the nameof operator is a method group. Hence the idea is to introduce something like IMethodGroupReferenceOperation:
namespace Microsoft.CodeAnalysis.Operations
{
public class IMethodGroupReferenceOperation
{
public INamedTypeSymbol ContainingType { get; }
public string Name { get; }
}
...
}Metadata
Metadata
Assignees
Labels
Area-CompilersConcept-APIThis issue involves adding, removing, clarification, or modification of an API.This issue involves adding, removing, clarification, or modification of an API.Feature Requestapi-needs-workAPI needs work before it is approved, it is NOT ready for implementationAPI needs work before it is approved, it is NOT ready for implementation