mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
Merge pull request #2331 from calumgrant/cs/default-interface-methods
C#: Tests for default interface methods
This commit is contained in:
@@ -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() { }
|
||||
}
|
||||
@@ -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 |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import csharp
|
||||
|
||||
class DefaultInterfaceMethod extends Method {
|
||||
class DefaultInterfaceMethod extends Callable {
|
||||
DefaultInterfaceMethod() {
|
||||
this.hasBody() and
|
||||
this.getDeclaringType() instanceof Interface
|
||||
|
||||
Reference in New Issue
Block a user