AutoFixture/AutoFixture — pull request #184 by adamchester (2013-09-27 16:23:54+00:00)
Title: Create a polymorphic reflection visitor

This package was [proposed by @ploeh](https://github.com/AutoFixture/AutoFixture/issues/167#issuecomment-24884100) in response to issues encountered throughout the AutoFixture codebase, including (most recently) with #167.

@ploeh [said](https://github.com/AutoFixture/AutoFixture/issues/167#issuecomment-24456434):
In the BCL, the various Reflection types aren't polymorphic. Some do share common ancestors, like MemberInfo or MethodBase, but even these base classes are of limited usefulness, because much of the interesting information is only part of the concrete classes (e.g. PropertyInfo.PropertyType versus FieldInfo.FieldType). To make matters worse, another important Reflection type, namely ParameterInfo isn't at all part of any polymorphic hierarchy.

This leads to lots of code all over the AutoFixture code base which looks like this:

```csharp
var paramInfo = obj as ParameterInfo;
if (paramInfo != null)
// do something with paramInfo

var propInfo = obj as PropertyInfo
if (propInfo != null)
// do something with propInfo

var fieldInfo = obj as FieldInfo
if (fieldInfo != null)
// do something with fieldInfo

// etc.
```

This could be addressed by defining (in the AutoFixture kernel) a [Visitor](http://en.wikipedia.org/wiki/Visitor_pattern) for the most common Reflection types used in AutoFixture: PropertyInfo, FieldInfo, ParameterInfo, ConstructorInfo, MethodInfo...