Skip to content

DaredevilOSS/sqlc-gen-csharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CI

sqlc-gen-csharp

Usage

Options

Option Possible values Optional Info
driver values: MySqlConnector,Npgsql, Sqlite No Choosing the driver to use - refer to the examples to see the supported SQL engines and their drivers
targetFramework default: net8.0
values: netstandard2.0, netstandard2.1, net8.0
Yes Determines the target framework for your generated code, meaning the generated code will be compiled to the specified runtime.
For more information and help deciding on the right value, refer to the Microsoft .NET Standard documentation.
generateCsproj default: true
values: false,true
Yes Assists you with the integration of SQLC and csharp by generating a .csproj file. This converts the generated output to a .dll, a project that you can easily incorporate into your build process.

Configuration

version: "2"
plugins:
- name: csharp
  wasm:
    url: https://github.com/DaredevilOSS/sqlc-gen-csharp/releases/download/v0.10.0/sqlc-gen-csharp.wasm
    sha256: ${RELEASE_SHA}
sql:
  # PostgreSQL Example
  - schema: "examples/authors/postgresql/schema.sql"
    queries: "examples/authors/postgresql/query.sql"
    engine: "postgresql"
    codegen:
      - plugin: csharp
        out: NpgsqlExample
        options:
          driver: Npgsql
          targetFramework: net8.0
          generateCsproj: true
  # MySQL Example
  - schema: "examples/authors/mysql/schema.sql"
    queries: "examples/authors/mysql/query.sql"
    engine: "mysql"
    codegen:
      - plugin: csharp
        out: MySqlConnectorExample
        options:
          driver: MySqlConnector
          targetFramework: net8.0
          generateCsproj: true

Contributing

Local plugin development

Prerequisites

make sure that the following applications are installed and exposed in your path

Follow the instructions in each of these:

Protobuf

SQLC protobuf are defined in sqlc-dev/sqlc repository. Generating C# code from protocol buffer files:

make protobuf-generate

Generating code

SQLC utilizes our process / WASM plugin to generate code

make sqlc-generate-process
make sqlc-generate-wasm

Testing generated code

Testing the SQLC generated code via a predefined flow:

make test-process-plugin
make test-wasm-plugin

Release flow

The release flow in this repo follows the semver conventions, building tag as v[major].[minor].[patch].

  • In order to create a release you need to add [release] somewhere in your commit message when merging to master

Version bumping (built on tags)

By default, the release script will bump the patch version., by adding [release] to your commit message the release script will create a new tag with v[major].[minor].[patch]+1.

  • Bump minor version by adding [minor] to your commit message resulting in a new tag with v[major].[minor]+1.0
  • Bump major version by adding [major] to your commit message resulting in a new tag with v[major]+1.0.0

Release structure

The new created tag will create a draft release with it, in the release there will be the wasm plugin embedded in the release.

All we have left to do now is to add the changelog and publish the draft