We introduce packaging, distribution and documentation C# driver for TypeDB (the original driver PR). It is built using the cross-platform .NET 6 framework.
Usage:
The driver is distributed as a series of Nuget packages. To use the driver, import the latest versions of the driver (TypeDB.Driver) and its Pinvoke runtime (TypeDB.Driver.Pinvoke) suitable for your platform.
CS project:
Here is an example from a .csproj for MacOS x86-64:
If you aim to build a platform-independent package, reference all the needed runtimes (it will affect the size of your application by downloading a respective set of platform-specific dynamic libraries):
Import both the TypeDB.Driver and TypeDB.Driver.Pinvoke nuget packages as dependencies to your build rule.
For development, you can also use a csharp bazel rule, passing targets //csharp:driver-csharp (the driver itself), //csharp/Api:api (exposed Api namespace), //csharp/Common:common (exposed Common namespace) as dependencies.
A simple usage example (see csharp/Test/Integration/Examples for more):
using TypeDB.Driver.Api;
using TypeDB.Driver.Common;
public class TypeDBExample
{
public void SetupTypeDB()
{
string dbName = "access-management-db";
string serverAddr = "127.0.0.1:1729";
try
{
using (ITypeDBDriver driver = Drivers.CoreDriver(serverAddr))
{
driver.Databases.Create(dbName);
IDatabase database = driver.Databases.Get(dbName);
using (ITypeDBSession session = driver.Session(dbName, SessionType.Schema))
{
using (ITypeDBTransaction transaction = session.Transaction(TransactionType.Write))
{
transaction.Query.Define("define person sub entity;").Resolve();
string longQuery = "define name sub attribute, value string; person owns name;";
transaction.Query.Define(longQuery).Resolve();
transaction.Commit();
}
}
database.Delete();
}
}
catch (TypeDBDriverException e)
{
Console.WriteLine($"Caught TypeDB Driver Exception: {e}");
}
}
}
Implementation
Documentation:
Documentation for C# is generated in a similar way as the C/C++ ones: doxygen -> adoc. This way, the C# parser has some extra logic of parsing the intermediate doxygen files but follows a similar (copypasted) structure. Additionally, some small bugs for both old parsers have been fixed.
Distribution:
We decided to distribute the C# driver as a series of packages to allow the end user to choose between multi-platform and compactness. This way, we have:
TypeDB.Driver.{X-X-X-version}.nupkg - the main package with the driver, which fails in runtime if no runtime is additionally provided.
TypeDB.Driver.Pinvoke.{X-X-X-version}.{platform}.nupkg - platform-specific runtimes (osx-x64, osx-arm64, linux-x64, linux-arm64, win-x64).
The distribution is implemented via several bazel rules: nuget_pack (with a wrapper for native packages in this PR) and nuget_push and their respective calls for both runtime and main packages.
Tests:
Integration tests use NUnit framework as a built-in framework for C# bazel test rules. This PR presents both test-core and test-cloud as small usage examples within the integration tests. These tests are also triggered by Factory.
There is also a new Deployment test, which creates a .csproj project and tries to fetch all the needed (and all the available runtime) packages to use them for another small C# program. This test is triggered by CircleCI.
Usage and product changes
We introduce packaging, distribution and documentation C# driver for TypeDB (the original driver PR). It is built using the cross-platform .NET 6 framework.
Usage:
The driver is distributed as a series of Nuget packages. To use the driver, import the latest versions of the driver (TypeDB.Driver) and its Pinvoke runtime (TypeDB.Driver.Pinvoke) suitable for your platform.
CS project: Here is an example from a
.csproj
for MacOS x86-64:If you aim to build a platform-independent package, reference all the needed runtimes (it will affect the size of your application by downloading a respective set of platform-specific dynamic libraries):
Bazel:
TypeDB.Driver
andTypeDB.Driver.Pinvoke
nuget packages as dependencies to your build rule.//csharp:driver-csharp
(the driver itself),//csharp/Api:api
(exposed Api namespace),//csharp/Common:common
(exposed Common namespace) as dependencies.A simple usage example (see
csharp/Test/Integration/Examples
for more):Implementation
Documentation: Documentation for C# is generated in a similar way as the C/C++ ones:
doxygen
->adoc
. This way, the C# parser has some extra logic of parsing the intermediate doxygen files but follows a similar (copypasted) structure. Additionally, some small bugs for both old parsers have been fixed.Distribution: We decided to distribute the C# driver as a series of packages to allow the end user to choose between multi-platform and compactness. This way, we have:
TypeDB.Driver.{X-X-X-version}.nupkg
- the main package with the driver, which fails in runtime if no runtime is additionally provided.TypeDB.Driver.Pinvoke.{X-X-X-version}.{platform}.nupkg
- platform-specific runtimes (osx-x64
,osx-arm64
,linux-x64
,linux-arm64
,win-x64
).The distribution is implemented via several bazel rules:
nuget_pack
(with a wrapper for native packages in this PR) andnuget_push
and their respective calls for both runtime and main packages.Tests: Integration tests use NUnit framework as a built-in framework for C# bazel test rules. This PR presents both
test-core
andtest-cloud
as small usage examples within the integration tests. These tests are also triggered by Factory.There is also a new Deployment test, which creates a
.csproj
project and tries to fetch all the needed (and all the available runtime) packages to use them for another small C# program. This test is triggered by CircleCI.