-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Copy link
Labels
Area-IDEFeature - IDE0025Use expression body for propertiesUse expression body for propertieshelp wantedThe issue is "up for grabs" - add a comment if you are interested in working on itThe issue is "up for grabs" - add a comment if you are interested in working on it
Milestone
Description
Version Used:
Compiler version: '4.13.0-3.25112.7 (afe5bc4)'. Language version: preview.
Steps to Reproduce:
public class Program
{
public static object obj
{
get
{
return field;
}
} = new();
public static object fixed_obj => field = new(); // New semantics (reassign on every get)
public static object? nullable_obj
{
get
{
return field ?? new();
}
} = new();
public static object? fixed_nullable_obj => field ?? new() = new(); // CS0131
}Diagnostic Id:
IDE0025 Use expression body for properties
Expected Behavior:
Code fixer not suggested when property has an initializer
Actual Behavior:
Code fixer suggested and applies change semantics and possibly invalid code.
Metadata
Metadata
Assignees
Labels
Area-IDEFeature - IDE0025Use expression body for propertiesUse expression body for propertieshelp wantedThe issue is "up for grabs" - add a comment if you are interested in working on itThe issue is "up for grabs" - add a comment if you are interested in working on it
Type
Projects
Status
Completed