Modifier to mark interface implementation (implement
complementing override
)
#7764
Unanswered
gatlex
asked this question in
Language Ideas
Replies: 2 comments 32 replies
-
See also: #7210 For this specific case you could also use a custom attribute with an analyzer to warn/error on annotated methods that don't implicitly implement an interface member. This is kind of how |
Beta Was this translation helpful? Give feedback.
8 replies
-
You can use explicit interface implementations to get a similar effect public interface IFoo
{
void Bar();
}
public class Foo : IFoo
{
void IFoo.Bar()
{
// implementation
}
} |
Beta Was this translation helpful? Give feedback.
24 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I suggest to introduce a modifier to mark a method as an implementation of the
interface
.DR: It greatly introduces maintainability. It is quite common in large projects and medium-sized refactorings, that a method is removed from an interface - but the (former) implementation remains as dead code.
Edit: Another solution for my goal would be to 'improve' on explicit interface implementation as detailed in this comment.
Regarding naming I have no strong opinion. Two options that come to mind:
override
.Pro: Keyword exists.
Con: Language lawyers will argue that this would not truly reflect the meaning as the method does not actually override but implements the interface method.
implement
or similar.Beta Was this translation helpful? Give feedback.
All reactions