Skip to content

Commit f6af593

Browse files
committed
C#: Add a unit test for escaping method names.
1 parent 6716921 commit f6af593

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

csharp/extractor/Semmle.Extraction.Tests/StubGenerator.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,26 @@ public class MyTest {
7676
Assert.Equal(expected, stub);
7777
}
7878

79+
[Fact]
80+
public void StubGeneratorEscapeMethodName()
81+
{
82+
// Setup
83+
const string source = @"
84+
public class MyTest {
85+
public int @default() { return 0; }
86+
}";
87+
88+
// Execute
89+
var stub = GenerateStub(source);
90+
91+
// Verify
92+
const string expected = @"public class MyTest {
93+
public int @default() => throw null;
94+
}
95+
";
96+
Assert.Equal(expected, stub);
97+
}
98+
7999
private static string GenerateStub(string source)
80100
{
81101
var st = CSharpSyntaxTree.ParseText(source);

0 commit comments

Comments
 (0)