C#: nint/System.IntPtr and nuint/System.UIntPtr are indistinguishable by the extractor.

This commit is contained in:
Michael Nebel
2022-12-07 13:15:43 +01:00
parent 51f11f19cc
commit 2d9975d73f
3 changed files with 27 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
public class NativeInt
{
public void M1()
{
nint x1 = 0;
System.IntPtr x2 = (System.IntPtr)0;
nuint y1 = 0;
System.UIntPtr y2 = (System.UIntPtr)0;
}
}

View File

@@ -0,0 +1,4 @@
| NativeInt.cs:5:14:5:15 | x1 | NativeInt.cs:6:23:6:24 | x2 | System.IntPtr |
| NativeInt.cs:6:23:6:24 | x2 | NativeInt.cs:5:14:5:15 | x1 | System.IntPtr |
| NativeInt.cs:8:15:8:16 | y1 | NativeInt.cs:9:24:9:25 | y2 | System.UIntPtr |
| NativeInt.cs:9:24:9:25 | y2 | NativeInt.cs:8:15:8:16 | y1 | System.UIntPtr |

View File

@@ -0,0 +1,12 @@
import csharp
import semmle.code.csharp.commons.QualifiedName
from LocalVariable v1, LocalVariable v2, Type t, string qualifier, string name
where
v1.getFile().getStem() = "NativeInt" and
v2.getFile().getStem() = "NativeInt" and
t = v1.getType() and
t = v2.getType() and
t.hasQualifiedName(qualifier, name) and
v1 != v2
select v1, v2, getQualifiedName(qualifier, name)