I have a set of so called fluent interfaces, so I can use syntax like this:
a.With("abc").Do("this").Then("that);
Each method returns an object cast to a corresponding interface. At design time I can use Intellisense to easily navigate between API methods. However I can no longer do it if I cast one of the arguments to a dynamic:
a.With((dynamic)"abc").Do("this").Then("that);
Not only I lose Intellisense at design time, this cast affects runtime execution: all subsequent calls after With return objects of a dynamic type potentially breaking the execution logic.
What I fail to understand is why should a dynamic argument affect contracts that only use static types. If a method With is designed to return an instance of ISomeInterface and the implementation returns SomeClass (that implements ISomeInterface), why should a dynamic object used in unrelated place infect all subsequent call chain? Is there any way to prevent it?