-
Notifications
You must be signed in to change notification settings - Fork 4.2k
CS0103 Triggers for nameof-expression inside extension property #81496
Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
Labels
Area-CompilersArea-Language DesignFeature - Extension EverythingThe extension everything featureThe extension everything featureResolution-By DesignThe behavior reported in the issue matches the current designThe behavior reported in the issue matches the current design
Milestone
Description
Version Used: dotnet 10.0.100
Steps to Reproduce:
Create any extension property and use nameof() inside the getter or setter.
public static class Test {
extension(string str)
{
public void SomeMethod() => Console.WriteLine(nameof(SomeMethod)); // this works
public bool SomeProp
{
get => Console.WriteLine(nameof(SomeProp) + str); // this does not
set => Console.WriteLine(nameof(SomeProp) + value); // this does not
}
public string SomeOtherProp => nameof(get_SomeOtherProp); // this works for some reason
public string OneMoreProp => nameof(OneMoreProp); // again this does not
}
}Diagnostic Id: CS0103 - "The name 'SomeProp' does not exist in the current context"
Expected Behavior: Compilation succeeds
Actual Behavior: Compilation fails
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Area-CompilersArea-Language DesignFeature - Extension EverythingThe extension everything featureThe extension everything featureResolution-By DesignThe behavior reported in the issue matches the current designThe behavior reported in the issue matches the current design