ReadOnlyLocator.ParentLocator

Topics: ObjectBuilder
Sep 14, 2007 at 11:23 AM
I haven't tried it but by looking at the code I can clearly see that if the ParentLocator of the innerLocator is null, it would throw an ArgumentNullException instead of simply returning null as per the contract of IReadableLocator.

I think it should check for null first.
Coordinator
Sep 15, 2007 at 1:29 PM
Sorry, perhaps the name of "ReadOnlyLocator" doesn't clearly express what it does. It wraps and existing readable locator and ensures that it can only be read. It's like calling ".AsReadOnly()" on one of the built-in containers in .NET.
Sep 15, 2007 at 2:35 PM
It is quite clear to me. I was just saying it should respect IReadableLocator contract.

IReadableLocator locator = new Locator();
Assert.IsNull(locator.ParentLocator);

locator = new ReadOnlyLocator(locator);
Assert.IsNull(locator.ParentLocator); //Will throw ArgumentNullException when it should Assert successfully.
Coordinator
Sep 15, 2007 at 7:15 PM
Ah, you're right. I mis-read your original post. This is a bug.

Thanks!
Coordinator
Sep 15, 2007 at 8:07 PM
I've fixed this in the ObjectBuilder project used by the CodePlexContainer sample in change set 26886:

http://www.codeplex.com/ObjectBuilder/SourceControl/ListDownloadableCommits.aspx
http://www.codeplex.com/ObjectBuilder/SourceControl/DirectoryView.aspx?SourcePath=&changeSetId=26886