mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Merge pull request #11593 from michaelnebel/csharp/patternmatchspan
C#: Pattern match Span<char> and ReadOnlySpan<char> against a constant string.
This commit is contained in:
19
csharp/ql/test/library-tests/csharp11/PatternMatchSpan.cs
Normal file
19
csharp/ql/test/library-tests/csharp11/PatternMatchSpan.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
|
||||
class PatternMatchSpan
|
||||
{
|
||||
|
||||
public void M1(ReadOnlySpan<char> x1)
|
||||
{
|
||||
if (x1 is "ABC") { }
|
||||
}
|
||||
|
||||
public void M2(Span<char> x2)
|
||||
{
|
||||
switch (x2)
|
||||
{
|
||||
case "DEF": { break; }
|
||||
default: { break; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
| ReadOnlySpan<Char> | PatternMatchSpan.cs:8:19:8:23 | "ABC" | String |
|
||||
| Span<Char> | PatternMatchSpan.cs:15:18:15:22 | "DEF" | String |
|
||||
@@ -0,0 +1,5 @@
|
||||
import csharp
|
||||
|
||||
from PatternMatch pm
|
||||
where pm.getFile().getStem() = "PatternMatchSpan"
|
||||
select pm.getExpr().getType().getName(), pm.getPattern(), pm.getPattern().getType().getName()
|
||||
Reference in New Issue
Block a user