I just know I'm being an idiot, so somebody please tell me how.
Setup is simple:
Create a solution with three projects (.Net framework, class libraries) named
InherTest
,InherTest.Base
, andInherTest.Base.Inherited
In
InherTest.Base
, add the following class:namespace InherTest.Base { public abstract class BaseClass { internal abstract string MEMBER_1 { get; } } }
Copy the exact same code into
InherTest
, including the namespace.In
InherTest.Base.Inherited
, add the following class:namespace InherTest.Base.Inherited { public class Inherited : BaseClass { internal override string MEMBER_1 { get; } } }
Add a project reference in
InherTest.Base.Inherited
toInherTest.Base
. Note the errors ("abstract member not implemented" and "no suitable member found to override").Remove that reference and replace it with one to
InherTest
. Observe that the inheritance also fails.
Why don't they both work?
Edit: Originally I stated that one test would fail and the other would succeed; however, both inheritance attempts fail in the above scenario.
MEMBER_1
should be declaredpublic
– Rahul Jul 19 '18 at 15:23Why don't they both work?
<= They should both fail if they contain the same code as you claim. If that is not the case then the code is different between the 2 projects, specifically theMEMBER_1
is probably declared aspublic
inInherTest
project. Alternatively you have an assembly level attribute[assembly:InternalsVisibleTo("InherTest.Base.Inherited")]
in the projectInherTest
– Igor Jul 19 '18 at 15:26