Skip to content

Getting Started

Brian Chavez edited this page Oct 29, 2015 · 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 yamlimport - Imports and cleans up freshly copied YAML tests from the Java driver. See Unit Tests section below.
  • build testgen - Generates C# unit tests from refined YAML tests.

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
  • global_info.json
  • java_term_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. java_term_info.json generated by running the following command in the Java driver's folder:

python3 metajava.py --term-info term_info.json --output-file java_term_info.json generate-java-terminfo

The result of the command above will produce java_term_info.json. The JSON files inside the Java driver's folder 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