C#: Add property test case where the field keyword is used.

This commit is contained in:
Michael Nebel
2026-02-11 14:55:55 +01:00
parent edb2ed8df2
commit 113f3e880b
4 changed files with 27 additions and 1 deletions

View File

@@ -230,3 +230,19 @@ properties.cs:
#-----| 2: (Parameters)
# 124| 0: [Parameter] value
# 124| 4: [BlockStmt] {...}
# 128| 10: [Class] UseFieldKeyword
# 130| 6: [Property] Prop
# 130| -1: [TypeMention] object
# 132| 3: [Getter] get_Prop
# 132| 4: [BlockStmt] {...}
# 132| 0: [ReturnStmt] return ...;
# 132| 0: [FieldAccess] access to field Prop.field
# 133| 4: [Setter] set_Prop
#-----| 2: (Parameters)
# 133| 0: [Parameter] value
# 133| 4: [BlockStmt] {...}
# 133| 0: [ExprStmt] ...;
# 133| 0: [AssignExpr] ... = ...
# 133| 0: [FieldAccess] access to field Prop.field
# 133| 1: [ParameterAccess] access to parameter value
# 130| 7: [Field] Prop.field

View File

@@ -1,3 +1,4 @@
| Prop.field |
| caption |
| next |
| y |

View File

@@ -1,5 +1,5 @@
/**
* @name Test that there are no backing fields
* @name Test that there are no backing fields except for properties that use the `field` keyword in their getter or setter.
*/
import csharp

View File

@@ -124,4 +124,13 @@ namespace Properties
set { }
}
}
class UseFieldKeyword
{
public object Prop
{
get { return field; }
set { field = value; }
}
}
}