Note: I checked the first two pages of search results that the Ask Question page brought up, but none address the issue/question I have.
Update: Having restarted VS after a good night's rest, the inconsistency is gone...
Going back to the commit with the code that did not produce the error before, and even going as far as deleting the bin and obj folders, now of course dutifully produces the error consistently and I can only make it go away by changing the code - as it should be.
Which makes me both :D and :(
I do dislike this kind of inconsistent behavior!
Why would code that compiles fine using MSTest, suddenly throw
Error 1 Inconsistent accessibility: return type
'ActualProject.ClassHierarchy.BaseJointer' is less accessible than method
'TestProject.ClassHierarchy.BaseJointer_Tests.MakeJointer()'
when adding NUnit into the mix?
The class that is "less accessible":
class BaseJointer
{
public DoveTailJoint MakeDoveTailJoint(
PieceOfWood woodTails, PieceOfWood woodPins)
{ return null; }
}
than the method:
[TestClass]
public class BaseJointer_Tests
{
protected virtual BaseJointer MakeJointer()
{
return new BaseJointer();
}
}
The error does not occur when none of the projects references NUnit.
The error does occur in two scenarios:
- When there are two projects in the solution:
ActualProject
andTestProject
.TestProject
already referenced MSTest. The error occurred when adding a reference to NUnit to theTestProject
. - When there are three projects in the solution:
ActualProject
,TestProject
only referencing MSTest andNUnitTestProject
only referencing NUnit.
The second one has me especially baffled as it produces an error on (the code of) the TestProject
which doesn't reference NUnit at all.
FYI: ActualProject has InternalsVisibleTo
set to both TestProject and NUnitTestProject
Why would internal
become less visible than protected
by sole virtue of adding a reference to the NUnit test framework?