What is the argument against declaring protected-access members on interfaces? This, for example, is invalid:
public interface IOrange
{
public OrangePee
An interface is just like the shape of a key.
It's not the key.
It's not the lock.
It's just the slim contact point.
For this reason all the members of the interface (that defines the shape of the key) must be public.
For a key to open a lock it is important that they both share the same shape.
By making the shape (the interface) public, you can let others create compatible locks or compatible keys.
Otherwise, making it (the interface) internal you will not allow others to create compatible locks or compatible keys.
An interface is a contract that promises certain functionality to clients. In other words, the purpose of an interface is to be able to cast a type into it and pass it around like that to code that needs the features guaranteed by that interface. Since client code of a type cannot access protected members of that type, it makes no sense to declare protected items in an interface.
By implementing an interface the type states that it supports a specific set of methods. If any of these methods were not public, it would not be available to callers and thus the type would not support the interface as stated.
There's sound judgment in current design of interfaces which is that it offers implementers greater flexibility. Remember that very often interfaces are written by framework programmers and implementers are different folks. To enforce implementation would be needlessly harsh.
Interface members are a public API; things like protected
etc are implementation details - and interfaces don't have any implementation. I suspect what you are looking for is explicit interface implementation:
public class NavelOrange : IOrange
{
public OrangePeel Peel { get { return new OrangePeel(); } }
OrangePips IOrange.Seeds { get { return null; } }
}
Interfaces exist to allow people to access your class without knowing what the concrete implementation is. It completely divorices the implementation from the data passing contract.
Therefore, everything in an interface must be public. Non-public members are only useful if you have access to the implementation and therefore don't meaningfully contribute to an interface definition.