Skip to content

Commit 2d9975d

Browse files
committed
C#: nint/System.IntPtr and nuint/System.UIntPtr are indistinguishable by the extractor.
1 parent 51f11f1 commit 2d9975d

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
public class NativeInt
2+
{
3+
public void M1()
4+
{
5+
nint x1 = 0;
6+
System.IntPtr x2 = (System.IntPtr)0;
7+
8+
nuint y1 = 0;
9+
System.UIntPtr y2 = (System.UIntPtr)0;
10+
}
11+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
| NativeInt.cs:5:14:5:15 | x1 | NativeInt.cs:6:23:6:24 | x2 | System.IntPtr |
2+
| NativeInt.cs:6:23:6:24 | x2 | NativeInt.cs:5:14:5:15 | x1 | System.IntPtr |
3+
| NativeInt.cs:8:15:8:16 | y1 | NativeInt.cs:9:24:9:25 | y2 | System.UIntPtr |
4+
| NativeInt.cs:9:24:9:25 | y2 | NativeInt.cs:8:15:8:16 | y1 | System.UIntPtr |
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import csharp
2+
import semmle.code.csharp.commons.QualifiedName
3+
4+
from LocalVariable v1, LocalVariable v2, Type t, string qualifier, string name
5+
where
6+
v1.getFile().getStem() = "NativeInt" and
7+
v2.getFile().getStem() = "NativeInt" and
8+
t = v1.getType() and
9+
t = v2.getType() and
10+
t.hasQualifiedName(qualifier, name) and
11+
v1 != v2
12+
select v1, v2, getQualifiedName(qualifier, name)

0 commit comments

Comments
 (0)