SQuiL.SourceGenerator 1.0.0-beta.182

This is a prerelease version of SQuiL.SourceGenerator.
dotnet add package SQuiL.SourceGenerator --version 1.0.0-beta.182
                    
NuGet\Install-Package SQuiL.SourceGenerator -Version 1.0.0-beta.182
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SQuiL.SourceGenerator" Version="1.0.0-beta.182" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SQuiL.SourceGenerator" Version="1.0.0-beta.182" />
                    
Directory.Packages.props
<PackageReference Include="SQuiL.SourceGenerator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SQuiL.SourceGenerator --version 1.0.0-beta.182
                    
#r "nuget: SQuiL.SourceGenerator, 1.0.0-beta.182"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SQuiL.SourceGenerator@1.0.0-beta.182
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SQuiL.SourceGenerator&version=1.0.0-beta.182&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=SQuiL.SourceGenerator&version=1.0.0-beta.182&prerelease
                    
Install as a Cake Tool

SQuiL

SQuiL is a C# source generator that turns SQL files into strongly-typed C# data-access code. You write a .squil file using a small set of variable-naming conventions; SQuiL generates the request/response models, a data context that executes the query, and the dependency-injection wiring — all at compile time, with no runtime reflection.

File extension: .squil is the canonical extension and is what the editor extensions key off. Plain .sql works too — the generator accepts both — so existing .sql query files don't need renaming.

your-query.squil  ──▶  SQuiL source generator  ──▶  strongly-typed C#
                                                     ├─ <Query>Request   (from @Param* vars)
                                                     ├─ <Query>Response  (from @Return* vars)
                                                     ├─ <Context>DataContext.<Query>(…)
                                                     └─ AddSQuiL…() DI extension

Why

  • No string-typed SQL scattered through C#. The SQL lives in its own file; the C# surface is generated and type-checked.
  • Parameters and results are inferred from the SQL itself via naming conventions — no hand-written DTOs to keep in sync.
  • Incremental Roslyn generator. Generation happens in the compiler; there is nothing to run or scaffold.

Requirements

  • .NET SDK 10.0 or later to build a consuming project.
  • The generator and runtime library target netstandard2.0, so generated code runs anywhere Microsoft.Data.SqlClient is supported.
  • SQL Server is the current target database (multi-database support is on the roadmap).

Install

dotnet add package SQuiL.SourceGenerator

The SQuiL.SourceGenerator package bundles both the generator and the SQuiL.Library runtime types, so it is the only reference you need.

Mark your query files as AdditionalFiles so the generator can see them:

<ItemGroup>
    <AdditionalFiles Include="**\Queries\*.squil" />
    <AdditionalFiles Include="**\Queries\*.sql" />
</ItemGroup>

Quick example

Queries/GetUser.squil:

Declare @Param_UserID int;
Declare @Return_Name varchar(100);
Use MyDatabase;
Set @Return_Name = (Select Name From Users Where UserID = @Param_UserID);
Select @Return_Name;

Declare a data context and point it at the query:

[SQuiLQuery(QueryFiles.GetUser)]
public partial class MyDataContext { }

SQuiL generates GetUserRequest, GetUserResponse, the MyDataContext.GetUser(…) method, and an AddSQuiL…() extension for DI. It also auto-supplies : SQuiLBaseDataContext and an IConfiguration constructor (into a generated Constructor.g.cs file) when the class declares no constructor of its own — declaring any constructor opts out (it must chain : base(configuration)). The connection string is read from IConfiguration (default name SQuiLDatabase, overridable per query via [SQuiLQuery(…, setting: "Name")]).

Variable-naming conventions

SQuiL reads the DECLARE statements to decide each variable's role:

Declaration Role
@Param_<name> input scalar parameter
@Params_<name> input table-valued parameter (list)
@Param_<name> table(…) input object parameter
@Return_<name> output scalar
@Returns_<name> output table (list)
@Return_<name> table(…) output object
@Debug, @SuppressDebug, @EnvironmentName, @AsOfDate special input variables (all opt-in — emitted only when declared)

Table-valued and single-object variables both generate <Name> records (no Table/Object suffix). Auto-generated row records are emitted into a .Models sub-namespace of the consuming context by default (override with [SQuiLQuery(..., Namespace: "Dto")] or Namespace: "" for top-level). Note the casing rule: an identifier ending in ID is always written ID (e.g. @Param_UserIDUserID), never Id.

Editor support

Syntax highlighting, IntelliSense, hover info, linting, and a generated-C# preview for .squil files are available for:

  • Visual Studio CodeSQuiL.VSCodeExtension
  • SQL Server Management Studio 22.6SQuiL.SsmsExtension
  • Visual Studio 2026SQuiL.VisualStudioExtension

Claude Code plugin

This repo doubles as a Claude Code plugin marketplace. The squil plugin teaches Claude how to author .squil files, wire up a consuming .csproj, and wrap the generated data contexts — and ships the canonical SQuiL TextMate grammar. Install it with:

/plugin marketplace add daemogar/SQuiL
/plugin install squil@squil

Documentation

See CONTRIBUTING.md for building, testing, project layout, and a tour of the architecture.

License

SQuiL is licensed under the GNU Affero General Public License v3.0 — see LICENSE.txt.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-beta.182 48 8/3/2026
Loading failed