Skip to content

Test plan for "Default Interface Implementation of static members" feature #60968

@AlekseyTs

Description

@AlekseyTs

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 DllImportAttribute applied
  • Disallowed modifiers on DIMs
    • abstract
    • override
    • private
    • readonly
  • static virtual disallowed outside interfaces
  • Reabstract DIMs
    • Via abstract in derived interface
    • No way to reabstract in class/struct
  • 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
  • virtual modifier is added
  • abstract modifier is not added for DIM
  • abstract and .override added 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 static modifier after virtual, IDE behavior has been adjusted to meet expectations.
  • Completion of virtual modifier after abstract, IDE behavior has been adjusted to meet expectations.
  • Completion of implicit/explicit keywords 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 static modifier 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

Metadata

Metadata

Type

No type

Projects

Status

Language/design

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions