Description
Summary
Offer "Implement interface" in type declaration body block too when it is empty yet.
Background and Motivation
"Implement interface" is only offered in the type declaration signature scope so far.
While it is intuitive to declare the skeleton of the type first:
class C : I
{
$$ // you end up here after declaration
// next step is to start implementation
}
To invoke the "Implement interface" code fix, you need to go back to the signature span:
class C : I$$
{
}
Proposed Feature
So, it would be intuitive and handy if we could call "Implement interface" right here:
interface I
{
void M();
}
class C : I
{
$$
}
To not get too intrusive (and display this code fix anywhere anytime in the body block), the availability could be limited to a few cases where it makes sense. For a start:
- offer the code fix inside the declaration body block only when it is empty (trivia-only)
Alternative Designs
I'm aware that the "Implement interface" can be invoked on a "partially" completed declaration too, where only the signature is there and there are no braces yet (e.g. class C : I
, and it is going to add them as well, but most people may not.
A similar experience is "Implement with Copilot" for throw new NotImplementedException();
-bodied methods.
(In this proposal I refer to the symbolic "Implement interface" code fix and not the newly introduced Copilot-based implementation.)