I have been refactoring the codebase of the project that I am currently on so that classes/interfaces which are not useful beyond the confines of the assembly should be declared as internal (rather than public). But I've run into a problem with the following code:
internal interface IFirstInterface
{
...
}
internal interface ISecondInterface
{
IFirstInterface First{ get; }
...
}
public class Implementer : ISecondInterface
{
public IFirstInterface First {get; private set;}
...
}
My questions:
Why do members of internal interfaces have to be publicly implemented?
While I can live with defining implementations of interface members as public (they won't be publicly accessible anyway since the class is internal) - I run into problems with the scenario above since I cannot have a public getter for IFirstInterface since it is purportedly an internal interface i.e. I get the following error from the compiler:
Inconsistent accessibility: property type 'IFirstInterface' is less accessible than property 'Implementer.First'
Is there any way around this?
Note: I realise that there is probably little value in this refactoring exercise but I thought it would be a good way for me to understand more deeply the implications of the internal modifier.