Tonight I was working on a unit test for an internal class:
internal class LockPipeline
{
...
}
class LockPipelineTest
{
LockPipeline pipeline // COMPILER ERROR
...
}
At this the compiler emitted an error:
Public field 'LockPipelineTest.pipeline' cannot use internal type 'bind::LockPipeline'
This threw me for a little bit until the word "public" jumped out at me. I changed the variable declaration to private and the test compiled.
It's great that the compiler prevents you from leaking internal classes into public API, however the error message could have been a little more specific, e.g.:
Public fields cannot reference internal types. Either 'LockPipelineTest.pipeline'
should be made private, or 'bind::LockPipeline' should be made public.
Something like this would have made the error more obvious and saved some time.
brianFri 22 Oct 2010
I like to keep error messages to fit on a single line (~70 chars or so). I personally think the current error message is pretty concise and explicit?
qualidafial Fri 22 Oct 2010
Tonight I was working on a unit test for an
internal
class:At this the compiler emitted an error:
This threw me for a little bit until the word "public" jumped out at me. I changed the variable declaration to
private
and the test compiled.It's great that the compiler prevents you from leaking internal classes into public API, however the error message could have been a little more specific, e.g.:
Something like this would have made the error more obvious and saved some time.
brian Fri 22 Oct 2010
I like to keep error messages to fit on a single line (~70 chars or so). I personally think the current error message is pretty concise and explicit?