We're new to using P4API.NET, and we've found one aspect particularly confusing: the lifecycle of a Connection and its private P4Server object.
1) Naming confusion.
Semantically, the Connection class represents a "connector" rather than a connection (it can connect and disconnect), while the P4Server object represents the connection. The naming is rather confusing.
--------
2) Phantom events.
There are various events defined on the Connection class (CommandEcho, ErrorReceived, InfoResultsReceived, TaggedOutputReceived, TextResultsReceived) but this is a little illusory ("phantom" events): the events are really on the P4Server object. Consider these:
* you subscribe to CommandEcho before Connect()ing and you get a NullReferenceException because there's no underlying P4Server object yet
* OK, so you Connect() first, then subscribe to CommandEcho; then you Disconnect() and Connect() again and - guess what - your subscription has been lost
--------
3) Phantom property: CommandTimeout
Same as above: setting Connection.CommandTimeout before Connect() throws a NullReferenceException.
Similar to CommandTimeout, setting Connection.CurrentWorkingDirectory is completely ineffective before Connect(). However, unlike in the cases above, calling it before Connect() does *not* throw. It just does nothing. This is not only confusing, but it's also inconsistent with the behaviour of the other "phantom" events/properties above.
--------
In all of 2), 3), 4), one must be familiar with the internals of Connection to be able to use it. Specifically, one must know that all these events and properties are passed through to the private (!) _p4server field, and also that the field is disposed in Disconnect().