I’ve been trying without success for the last hour to limit the results of a TFS query. It would be, on the face of it, relatively simple: I already know how to get all of the builds of a certain type, I just want to limit it to the last week. You might think this was achievable using LINQ, and it would be if the problem you were trying to solve was anything other than a timeout. Instead you find yourself falling down a rabbit hole.
Basically, in order to perform such a query, you need to pass in an implementation of IBuildDetailSpec. This, in turn references, IBuildDefinitionSpec. They’re both great big DTOs wrapped in an interface. You might be wondering at this point why the interface has so many set properties, but Resharper cuts the implementation work down. However, there’s a nasty shock waiting for you: an invalid array cast exception. You see, TFS doesn’t really expect an IBuildDetailSpec, it expects a BuildDetailSpec. Which is an internal sealed class. You’re actually expected to create this object through the store’s own factory.
Seriously, what benefit is there to exposing an interface when only one implementation could ever possibly work? I understand Microsoft has different priorities from open source developers, but I genuinely can’t think of an angle in which wrapping a DTO in these layers helps.