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:
Michael Nebel
2022-12-08 13:53:00 +01:00
committed by GitHub
3 changed files with 26 additions and 0 deletions

View 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; }
}
}
}

View File

@@ -0,0 +1,2 @@
| ReadOnlySpan<Char> | PatternMatchSpan.cs:8:19:8:23 | "ABC" | String |
| Span<Char> | PatternMatchSpan.cs:15:18:15:22 | "DEF" | String |

View File

@@ -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()