336 lines
9.7 KiB
Plaintext
336 lines
9.7 KiB
Plaintext
================================================================================
|
|
Global empty interface
|
|
================================================================================
|
|
|
|
public interface IOne {};
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(compilation_unit
|
|
(interface_declaration
|
|
(modifier)
|
|
name: (identifier)
|
|
body: (declaration_list)))
|
|
|
|
================================================================================
|
|
Interface with properties
|
|
================================================================================
|
|
|
|
interface IOne {
|
|
byte Get { get; }
|
|
char Set { set; }
|
|
uint GetSet { get; set; }
|
|
long SetGet { set; get; }
|
|
};
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(compilation_unit
|
|
(interface_declaration
|
|
name: (identifier)
|
|
body: (declaration_list
|
|
(property_declaration
|
|
type: (predefined_type)
|
|
name: (identifier)
|
|
accessors: (accessor_list
|
|
(accessor_declaration)))
|
|
(property_declaration
|
|
type: (predefined_type)
|
|
name: (identifier)
|
|
accessors: (accessor_list
|
|
(accessor_declaration)))
|
|
(property_declaration
|
|
type: (predefined_type)
|
|
name: (identifier)
|
|
accessors: (accessor_list
|
|
(accessor_declaration)
|
|
(accessor_declaration)))
|
|
(property_declaration
|
|
type: (predefined_type)
|
|
name: (identifier)
|
|
accessors: (accessor_list
|
|
(accessor_declaration)
|
|
(accessor_declaration))))))
|
|
|
|
================================================================================
|
|
Interface with methods
|
|
================================================================================
|
|
|
|
interface IOne {
|
|
void Nothing();
|
|
int Output();
|
|
void Input(string a);
|
|
int InputOutput(string a);
|
|
};
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(compilation_unit
|
|
(interface_declaration
|
|
name: (identifier)
|
|
body: (declaration_list
|
|
(method_declaration
|
|
type: (predefined_type)
|
|
name: (identifier)
|
|
parameters: (parameter_list))
|
|
(method_declaration
|
|
type: (predefined_type)
|
|
name: (identifier)
|
|
parameters: (parameter_list))
|
|
(method_declaration
|
|
type: (predefined_type)
|
|
name: (identifier)
|
|
parameters: (parameter_list
|
|
(parameter
|
|
type: (predefined_type)
|
|
name: (identifier))))
|
|
(method_declaration
|
|
type: (predefined_type)
|
|
name: (identifier)
|
|
parameters: (parameter_list
|
|
(parameter
|
|
type: (predefined_type)
|
|
name: (identifier)))))))
|
|
|
|
================================================================================
|
|
Interface base single
|
|
================================================================================
|
|
|
|
private interface IOne : ITwo { }
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(compilation_unit
|
|
(interface_declaration
|
|
(modifier)
|
|
name: (identifier)
|
|
bases: (base_list
|
|
(identifier))
|
|
body: (declaration_list)))
|
|
|
|
================================================================================
|
|
Interface base multiple
|
|
================================================================================
|
|
|
|
private interface IOne : ITwo, IThree { }
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(compilation_unit
|
|
(interface_declaration
|
|
(modifier)
|
|
name: (identifier)
|
|
bases: (base_list
|
|
(identifier)
|
|
(identifier))
|
|
body: (declaration_list)))
|
|
|
|
================================================================================
|
|
Interface generic
|
|
================================================================================
|
|
|
|
private interface IOne<T1> : ITwo { }
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(compilation_unit
|
|
(interface_declaration
|
|
(modifier)
|
|
name: (identifier)
|
|
type_parameters: (type_parameter_list
|
|
(type_parameter
|
|
name: (identifier)))
|
|
bases: (base_list
|
|
(identifier))
|
|
body: (declaration_list)))
|
|
|
|
================================================================================
|
|
Interface generic single constraint
|
|
================================================================================
|
|
|
|
private interface IOne<T1> : ITwo where T1:T2 { }
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(compilation_unit
|
|
(interface_declaration
|
|
(modifier)
|
|
name: (identifier)
|
|
type_parameters: (type_parameter_list
|
|
(type_parameter
|
|
name: (identifier)))
|
|
bases: (base_list
|
|
(identifier))
|
|
(type_parameter_constraints_clause
|
|
target: (identifier)
|
|
constraints: (type_parameter_constraint
|
|
(type_constraint
|
|
type: (identifier))))
|
|
body: (declaration_list)))
|
|
|
|
================================================================================
|
|
Interface generic multiple constraints
|
|
================================================================================
|
|
|
|
private interface IOne<T1, T3> : ITwo where T1:T2 where T3:new() { }
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(compilation_unit
|
|
(interface_declaration
|
|
(modifier)
|
|
name: (identifier)
|
|
type_parameters: (type_parameter_list
|
|
(type_parameter
|
|
name: (identifier))
|
|
(type_parameter
|
|
name: (identifier)))
|
|
bases: (base_list
|
|
(identifier))
|
|
(type_parameter_constraints_clause
|
|
target: (identifier)
|
|
constraints: (type_parameter_constraint
|
|
(type_constraint
|
|
type: (identifier))))
|
|
(type_parameter_constraints_clause
|
|
target: (identifier)
|
|
constraints: (type_parameter_constraint
|
|
(constructor_constraint)))
|
|
body: (declaration_list)))
|
|
|
|
================================================================================
|
|
Interface in namespace
|
|
================================================================================
|
|
|
|
namespace A {
|
|
interface IOne : ITwo { }
|
|
}
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(compilation_unit
|
|
(namespace_declaration
|
|
name: (identifier)
|
|
body: (declaration_list
|
|
(interface_declaration
|
|
name: (identifier)
|
|
bases: (base_list
|
|
(identifier))
|
|
body: (declaration_list)))))
|
|
|
|
================================================================================
|
|
Interface event declarations
|
|
================================================================================
|
|
|
|
interface A {
|
|
event EventHandler<T> SomeEvent;
|
|
}
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(compilation_unit
|
|
(interface_declaration
|
|
name: (identifier)
|
|
body: (declaration_list
|
|
(event_field_declaration
|
|
(variable_declaration
|
|
type: (generic_name
|
|
name: (identifier)
|
|
type_arguments: (type_argument_list
|
|
(identifier)))
|
|
(variable_declarator
|
|
name: (identifier)))))))
|
|
|
|
================================================================================
|
|
Interface with indexer
|
|
================================================================================
|
|
|
|
interface A {
|
|
bool this[int index] { get; set; }
|
|
}
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(compilation_unit
|
|
(interface_declaration
|
|
name: (identifier)
|
|
body: (declaration_list
|
|
(indexer_declaration
|
|
type: (predefined_type)
|
|
parameters: (bracketed_parameter_list
|
|
(parameter
|
|
type: (predefined_type)
|
|
name: (identifier)))
|
|
accessors: (accessor_list
|
|
(accessor_declaration)
|
|
(accessor_declaration))))))
|
|
|
|
================================================================================
|
|
Interface with default method
|
|
================================================================================
|
|
|
|
interface MyDefault {
|
|
void Log(string message) {
|
|
Console.WriteLine(message);
|
|
}
|
|
}
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(compilation_unit
|
|
(interface_declaration
|
|
name: (identifier)
|
|
body: (declaration_list
|
|
(method_declaration
|
|
type: (predefined_type)
|
|
name: (identifier)
|
|
parameters: (parameter_list
|
|
(parameter
|
|
type: (predefined_type)
|
|
name: (identifier)))
|
|
body: (block
|
|
(expression_statement
|
|
(invocation_expression
|
|
function: (member_access_expression
|
|
expression: (identifier)
|
|
name: (identifier))
|
|
arguments: (argument_list
|
|
(argument
|
|
(identifier))))))))))
|
|
|
|
================================================================================
|
|
Static abstract members
|
|
================================================================================
|
|
|
|
public interface IGetNext<T> where T : IGetNext<T>
|
|
{
|
|
static abstract T operator ++(T other);
|
|
}
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(compilation_unit
|
|
(interface_declaration
|
|
(modifier)
|
|
name: (identifier)
|
|
type_parameters: (type_parameter_list
|
|
(type_parameter
|
|
name: (identifier)))
|
|
(type_parameter_constraints_clause
|
|
target: (identifier)
|
|
constraints: (type_parameter_constraint
|
|
(type_constraint
|
|
type: (generic_name
|
|
name: (identifier)
|
|
type_arguments: (type_argument_list
|
|
(identifier))))))
|
|
body: (declaration_list
|
|
(operator_declaration
|
|
(modifier)
|
|
(modifier)
|
|
type: (identifier)
|
|
parameters: (parameter_list
|
|
(parameter
|
|
type: (identifier)
|
|
name: (identifier)))))))
|