diff --git a/csharp/ql/test/library-tests/csharp8/DefaultInterfaceMethods.cs b/csharp/ql/test/library-tests/csharp8/DefaultInterfaceMethods.cs new file mode 100644 index 000000000000..123462e0b439 --- /dev/null +++ b/csharp/ql/test/library-tests/csharp8/DefaultInterfaceMethods.cs @@ -0,0 +1,27 @@ +using System; + +interface IPerson +{ + string Name { get; } + + string Greeting + { + get => "Hello"; + set { } + } + + string Greet(string name) => Greeting + " " + name; + + string GreetingString => Greet(Name); + + void Greet(); +} + +class Person : IPerson +{ + public string Name => "Petra"; + + string IPerson.Greeting { get => "Howdy"; set { } } + + public void Greet() { } +} diff --git a/csharp/ql/test/library-tests/csharp8/DefaultInterfaceMethods.expected b/csharp/ql/test/library-tests/csharp8/DefaultInterfaceMethods.expected index e69de29bb2d1..a8700aa4d02a 100644 --- a/csharp/ql/test/library-tests/csharp8/DefaultInterfaceMethods.expected +++ b/csharp/ql/test/library-tests/csharp8/DefaultInterfaceMethods.expected @@ -0,0 +1,4 @@ +| DefaultInterfaceMethods.cs:9:9:9:11 | get_Greeting | +| DefaultInterfaceMethods.cs:10:9:10:11 | set_Greeting | +| DefaultInterfaceMethods.cs:13:12:13:16 | Greet | +| DefaultInterfaceMethods.cs:15:30:15:40 | get_GreetingString | diff --git a/csharp/ql/test/library-tests/csharp8/DefaultInterfaceMethods.ql b/csharp/ql/test/library-tests/csharp8/DefaultInterfaceMethods.ql index 9336ca3f060a..d9ba39ef02d6 100644 --- a/csharp/ql/test/library-tests/csharp8/DefaultInterfaceMethods.ql +++ b/csharp/ql/test/library-tests/csharp8/DefaultInterfaceMethods.ql @@ -1,6 +1,6 @@ import csharp -class DefaultInterfaceMethod extends Method { +class DefaultInterfaceMethod extends Callable { DefaultInterfaceMethod() { this.hasBody() and this.getDeclaringType() instanceof Interface