asiftasleem / nbuilder

Automatically exported from code.google.com/p/nbuilder
0 stars 0 forks source link

FluentInterface broken #28

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Builder<>.CreateNew() returns an ISingleObjectBuilder<>
2. all relevant methods are in IObjectBuilder<>
3. If I want to specify e.g. constructor args I have to cast the Result of 
CreateNew which breaks the nice FluentInterface

What is the expected output? What do you see instead?
I's expect intellisense to tell me what's possible after typing CreateNew
(), instead I see only Build(). When I write CreateNew().WithConstuctorArgs
() I get build errors.

What version of the product are you using? On what operating system?
2.1.8.0 on XP SP3, VS2005 clr 2.0.50727

Please provide any additional information below.

Original issue reported on code.google.com by michael....@gmail.com on 17 Aug 2009 at 11:24

GoogleCodeExporter commented 8 years ago
Hi Michael

NBuilder is intended only for use with c# 3.0 / vs 2008.

The fluent interface, with the exception of only a few core methods such as 
.Build(),
is implemented using extension methods.

WithConstructorArgs is an extension method of ISingleObjectBuilder.

To be honest I've never even tried it myself in vs2005, I'm surprised it 
actually
compiles at all!

If it does compile, perhaps you could try to get around it by invoking the 
extension
methods directly:

ISingleObjectBuilder<Product> builder = Builder<Product>.CreateNew();

SingleObjectBuilderExtensions.WithConstructorArgs(builder, arg1, arg2);

Original comment by garethdo...@googlemail.com on 16 Sep 2009 at 7:51