Skip to content

Commit

Permalink
C#: Add a unit test for stub generation of ref readonly parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelnebel committed Dec 13, 2023
1 parent d838806 commit 1cced72
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion csharp/extractor/Semmle.Extraction.Tests/StubGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void StubGeneratorMethodTest()
// Setup
const string source = @"
public class MyTest {
public int M1(string arg1) { return 0;}
public int M1(string arg1) { return 0; }
}";

// Execute
Expand All @@ -56,6 +56,26 @@ public class MyTest {
Assert.Equal(expected, stub);
}

[Fact]
public void StubGeneratorRefReadonlyParameterTest()
{
// Setup
const string source = @"
public class MyTest {
public int M1(ref readonly Guid guid) { return 0; }
}";

// Execute
var stub = GenerateStub(source);

// Verify
const string expected = @"public class MyTest {
public int M1(ref readonly Guid guid) => throw null;
}
";
Assert.Equal(expected, stub);
}

private static string GenerateStub(string source)
{
var st = CSharpSyntaxTree.ParseText(source);
Expand Down

0 comments on commit 1cced72

Please sign in to comment.