2
Vote

Upgrade to .Net 4.0 to support CreateAnonymous<T> for types with optional ctor params

description

I just came across an issue where CreateAnonymous<T> doesn't work for a type that has an optional param in the constructor.
Obviously this requires upgrading AutoFixture to .Net 4.0

comments

ploeh wrote May 26, 2011 at 7:34 PM

Upgrading AutoFixture to .NET 4.0 is quite a big step, although I must admit that I have no hard numbers about the platforms on which AutoFixture is used today. On the other hand I know about at least one heavy user who's currently on .NET 3.5 and likely to stay there for the foreseeable time.

In any case I believe that AutoFixture should be upgraded to .NET 4.0 when there's a compelling reason to do that. However, optional parameters are rather an abomination that should never have been in the framework, so I don't think AutoFixture should be upgraded just because of that.

That doesn't mean that it's impossible to address the issue. What could be done is this: an ICustomization (probably adding a custom ISpecimenBuilder) could be added in a .NET 4.0 assembly. This would essentially be a .NET 4.0-specific extension to AutoFixture, defined in a separate assembly.