Skip to content

Commit 0ceeace

Browse files
committed
C#: Add some more properties test examples and update expected test output.
1 parent 499816b commit 0ceeace

4 files changed

Lines changed: 103 additions & 0 deletions

File tree

csharp/ql/test/library-tests/properties/PrintAst.expected

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,3 +293,69 @@ properties.cs:
293293
# 160| 0: [LocalVariableAccess] access to local variable x
294294
# 160| 1: [PropertyCall] access to property Prop
295295
# 160| -1: [LocalVariableAccess] access to local variable s
296+
# 164| 13: [Class] BaseClass
297+
# 166| 6: [Property] Value
298+
# 166| -1: [TypeMention] int
299+
# 168| 3: [Getter] get_Value
300+
# 168| 4: [BlockStmt] {...}
301+
# 168| 0: [ReturnStmt] return ...;
302+
# 168| 0: [FieldAccess] access to field Value.field
303+
# 169| 4: [Setter] set_Value
304+
#-----| 2: (Parameters)
305+
# 169| 0: [Parameter] value
306+
# 169| 4: [BlockStmt] {...}
307+
# 169| 0: [ExprStmt] ...;
308+
# 169| 0: [AssignExpr] ... = ...
309+
# 169| 0: [FieldAccess] access to field Value.field
310+
# 169| 1: [ParameterAccess] access to parameter value
311+
# 166| 7: [Field] Value.field
312+
# 173| 14: [Class] DerivedClass1
313+
#-----| 3: (Base types)
314+
# 173| 0: [TypeMention] BaseClass
315+
# 175| 6: [Property] Value
316+
# 175| -1: [TypeMention] int
317+
# 177| 3: [Getter] get_Value
318+
# 177| 4: [BlockStmt] {...}
319+
# 177| 0: [ReturnStmt] return ...;
320+
# 177| 0: [IntLiteral] 20
321+
# 181| 15: [Class] DerivedClass2
322+
#-----| 3: (Base types)
323+
# 181| 0: [TypeMention] BaseClass
324+
# 183| 16: [Class] TestPartialPropertyOverride
325+
# 185| 6: [Method] M
326+
# 185| -1: [TypeMention] Void
327+
# 186| 4: [BlockStmt] {...}
328+
# 187| 0: [LocalVariableDeclStmt] ... ...;
329+
# 187| 0: [LocalVariableDeclAndInitExpr] DerivedClass1 d1 = ...
330+
# 187| -1: [TypeMention] DerivedClass1
331+
# 187| 0: [LocalVariableAccess] access to local variable d1
332+
# 187| 1: [ObjectCreation] object creation of type DerivedClass1
333+
# 187| 0: [TypeMention] DerivedClass1
334+
# 188| 1: [ExprStmt] ...;
335+
# 188| 0: [AssignExpr] ... = ...
336+
# 188| 0: [PropertyCall] access to property Value
337+
# 188| -1: [LocalVariableAccess] access to local variable d1
338+
# 188| 1: [IntLiteral] 11
339+
# 189| 2: [LocalVariableDeclStmt] ... ...;
340+
# 189| 0: [LocalVariableDeclAndInitExpr] Int32 test1 = ...
341+
# 189| -1: [TypeMention] int
342+
# 189| 0: [LocalVariableAccess] access to local variable test1
343+
# 189| 1: [PropertyCall] access to property Value
344+
# 189| -1: [LocalVariableAccess] access to local variable d1
345+
# 191| 3: [LocalVariableDeclStmt] ... ...;
346+
# 191| 0: [LocalVariableDeclAndInitExpr] DerivedClass2 d2 = ...
347+
# 191| -1: [TypeMention] DerivedClass2
348+
# 191| 0: [LocalVariableAccess] access to local variable d2
349+
# 191| 1: [ObjectCreation] object creation of type DerivedClass2
350+
# 191| 0: [TypeMention] DerivedClass2
351+
# 192| 4: [ExprStmt] ...;
352+
# 192| 0: [AssignExpr] ... = ...
353+
# 192| 0: [PropertyCall] access to property Value
354+
# 192| -1: [LocalVariableAccess] access to local variable d2
355+
# 192| 1: [IntLiteral] 12
356+
# 193| 5: [LocalVariableDeclStmt] ... ...;
357+
# 193| 0: [LocalVariableDeclAndInitExpr] Int32 test2 = ...
358+
# 193| -1: [TypeMention] int
359+
# 193| 0: [LocalVariableAccess] access to local variable test2
360+
# 193| 1: [PropertyCall] access to property Value
361+
# 193| -1: [LocalVariableAccess] access to local variable d2

csharp/ql/test/library-tests/properties/Properties17.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
| Prop.field |
2+
| Value.field |
23
| caption |
34
| next |
45
| x |

csharp/ql/test/library-tests/properties/Properties19.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@
66
| properties.cs:71:28:71:28 | Y | properties.cs:83:39:83:44 | access to property Y | properties.cs:74:13:74:15 | set_Y |
77
| properties.cs:146:24:146:27 | Prop | properties.cs:159:13:159:18 | access to property Prop | properties.cs:148:13:148:15 | get_Prop |
88
| properties.cs:146:24:146:27 | Prop | properties.cs:160:21:160:26 | access to property Prop | properties.cs:148:13:148:15 | get_Prop |
9+
| properties.cs:166:28:166:32 | Value | properties.cs:192:13:192:20 | access to property Value | properties.cs:169:13:169:15 | set_Value |
10+
| properties.cs:166:28:166:32 | Value | properties.cs:193:25:193:32 | access to property Value | properties.cs:168:13:168:15 | get_Value |
11+
| properties.cs:175:29:175:33 | Value | properties.cs:189:25:189:32 | access to property Value | properties.cs:177:13:177:15 | get_Value |

csharp/ql/test/library-tests/properties/properties.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,37 @@ public void M()
160160
var x = s.Prop;
161161
}
162162
}
163+
164+
public class BaseClass
165+
{
166+
public virtual int Value
167+
{
168+
get { return field; }
169+
set { field = value; }
170+
}
171+
}
172+
173+
public class DerivedClass1 : BaseClass
174+
{
175+
public override int Value
176+
{
177+
get { return 20; }
178+
}
179+
}
180+
181+
public class DerivedClass2 : BaseClass { }
182+
183+
public class TestPartialPropertyOverride
184+
{
185+
public void M()
186+
{
187+
var d1 = new DerivedClass1();
188+
d1.Value = 11;
189+
var test1 = d1.Value;
190+
191+
var d2 = new DerivedClass2();
192+
d2.Value = 12;
193+
var test2 = d2.Value;
194+
}
195+
}
163196
}

0 commit comments

Comments
 (0)