You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- #681 has been merged before completion to reduce
the conversation & change complexity. This is a review of
this PR changes now in draft-v8. Every change will be
augmented by a comment in the new PR
- Grammar testing, updates post #681
- Update tarball to v2.3.7
- Add sample “Expanded Interfaces”
Copy file name to clipboardExpand all lines: standard/basic-concepts.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -402,7 +402,7 @@ As described in [§7.4](basic-concepts.md#74-members), all members of a base cla
402
402
403
403
### 7.5.4 Protected access
404
404
405
-
When a `protected` or `private protected` instance member is accessed outside the program text of the class in which it is declared, and when a `protected internal` instance member is accessed outside the program text of the program in which it is declared, the access shall take place within a class declaration that derives from the class in which it is declared. Furthermore, the access is required to take place *through* an instance of that derived class type or a class type constructed from it. This restriction prevents one derived class from accessing protected members of other derived classes, even when the members are inherited from the same base class. Instance interface members defined with `protected` or `private protected` access cannot be accessed from a `class` or `struct` that implements that interface; thesecanbeaccessedonlyfromderivedinterfaces. However, `class` and `struct` types can define overridden `protected` instance members declared in an interface it implements.
405
+
When a `protected` or `private protected` instance member is accessed outside the program text of the class in which it is declared, and when a `protected internal` instance member is accessed outside the program text of the program in which it is declared, the access shall take place within a class declaration that derives from the class in which it is declared. Furthermore, the access is required to take place *through* an instance of that derived class type or a class type constructed from it. This restriction prevents one derived class from accessing protected members of other derived classes, even when the members are inherited from the same base class. Instance interface members defined with `protected` or `private protected` access cannot be accessed from a `class` or `struct` that implements that interface; thesecanbeaccessedonlyfromderivedinterfaces. However, `class` and `struct` types can override `protected` instance members declared in an interface they implement.
406
406
407
407
Let `B` be a base classthat declares a protected instance member `M`, and let `D` be a class that derives from `B`. Within the *class_body* of `D`, access to `M` can take one of the following forms:
Copy file name to clipboardExpand all lines: standard/classes.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -236,7 +236,7 @@ The direct base class of a class type shall be at least as accessible as the cla
236
236
237
237
The direct base class of a class type shall not be any of the following types: `System.Array`, `System.Delegate`, `System.Enum`, `System.ValueType` orthe `dynamic` type. Furthermore, agenericclassdeclarationshallnotuse `System.Attribute` asadirectorindirectbaseclass ([§23.2.1](attributes.md#2321-general)).
@@ -3426,6 +3426,7 @@ For a ref-valued property the *ref_get_accessor_declaration* consists optional a
3426
3426
3427
3427
The use of *accessor_modifier*s is governed by the following restrictions:
3428
3428
3429
+
- An *accessor_modifier* shall not be used in an explicit interface member implementation.
3429
3430
- The *accessor_modifier*`readonly` is permitted only in a *property_declaration* or *indexer_declaration* that is contained directly by a *struct_declaration* ([§16.4.11](structs.md#16411-properties), [§16.4.13](structs.md#16413-indexers)).
3430
3431
- For a property or indexer that has no `override` modifier, an *accessor_modifier* is permitted only if the property or indexer has both a get and set accessor, and then is permitted only on one of those accessors.
3431
3432
- For a property or indexer that includes an `override` modifier, an accessor shall match the *accessor_modifier*, if any, of the accessor being overridden.
Copy file name to clipboardExpand all lines: standard/interfaces.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
An interface defines a contract. A class or struct that implements an interface shall adhere to its contract. An interface may inherit from multiple base interfaces, and a class or struct may implement multiple interfaces.
6
6
7
-
Interfaces may contain various kinds of members, as described in [§19.4](interfaces.md#194-interface-members). The interface itself may provide an implementation for some or all of the function members that it declares. Members for which the interface does not provide an implementation are abstract. Their implementations must be supplied by classes or structs that implement the interface, or derived interface that provide an overriding definition.
7
+
Interfaces may contain various kinds of members, as described in [§19.4](interfaces.md#194-interface-members). The interface itself may provide an implementation for some or all of the function members that it declares. Members for which the interface does not provide an implementation are abstract. Their implementations must be supplied by classes or structs that implement the interface, and may be supplied by derived interfaces through an explicit implementation ([§19.6.2](interfaces.md#1962-explicit-interface-member-implementations)).
8
8
9
9
<!-- This note needs to be updated in C# 13, when ref struct types can implement interfaces. -->
10
10
> *Note*: Historically, adding a new function member to an interface impacted all existing consumers of that interface type; it was a breaking change. The addition of interface function member implementations allowed developers to upgrade an interface while still enabling any implementors to override that implementation. Users of the interface can accept the implementation as a non-breaking change; however, if their requirements are different, they can override the provided implementations. *end note*
This clause augments the description of members in classes ([§15.3](classes.md#153-class-members)) with restrictions for interfaces. The Interface members are declared using *member_declaration*s with the following additional rules:
236
+
This clause augments the description of members in classes ([§15.3](classes.md#153-class-members)) with the differences and restrictions for interfaces:
237
237
238
238
- A *finalizer_declaration* is not allowed.
239
239
- Instance constructors, *constructor_declaration*s, are not allowed.
240
240
- All interface members implicitly have public access; however, an explicit access modifier ([§7.5.2](basic-concepts.md#752-declared-accessibility)) is permitted except on static constructors ([§15.12](classes.md#1512-static-constructors)).
241
-
- The `abstract` modifier is implied for interface function members without bodies; that modifier may be given explicitly.
241
+
- The `abstract` modifier is implied for interface function members ([§12.6](expressions.md#126-function-members)) without bodies; that modifier may be given explicitly.
242
242
- An interface instance function member whose declaration includes a body is an implicitly `virtual` member unless the `sealed` or `private` modifier is used. The `virtual` modifier may be given explicitly.
243
243
- A `private` or `sealed` function member of an interface shall have a body.
244
244
- A `private` function member shall not have the modifier `sealed`.
@@ -476,7 +476,7 @@ Interface indexers are declared using *indexer_declaration*s ([§15.9](classes.m
476
476
477
477
This clause augments the description of *operator_declaration* members in classes [§15.10](classes.md#1510-operators) for operators declared in interfaces.
478
478
479
-
An *operator_declaration* in an interface is the implementation ([§19.1](interfaces.md#191-general)).
479
+
For an *operator_declaration* in an interface the *operator_body* may only be a block body ([§15.6.1](classes.md#1561-general)) or an expression body ([§15.6.1](classes.md#1561-general)).
480
480
481
481
It is a compile-time error for an interface to declare a conversion, equality, or inequality operator.
482
482
@@ -514,7 +514,7 @@ It is an error to declare a class type, struct type, or enum type within the sco
514
514
>
515
515
>*endexample*
516
516
517
-
### 19.4.10 most specific implementation
517
+
### 19.4.10 Most specific implementation
518
518
519
519
Everyclassand struct shall have a most specific implementation for every virtual member declared in all interfaces implemented by that type among the implementations appearing in the type or its direct and indirect interfaces. The ***most specific implementation*** is a unique implementation that is more specific than every other implementation.
520
520
@@ -886,7 +886,7 @@ A *type_parameter_constraints_clause* on an explicit interface method implementa
886
886
> Explicit interface member implementations serve two primary purposes:
887
887
>
888
888
> - Because explicit interface member implementations are not accessible through classor struct instances, they allow interface implementations to be excluded from the public interface of a class or struct. This is particularly useful when a class or struct implements an internal interface that is of no interest to a consumer of that class or struct.
889
-
> - Explicit interface member implementations allow disambiguation of interface members with the same signature. Without explicit interface member implementations it would be impossible for a class, struct, or interface to have different implementations of interface members with the same signature and return type, as would it be impossible for a class, struct, or interface to have any implementation at all of interface members with the same signature but with different return types.
889
+
> - Explicit interface member implementations allow disambiguation of interface members with the same signature. Without explicit interface member implementations it would be impossible for a class, struct, or interface to have different implementations of interface members with the same signature and return type; anditwouldbeimpossiblefor a class, struct, or interface to have any implementation at all of interface members with the same signature but with different return types.
890
890
>
891
891
> *end note*
892
892
@@ -1066,7 +1066,7 @@ When a generic method implicitly implements an interface method, the constraints
Interfacemappingforaclassorstruct `C` locatesanimplementationforeachmemberofeachinterfacespecifiedinthebaseclasslistof `C`. Theimplementationofaparticularinterfacemember `I.M`, where `I` is the interface in which the member `M` is declared, is determined by examining each class, interface, or struct `S`, starting with `C` and repeating for each successive base class and implemented interface of `C`, until a match is located:
1072
1072
@@ -1463,7 +1463,7 @@ When a class implements an interface, it implicitly also implements all that int
1463
1463
1464
1464
### 19.6.8 Abstract classes and interfaces
1465
1465
1466
-
Likeanon-abstract class, an abstract classshall provide implementations of all abstract members of the interfaces that are listed in the base class list of the class. However, an abstract class is permitted to map interface methods onto abstract methods.
1466
+
Likeanon-abstract class, an abstract classshall provide implementations of all abstract members of the interfaces that are listed in the base class list of the class which are not implemented in any of those listed interfaces. However, an abstract class is permitted to map interface methods onto abstract methods.
1467
1467
1468
1468
> *Example*:
1469
1469
>
@@ -1479,7 +1479,7 @@ Like a non-abstract class, an abstract class shall provide implementations of al
1479
1479
> {
1480
1480
> publicabstractvoidF();
1481
1481
> publicabstractvoidG();
1482
-
> }
1482
+
> }
1483
1483
> ```
1484
1484
>
1485
1485
>Here, theimplementationof `IMethods` maps `F` and `G` ontoabstractmethods, whichshallbeoverriddeninnon-abstractclassesthatderivefrom `C`.
0 commit comments