Skip to content

Commit 48ed296

Browse files
committed
C#: Add dataflow test for partial constructors.
1 parent b9df34f commit 48ed296

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

csharp/ql/test/library-tests/dataflow/constructors/ConstructorFlow.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ subpaths
274274
| Constructors.cs:143:25:143:26 | access to local variable o1 : Object | Constructors.cs:137:29:137:32 | Obj1 : Object | Constructors.cs:137:19:137:20 | this [Return] : R1 [property Obj1] : Object | Constructors.cs:143:18:143:31 | object creation of type R1 : R1 [property Obj1] : Object |
275275
| Constructors.cs:143:29:143:30 | access to local variable o2 : Object | Constructors.cs:137:42:137:45 | Obj2 : Object | Constructors.cs:137:19:137:20 | this [Return] : R1 [property Obj2] : Object | Constructors.cs:143:18:143:31 | object creation of type R1 : R1 [property Obj2] : Object |
276276
testFailures
277+
| Constructors.cs:164:29:164:48 | // ... | Missing result: hasValueFlow=11 |
277278
#select
278279
| Constructors.cs:15:18:15:19 | access to field s1 | Constructors.cs:5:29:5:45 | call to method Source<Object> : Object | Constructors.cs:15:18:15:19 | access to field s1 | $@ | Constructors.cs:5:29:5:45 | call to method Source<Object> : Object | call to method Source<Object> : Object |
279280
| Constructors.cs:33:18:33:19 | access to field s1 | Constructors.cs:21:29:21:45 | call to method Source<Object> : Object | Constructors.cs:33:18:33:19 | access to field s1 | $@ | Constructors.cs:21:29:21:45 | call to method Source<Object> : Object | call to method Source<Object> : Object |

csharp/ql/test/library-tests/dataflow/constructors/Constructors.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,25 @@ public void M7()
145145
Sink(r1.Obj2); // $ hasValueFlow=10
146146
}
147147

148+
public partial class CPartial
149+
{
150+
public object Obj { get; }
151+
152+
public partial CPartial(object o);
153+
}
154+
155+
public partial class CPartial
156+
{
157+
public partial CPartial(object o) => Obj = o;
158+
}
159+
160+
public void M8()
161+
{
162+
var o = Source<object>(11);
163+
var cPartial = new CPartial(o);
164+
Sink(cPartial.Obj); // $ hasValueFlow=11
165+
}
166+
148167
public static void Sink(object o) { }
149168

150169
public static T Source<T>(object source) => throw null;

0 commit comments

Comments
 (0)