Closed GoogleCodeExporter closed 8 years ago
Hi Russell,
From what I can ascertain from the code, the AreConstructedUsing method is
intended to be used to construct a class with an alternate constructor for the
class being constructed using Builder<T>. As such, it is not intended to be
used in the way you have attempted.
I believe the reason you are currently unable to do what you are wanting is not
due to NBuilder but rather the version of C# you are using. It turns out C# 4.0
has better support for covariance and contravariance:
http://blogs.msdn.com/b/csharpfaq/archive/2010/02/16/covariance-and-contravarian
ce-faq.aspx
During my investigation of this issue, I tested my thought that this was a
covariance/contravariance type isue by testing NBuilder in a .NET 3.5 and a
.NET 4 project.
This is the code I used:
List<Parent> children = Builder<Child>
.CreateListOfSize(3)
.Build()
.ToList<Parent>();
This code only compiles in .NET 4. The result is a list of Parent type
containing Child type instances.
In light of the evidence, I will presently be closing this defect. If you feel
that this is being closed in error, please let me know and we can discuss this
further.
All the best upgrading to C# 4.
Regards,
Joshua Roth
Original comment by joshuajr...@gmail.com
on 10 Sep 2010 at 12:14
Original issue reported on code.google.com by
russell....@googlemail.com
on 16 Feb 2010 at 12:02