Skip to content

Commit c95db9e

Browse files
authored
Merge pull request #2331 from calumgrant/cs/default-interface-methods
C#: Tests for default interface methods
2 parents 810a046 + aac3604 commit c95db9e

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
3+
interface IPerson
4+
{
5+
string Name { get; }
6+
7+
string Greeting
8+
{
9+
get => "Hello";
10+
set { }
11+
}
12+
13+
string Greet(string name) => Greeting + " " + name;
14+
15+
string GreetingString => Greet(Name);
16+
17+
void Greet();
18+
}
19+
20+
class Person : IPerson
21+
{
22+
public string Name => "Petra";
23+
24+
string IPerson.Greeting { get => "Howdy"; set { } }
25+
26+
public void Greet() { }
27+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
| DefaultInterfaceMethods.cs:9:9:9:11 | get_Greeting |
2+
| DefaultInterfaceMethods.cs:10:9:10:11 | set_Greeting |
3+
| DefaultInterfaceMethods.cs:13:12:13:16 | Greet |
4+
| DefaultInterfaceMethods.cs:15:30:15:40 | get_GreetingString |

csharp/ql/test/library-tests/csharp8/DefaultInterfaceMethods.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import csharp
22

3-
class DefaultInterfaceMethod extends Method {
3+
class DefaultInterfaceMethod extends Callable {
44
DefaultInterfaceMethod() {
55
this.hasBody() and
66
this.getDeclaringType() instanceof Interface

0 commit comments

Comments
 (0)