views:

45

answers:

2

I am working on an .NET library project, containing a bunch of interfaces which can be consumed by a service, which I am also creating. Users of the service will provide implementations of the interfaces from the library, which are then injected into the service application.

My library relies on a third-party library, which I will of course need to reference. One of the interfaces in my library, uses types from the third-party in its method signatures. This means, that implementors of this particular interface will also need to reference the third-party library. My concern is that this adds friction, distracting the user from doing the job she is really meant to do - implement that interface.

One solution to this problem would be to include the source files from the third-party library build, rather than referencing it as a seperate assembly. I am aware that this might make it somewhat harder for me to integrate updates to the third-party code in the future, but apart from that, are there any reasons why I should not consider this an option? When do you include third-party code rather than reference it?

Notes: The third-party library in question is quite small (less than 10 classes, total 1500 SLOC), and it is made available under the open-source license as my project (Apache License 2.0).

+3  A: 

I would be very reluctant to include the source code in your own project. Yes, your user needs to add another reference... but that means they know where it's coming from. Maybe they'll want to use it elsewhere - maybe they'll even be using another project with the same 3rd party library. You don't want to end up with multiple copies of the same type.

Additionally, keeping it as a separate library will make it a good deal easier to update as and when the third party library changes.

There are some projects which explicitly give you a "single source file" version of the library to make it easy to embed within a project. (linqbridge does, for example.) That changes things somewhat - at that point I think it's more reasonable to include it if you want to. But for "normal" projects I'd just add the reference.

Jon Skeet
A: 

In your case, I would definitly add the reference, not the source.

I don't see the benefit in adding the source. As you rightly state, it will be more difficult to integrate updates. Also, for an update, you would need to rebuild.

My recommendation: add the reference, and just add a comment in the definition of the interface, where to get the library, and why you are using it.

Marcel