mirror of
https://github.com/github/codeql.git
synced 2026-04-26 17:25:19 +02:00
C#: Add test for implicit index usage.
This commit is contained in:
24
csharp/ql/test/library-tests/index/Index.cs
Normal file
24
csharp/ql/test/library-tests/index/Index.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
|
||||
public class Container
|
||||
{
|
||||
public object[] Buffer { get; } = new object[10];
|
||||
}
|
||||
|
||||
public class TestIndex
|
||||
{
|
||||
public void M()
|
||||
{
|
||||
var c = new Container()
|
||||
{
|
||||
Buffer =
|
||||
{
|
||||
[0] = new object(),
|
||||
[1] = new object(),
|
||||
[^1] = new object()
|
||||
}
|
||||
};
|
||||
c.Buffer[4] = new object();
|
||||
c.Buffer[^3] = new object();
|
||||
}
|
||||
}
|
||||
2
csharp/ql/test/library-tests/index/Index.expected
Normal file
2
csharp/ql/test/library-tests/index/Index.expected
Normal file
@@ -0,0 +1,2 @@
|
||||
| Index.cs:18:18:18:19 | ^... | Index.cs:18:19:18:19 | 1 |
|
||||
| Index.cs:22:18:22:19 | ^... | Index.cs:22:19:22:19 | 3 |
|
||||
4
csharp/ql/test/library-tests/index/Index.ql
Normal file
4
csharp/ql/test/library-tests/index/Index.ql
Normal file
@@ -0,0 +1,4 @@
|
||||
import csharp
|
||||
|
||||
from IndexExpr e
|
||||
select e, e.getExpr()
|
||||
Reference in New Issue
Block a user