141 lines
4.3 KiB
Plaintext
141 lines
4.3 KiB
Plaintext
================================================================================
|
|
Struct with a type parameter struct constraint
|
|
================================================================================
|
|
|
|
public struct F<T> where T:struct {}
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(compilation_unit
|
|
(struct_declaration
|
|
(modifier)
|
|
name: (identifier)
|
|
type_parameters: (type_parameter_list
|
|
(type_parameter
|
|
name: (identifier)))
|
|
(type_parameter_constraints_clause
|
|
target: (identifier)
|
|
constraints: (type_parameter_constraint))
|
|
body: (declaration_list)))
|
|
|
|
================================================================================
|
|
Struct with a type parameter class constraint
|
|
================================================================================
|
|
|
|
public struct F<T> where T:class {}
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(compilation_unit
|
|
(struct_declaration
|
|
(modifier)
|
|
name: (identifier)
|
|
type_parameters: (type_parameter_list
|
|
(type_parameter
|
|
name: (identifier)))
|
|
(type_parameter_constraints_clause
|
|
target: (identifier)
|
|
constraints: (type_parameter_constraint))
|
|
body: (declaration_list)))
|
|
|
|
================================================================================
|
|
Struct with type parameter new constraint
|
|
================================================================================
|
|
|
|
public struct F<T> where T: new() {}
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(compilation_unit
|
|
(struct_declaration
|
|
(modifier)
|
|
name: (identifier)
|
|
type_parameters: (type_parameter_list
|
|
(type_parameter
|
|
name: (identifier)))
|
|
(type_parameter_constraints_clause
|
|
target: (identifier)
|
|
constraints: (type_parameter_constraint
|
|
(constructor_constraint)))
|
|
body: (declaration_list)))
|
|
|
|
================================================================================
|
|
Struct with interface
|
|
================================================================================
|
|
|
|
public struct A : ISomething { }
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(compilation_unit
|
|
(struct_declaration
|
|
(modifier)
|
|
name: (identifier)
|
|
bases: (base_list
|
|
(identifier))
|
|
body: (declaration_list)))
|
|
|
|
================================================================================
|
|
Struct with multiple type parameter constraints
|
|
================================================================================
|
|
|
|
private struct F<T1,T2> where T1 : I1, I2, new() where T2 : I2 { }
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(compilation_unit
|
|
(struct_declaration
|
|
(modifier)
|
|
name: (identifier)
|
|
type_parameters: (type_parameter_list
|
|
(type_parameter
|
|
name: (identifier))
|
|
(type_parameter
|
|
name: (identifier)))
|
|
(type_parameter_constraints_clause
|
|
target: (identifier)
|
|
constraints: (type_parameter_constraint
|
|
(type_constraint
|
|
type: (identifier)))
|
|
constraints: (type_parameter_constraint
|
|
(type_constraint
|
|
type: (identifier)))
|
|
constraints: (type_parameter_constraint
|
|
(constructor_constraint)))
|
|
(type_parameter_constraints_clause
|
|
target: (identifier)
|
|
constraints: (type_parameter_constraint
|
|
(type_constraint
|
|
type: (identifier))))
|
|
body: (declaration_list)))
|
|
|
|
================================================================================
|
|
Struct with readonly modifier
|
|
================================================================================
|
|
|
|
readonly struct Test {
|
|
}
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(compilation_unit
|
|
(struct_declaration
|
|
(modifier)
|
|
name: (identifier)
|
|
body: (declaration_list)))
|
|
|
|
================================================================================
|
|
Struct with ref modifier
|
|
================================================================================
|
|
|
|
ref struct Test {
|
|
}
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(compilation_unit
|
|
(struct_declaration
|
|
(modifier)
|
|
name: (identifier)
|
|
body: (declaration_list)))
|