P4.Net

Perforce API for the .Net CLR

Contents

  1. Introduction
  2. License
  3. Support
  4. Documentation
  5. Building P4.Net
  6. Downloads
  7. Sample Code
  8. Credits
  9. Known Issues
  10. shawn

Introduction

P4.Net is an API for the Microsoft .Net Common Language Runtime (CLR).  It can be used from any managed language including C#, VB.Net, and J#.

Licence

P4.Net is protected under <TODO> license, which is a BSD-like license.

Support

P4.Net is supported by me personally, in my spare time. If you have any issues you can contact me at p4shawn <at> gmail <dot> com.  I use P4.Net at work extensively, so I'm motivated to fix any bugs.  But I can't guarantee I'll be able to help everyone in a timely fashion, or even at all.

P4.Net vs. P4COM

P4COM can can absolutely be used from managed languages w/o issues.  So why would you want to use P4.Net?  P4COM requires you to register the dll when deploying, but since P4.Net is entirely managed code, there is no need to register any dlls.  You can literally use xcopy deployment (or p4 sync :-).  Also, P4COM is constrained by some of the inherent limitations in COM.  P4.Net uses inheritence, indexers and collection interfaces that all give it a cleaner, more .Net-like interface than P4COM (IMHO).

Documentation

Building P4.Net

1. Download the Perforce API

First, you will need to download the Perforce C++ API and unzip the contents into this folder:
P4.Net\ext\p4api

Features coded in P4.Net require at least version 2005.2.  There should be no problems using this P4.Net against older servers.

 

2. Deploying P4.Net

This is the beauty of .Net.  Simply copy P4API.dll and p4dn.dll into the same folder as your executable.  If you need to use the strong-named assemblies, I recommend you install them into the GAC.  If you are using strong-named assemblies in ASP.Net, you must install them in the GAC, or you will likely encounter file-locking issues.

Downloads

Current Builds

 

Sample code

 P4Connection p4 = new P4Connection();
 p4.Connect();
 P4Form client = p4.Fetch_Form("client");
 client["Root"] = @"c:\p4";
 p4.Save_Form(f);
 p4.Disconnect();

        

Architecture

P4.Net is divided into two distinct components.

p4dn: Written in C++, this component marshals all objects between the native Perforce C++ API and managed types.  It generally follows the object model of the native Perforce API.  It can be used directly from any managed language, but it can get complicated.  I won't attempt to document it, but between the P4API implemention and the Perforce C++ API docutmentation, you can probably figure it out if P4API isn't meeting your needs.  p4dn was originally ported from <who was it?>

P4API:  Written in C#, this component consumes p4dn, and abstracts the complexity of the native API into an easier to use syntax.  The object model is inspired from a combination P4Ruby, P4Python, P4COM, and ADO.

Credits