views:

50

answers:

2

I'm a relatively new employee at my current company, so I'm still "drinking from the fire hose" in terms of learning my way around the software and architecture. I've found myself dealing with some very large objects while writing unit tests, let's say for discussion a "SavedOrder", and I need to find where to find a particular piece of data I'm looking for.

The problem I'm having is that I know that each SavedOrder has, somewhere in the innards of it's inheritances and members (who have members, of whom have members, and so on and so on), the piece of data I'm looking for.

For now I find myself mindlessly expanding my watches and mousing over the objects to hopefully find what I'm looking for. Does anybody know of a plugin/technique to use to find if this object has something of "Type A" or something of value "SomeEnum.SomeValue"?

EDIT: All good input, nothing yet that completely solves my goal. The object browsers (Object Browser and Reflector) do a good job of browsing the members of each object, but in the goal of linking point A to point D, they really just help in bringing point A to point B or D to C.

I guess the pseudo c# recursive algorithm that would best describe a solution would be:

WheresWaldo FindMember(Object o)
{
    foreach(PublicMember member in o)
    {
         if(o.IsType(MyType))
            return Success!;
         else
            return WheresWaldo(member);
    }


}

Who knows, maybe not possible.

+3  A: 

I am not sure I follow you completely, but perhaps you could use a conditional break point. Set a break point on the relevant code, right click and select conditional break point. From here you can write a piece of code, that will be evaluated each time the break point is evaluated. That way you can specify to only stop when the condition is met.

EDIT: Based on your comments, I would say that Reflector may be useful. It has the option to search for specific types or members. Launch Reflector with you relevant assemblies. Press F3 for search and select Ctrl-M for members and type the name of the member you're looking for. You can toggle exact match on/off to help you with the search.

Brian Rasmussen
I did find it difficult to describe what I wanted. To clarify, suppose my goal was to find the warranty length of an order, and that warranty was in SavedOrder.Header.ProductSupport.WarrantyLength but I had no idea that's where it was (and with many more gray object names to deal with). How would I go about finding where that field was?
eskerber
Are you looking to find the value of WarrantyLength for a particular instance or are you not sure what type has this property?
Brian Rasmussen
I'm not sure "where" it is :).What I was trying to show was that the property was "4 deep" in that SavedOrder has a Header, which has a ProductSupport, which has a WarrantyLength property. I know just by intuition that the warranty is somewhere in the SavedOrder, but don't know how to navigate the hundreds of properties to find it.
eskerber
+1  A: 

ObjectBrowser is probably what you want to use. You can search for properties using that.

PaulG
Oooh almost, I have used that but forgot about it. It's only flaw is that I can browse the type SavedOrder and it can show me all of it's inherited and owned members, but not the members OF those members (i.e. that ProductSupport is a member of Header without browsing to Header). So the WarrantyInfo will still be difficult to find.
eskerber