Cook Computing

Using NAnt to Build .NET Projects

January 28, 2003 Written by Charles Cook

O'Reilly have an introductory article on NAnt (via Meerkat). I've thought about using NAnt with XML-RPC.NET but before investing the time in setting it up I'd like to be sure that I'll be able to run NAnt on Linux using Mono. I did some research this morning and couldn't find a definite answer. If anyone has NAnt running on Linux please let me know.

Speaking of Meerkat, last night I wrote an XML-RPC.NET interface and test client to access the Meerkat XML-RPC implementation. This was to test the work I'm doing on optional struct members. The recipe parameter to meerkat.getItems can now be represented by a struct like this:

struct Recipe
  // search criteria
  public XmlRpcInt channel;
  public XmlRpcInt category;
  public XmlRpcInt item;
  public string search;
  public string search_what;
  public string time_period;
  public XmlRpcInt profile;
  public XmlRpcInt mob;
  public string url;
  // display recipes
  public int ids;
  public int descriptions;
  public int categories;
  public int channels;
  public int dates;
  public int dc;
  public XmlRpcInt num_items;

The XmlRpcMappingAction attribute specifies that all the members are optional. So only a subset of the search criteria members need be set and the others members which will default to null will not be transmitted in the XML-RPC request. Similarly with the num_items member. The other display recipe items are value types and will default to zero if not explicitly set, just the behavior we want. So calls are as flexible as the Meerkat API allows:

Recipe recipe = new Recipe(); = 5209; = "/Java|p2p/";
recipe.search_what = "dc:subject";
recipe.time_period = "30DAY";
recipe.descriptions = 1;
recipe.dc = 1;
recipe.num_items = 3;
Result[] results = meerkat.GetItems(recipe);

Recipe recipe = new Recipe();
recipe.category = 63;
recipe.descriptions = 1;
Result[] results = meerkat.GetItems(recipe);

For handling the results from meerkat.getItems this structure can be used:

struct Result
  public string title;
  public string link;
  public string description;
  public string dc_creator;
  public string dc_subject;
  public string dc_publisher;
  public string dc_date;
  public string dc_format;
  public string dc_language;
  public string dc_rights;

Again the default for the structure is to ignore missing members but because we always expect title and link we can override their MappingAction settings individually so that an exception is thrown if these members are missing from any of the structs in a response.

I'll include the interface and associated types in the XML-RPC.NET FAQ when I put out the next release. It feels good to have made this change. Meerkat was one of the first XML-RPC APIs I tested the library with and it has always bugged me that an accurate .NET representation was not possible.

Finally, one other change required to use Meerkat is that its PHP XML-RPC implementation does not like any indentation or newline whitespace between elements in the XML-RPC request. It returns garbage in this situation even though the request is valid. I had to modify the XML-RPC.NET code to work around this and so I'll probably enhance the XmlRpcClientProtocol class to make indentation, etc, configurable.