Skip to content

Commit baea74f

Browse files
committed
C#: Add new testexamples and update expected testoutput.
1 parent 621674e commit baea74f

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

csharp/ql/test/query-tests/Likely Bugs/StaticFieldWrittenByInstance/StaticFieldWrittenByInstance.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,21 @@ void InstanceTest()
2626
staticField = 0; // BAD
2727
instanceField = 0; // OK
2828
}
29+
30+
static object backingField;
31+
static object StaticProp
32+
{
33+
get
34+
{
35+
return backingField ?? (backingField = new object()); // OK
36+
}
37+
}
38+
39+
object Prop
40+
{
41+
get
42+
{
43+
return backingField ?? (backingField = new object()); // BAD
44+
}
45+
}
2946
}
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
| StaticFieldWrittenByInstance.cs:15:9:15:19 | access to field staticField | Write to static field from instance method or constructor. |
2-
| StaticFieldWrittenByInstance.cs:26:9:26:19 | access to field staticField | Write to static field from instance method or constructor. |
1+
| StaticFieldWrittenByInstance.cs:15:9:15:19 | access to field staticField | Write to static field from instance method, property or constructor. |
2+
| StaticFieldWrittenByInstance.cs:26:9:26:19 | access to field staticField | Write to static field from instance method, property or constructor. |
3+
| StaticFieldWrittenByInstance.cs:43:37:43:48 | access to field backingField | Write to static field from instance method, property or constructor. |

0 commit comments

Comments
 (0)