mirror of
https://github.com/github/codeql.git
synced 2026-04-19 22:14:01 +02:00
Merge pull request #15087 from michaelnebel/csharp/stubgenrefreadonly
C#: Stub generator support for `ref readonly` parameters.
This commit is contained in:
@@ -534,6 +534,9 @@ internal sealed class StubVisitor : SymbolVisitor
|
||||
case RefKind.In:
|
||||
stubWriter.Write("in ");
|
||||
break;
|
||||
case RefKind.RefReadOnlyParameter:
|
||||
stubWriter.Write("ref readonly ");
|
||||
break;
|
||||
default:
|
||||
stubWriter.Write($"/* TODO: {parameter.RefKind} */");
|
||||
break;
|
||||
@@ -884,4 +887,4 @@ internal sealed class StubVisitor : SymbolVisitor
|
||||
if (explicitInterfaceImplementations.Length == 0)
|
||||
StubProperty(symbol, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public const string MyField2 = default;
|
||||
// Setup
|
||||
const string source = @"
|
||||
public class MyTest {
|
||||
public int M1(string arg1) { return 0;}
|
||||
public int M1(string arg1) { return 0; }
|
||||
}";
|
||||
|
||||
// Execute
|
||||
@@ -56,6 +56,26 @@ public int M1(string arg1) => throw null;
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user