-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Area-CompilersFeature - Default Interface ImplDefault Interface ImplementationDefault Interface ImplementationFeature - StaticAbstractMembersInInterfaces
Milestone
Description
Feature branch - https://github.com/dotnet/roslyn/tree/features/DefaultInterfaceImplementation
Specification - https://github.com/dotnet/csharplang/blob/main/proposals/csharp-11.0/static-abstracts-in-interfaces.md
Static Abstract Members test plan - #52221
DIM specification - https://github.com/dotnet/csharplang/blob/main/proposals/csharp-8.0/default-interface-methods.md
DIM test plan - #19217
Proposal: dotnet/csharplang#4436
Syntax
- SyntaxNormalizer
Semantics
- Allowed modifiers on DIMs
-
virtual -
sealed -
partial- One part disallows body
-
extern- Body disallowed
- Warning if no
DllImportAttributeapplied
-
- Disallowed modifiers on DIMs
-
abstract -
override -
private -
readonly
-
-
static virtualdisallowed outside interfaces - Reabstract DIMs
- Via
abstractin derived interface - No way to reabstract in class/struct
- Via
- Kinds of DIMs allowed:
- Methods
- Properties
- Indexers
- Conversions
- Operators
- Events
- Reimplementation
- Explicit implementation in derived interface
- Explicit implementation in derived class
- Implicit implementation in derived class
- Implicit implementation of a get-only virtual static can add setter in derived class
- Derived interface members hide, not reimplement
- Most specific implementation
- Derived interface DIMs do not count as the most specific implementation for a static abstract
- Explicit implementations in a derived interface count as the most specific implementation
- Direct access to DIMs is disallowed
- Only access through type parameter is permitted
Emit
- Methodimpl entry is added for every non-virtual implicit override
- No virtual implicit overrides are possible
-
virtualmodifier is added -
abstractmodifier is not added for DIM -
abstractand.overrideadded for re-abstraction
Productivity
- Formatter
- EnC/Hot Reload
- Inside methods
- On transition from DIM to abstract
- On transition from abstract to DIM
Features covered during IDE test pass:
- Completion of
staticmodifier aftervirtual, IDE behavior has been adjusted to meet expectations. - Completion of
virtualmodifier afterabstract, IDE behavior has been adjusted to meet expectations. - Completion of
implicit/explicitkeywords for re-abstraction in derived interfaces. - Member completion on ‘dot’ after an interface type in declaration of an explicit interface implementation in derived interface.
- Completion list on ’dot’ after type parameter constrained to an interface with static abstract members. Completion is not offered for static virtual members, tracked by Static virtual members of interfaces are not included into completion list on a type parameter #61255
- Implement interface fixer doesn't add implementation for virtual static members (as expected).
- Implement interface fixer doesn't add implementation for static members implemented in derived interface (as expected).
- Implement interface fixer adds implementation for virtual static members re-abstracted in derived interface.
- There is an existing bug, the "implement interface explicitly" option doesn't spit out static modifier for static events and properties - Implement interface fixer doesn't spit out
staticmodifier implementations of static members #53925 - There is an existing bug around implementing conversion operators with the "implement interface explicitly" fixer - "Implement interface explicitly" fixer implements conversion operators implicitly #61263
- "Go To Implementation" on static abstract member finds implementations in derived interfaces and classes.
- "Go To Implementation" on static virtual member finds the member itself (expected?) and implementations in derived interfaces and classes.
- "Go To Definition" on an implementation in a derived interface. There is an existing issue (exists for instance members) - "Go To Definition" on re-abstraction doesn't go the re-abstracted member #61268.
- "Go To Definition" on an implementation in a class.
- "Go To Definition" at the call site.
- "Find All References" on virtual static members
- "Rename"
- Declaration
- Implementation
- Call site
Reactions are currently unavailable
Metadata
Metadata
Labels
Area-CompilersFeature - Default Interface ImplDefault Interface ImplementationDefault Interface ImplementationFeature - StaticAbstractMembersInInterfaces
Type
Projects
Status
Language/design