Skip to content

Commit fbde76e

Browse files
committed
C#: Add some GOOD dead store of local test examples.
1 parent b3c16b4 commit fbde76e

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

csharp/ql/test/query-tests/Dead Code/DeadStoreOfLocal/DeadStoreOfLocal.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Linq;
34

45
public class DeadStoreOfLocal
56
{
@@ -484,3 +485,16 @@ void Pi()
484485
Console.WriteLine($"Pi, {pi,align:F3}");
485486
}
486487
}
488+
489+
class LinqFields
490+
{
491+
private readonly IEnumerable<int> QueryBackedField =
492+
from x1 in new[] { 1, 2, 3 }
493+
where x1 > 1
494+
select x1; // GOOD: The query range variable is used by the LINQ expression.
495+
496+
public static readonly IEnumerable<int> StaticQueryBackedField =
497+
from x2 in new[] { 1, 2, 3 }
498+
where x2 > 1
499+
select x2; // GOOD: The query range variable is used by the LINQ expression.
500+
}

0 commit comments

Comments
 (0)