Merge pull request #2563 from calumgrant/cs/tuple-expr

C#: Handle tuple expressions
This commit is contained in:
Tom Hvitved
2020-01-07 09:31:17 +01:00
committed by GitHub
6 changed files with 25 additions and 0 deletions

View File

@@ -129,6 +129,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
case SyntaxKind.ArrayType:
case SyntaxKind.PredefinedType:
case SyntaxKind.NullableType:
case SyntaxKind.TupleType:
return TypeAccess.Create(info);
case SyntaxKind.TypeOfExpression:

View File

@@ -0,0 +1,4 @@
| expressions.cs:492:29:492:41 | access to type (Int32,String) | expressions.cs:492:29:492:41 | (Int32,String) |
| expressions.cs:493:29:493:49 | access to type (Boolean,Int32[],Object) | expressions.cs:493:29:493:49 | (Boolean,Int32[],Object) |
| expressions.cs:494:28:494:40 | access to type (Int32,String) | expressions.cs:492:29:492:41 | (Int32,String) |
| expressions.cs:495:28:495:49 | access to type (Boolean,Int32[],dynamic) | expressions.cs:495:28:495:49 | (Boolean,Int32[],dynamic) |

View File

@@ -0,0 +1,5 @@
import csharp
from TypeAccess access, TupleType type
where type = access.getTarget()
select access, type

View File

@@ -484,4 +484,15 @@ namespace Expressions
const int d = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 +
1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1;
}
class TupleExprs
{
void Test()
{
var a = default((int, string));
var b = default((bool, int[], object));
var x = typeof((int, string));
var y = typeof((bool, int[], dynamic));
}
}
}