Skip to content

Getting Started

Brian Chavez edited this page Feb 15, 2016 · 22 revisions

Prerequisites

Checkout

  • git clone https://github.com/bchavez/RethinkDb.Driver.git
  • cd RethinkDb.Driver

Build Commands

The following build tasks are defined in BauBuild.cs. Execute any of the following build commands in the root project folder.

  • build - By default, triggers build msb.
  • build msb - Builds binaries for .NET Framework v4.5 using msbuild.
  • build dnx - Builds CoreCLR binaries using dnu build.
  • build mono - Builds Mono binaries using xbuild.
  • build clean - Cleans up build.
  • build astgen - Regenerates C# AST classes from *.json files.
  • build pack - Builds local NuGet packages.
  • build restore - Restores NuGet (runtime and devtime) packages. You must run this first before opening .sln files in Visual Studio.

The following folders at the root checkout level be generated:

  • __compile - Contains the result of the build process.
  • __package - Contains the result of the packaging process.

Project Structure

  • build.cmd - Ensures sane build environment and forwards build commands to Builder.
  • Source\Builder - Primary location where build tasks are defined. See BauBuild.cs.
  • Source\RethinkDb.Driver - The RethinkDB C# driver.
  • Source\RethinkDb.Driver.Tests - Driver unit tests.
  • Source\Templates - Code generation templates.

Driver Architecture

There are two main components of this C# driver. The ReQL Abstract Syntax Tree (AST) and the infrastructure to handle serialization/deserialization of the AST. The infrastructure also handles communication with a RethinkDB server.

AST & Code Generation

The ReQL AST is located in Source\RethinkDb.Driver\Generated\Ast. The AST C# classes are generated using code generation templates in Source\Templates. The code generation process is similar to the Java driver, except this C# driver requires JSON metadata files derived the Java driver's python scripts (namely, metajava.py). The JSON metadata files required to rebuild the AST (and other objects) are:

  • proto_basic.json
  • java_term_info.json
  • global_info.json

These files reside inside Source/Templates/Metadata.

java_term_info.json is a special file (not to be confused with term_info.json). java_term_info.json is a more refined output of term_info.json that includes extra metadata to support OOP language semantics when generating RethinkDB's AST.

To generate the intermediate JSON files required by this C# driver:

  1. Clone the rethinkdb repository (preferably on a Linux computer with build/make tools).

  2. Inside the cloned repo, run: ./configure --allow-fetch

  3. Next,

    make build/drivers/java/proto_basic.json
    make build/drivers/java/java_term_info.json
    

The required JSON files will be in the following locations:

  • rethinkdb/build/drivers/java/proto_basic.json
  • rethinkdb/build/drivers/java/java_term_info.json
  • rethinkdb/drivers/java/global_info.json

The JSON files above can be copied to & overwritten inside the C# driver's folder Source/Templates/Metadata. The build astgen task will use the *.json files mentioned above to regenerate all AST C# classes, protocol enums, and various models.

build astgen build task essentially runs Templates\GeneratorForAst.cs:Generate_All().

Updating Code Generation Templates

The code generator templates are located in Source/Templates/CodeGen/. The templates are RazorGenerator templates. Updating any of the *.cshtml code generation templates requires installing RazorGenerator's Visual Studio Extension or using RazorGenerator's MSBuild task to transform the Razor *.cshtml templates to *.generated.cs razor code-behind files.

Clone this wiki locally