Osy#betaRun it on Osyrin: osyrin.com

Reference / Local

Generating the C# a native provider implements

osy seam generate <interface> [-o <file>] [--json]

Writes the C# interface, and the plain classes it carries, for a seam a native .NET provider implements — `IBlobStore`, `IEntitySource`, `IWritableEntitySource` or `IExportSink` — exactly as this platform declares it, stamped with the seam hash the platform checks. A seam that extends another is written with it: generate the one you implement.

previewlocalcliprovidersnative

Summary#

A provider is normally Osy#: a class in a package that implements a seam. When what it needs cannot be reached from Osy# — a vendor driver with no HTTP API, a proprietary library — it can be written in C# instead, against the same seam. osy seam generate writes that seam as C#: the interface and every class it carries, with the platform's documentation, stamped with the seam's hash.

Signature#

osy seam generate <interface> [-o <file>] [--json]

Description#

What it writes#

The seam as this platform declares it in Osy#, read from the platform itself — no repository, no account. A method that answers nothing returns Task, one that answers a value Task<T>, and one that streams IAsyncEnumerable<T>; every method takes a trailing CancellationToken. The classes a seam carries — a query plan, a batch of changes — are plain classes of text, numbers, bools, dates, ids, byte[], enums, lists and string-keyed dictionaries.

Without -o the C# is printed; with it, written to the file. --json prints the seam, its hash and the file.

The file is self-contained. It declares the [SeamHash] attribute beside the seam, so the provider's project references nothing of the platform's: compile it into the project that implements the seam.

The seam hash#

The interface carries [SeamHash("…")]: a hash of every member's name, type and default in the Osy# declaration, and of nothing a comment says. A provider built against one hash is refused by a platform whose seam has another, naming the package, the seam and both hashes — before it serves anything. So regenerate after upgrading the toolchain, and rebuild the provider.

Where a native provider may run#

Native code runs on dedicated and self-hosted platforms, where the only tenant it can affect is the one who chose it. A package ships the assembly with its manifest's native role and declares the class as a native class. A deploy to shared hosting refuses a native package, naming the tiers that run it.

Examples#

osy seam generate IEntitySource -o src/Seams/EntitySource.g.cs
osy seam generate IBlobStore --json

See also#

Related

native class — a provider implemented in .NET

A `native class` is a provider whose behaviour is a .NET assembly its package ships. It is declared in Osy# for what…

package.osy

The manifest that makes a git repository a publishable Osy# package. It names the package, says which of the…

data held somewhere else (app.DataSources)

`app.DataSources` registers the places an app's data can live besides its own database — a warehouse, a SaaS table API…

data sent somewhere else, as it changes (app.Exports)

`app.Exports` sends an entity's changes to another system — a warehouse, a lake, a SaaS table — as they commit. Each…

The local loop (running your app on your own machine)

Everything the `osy` CLI does to the project in front of you — run it, look at what it did, check it before you ship…