PowerSync.Common.SourceGenerators 1.0.0-alpha.1

This is a prerelease version of PowerSync.Common.SourceGenerators.
dotnet add package PowerSync.Common.SourceGenerators --version 1.0.0-alpha.1
                    
NuGet\Install-Package PowerSync.Common.SourceGenerators -Version 1.0.0-alpha.1
                    
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="PowerSync.Common.SourceGenerators" Version="1.0.0-alpha.1">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PowerSync.Common.SourceGenerators" Version="1.0.0-alpha.1" />
                    
Directory.Packages.props
<PackageReference Include="PowerSync.Common.SourceGenerators">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
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 PowerSync.Common.SourceGenerators --version 1.0.0-alpha.1
                    
#r "nuget: PowerSync.Common.SourceGenerators, 1.0.0-alpha.1"
                    
#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 PowerSync.Common.SourceGenerators@1.0.0-alpha.1
                    
#: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=PowerSync.Common.SourceGenerators&version=1.0.0-alpha.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=PowerSync.Common.SourceGenerators&version=1.0.0-alpha.1&prerelease
                    
Install as a Cake Tool

PowerSync.Common.SourceGenerators

Source generators for PowerSync.Common.

⚠️ Project Status

This package is in alpha and is not yet considered ready for production use. See our feature status definitions here.

[GenerateSqlMapper]

Mark a partial class, struct or record with [GenerateSqlMapper] to generate its IFromRow<T> implementation, so it can be used with GetAll<T>, Get<T>, GetOptional<T> and Watch<T> without writing a mapper by hand.

using PowerSync.Common.DB;
using PowerSync.Common.DB.Schema.Attributes;

[GenerateSqlMapper]
public partial class TodoItem
{
    [Column("id")]
    public string Id { get; set; } = "";

    [Column("description")]
    public string Description { get; set; } = "";

    [Column("completed_at")]
    public DateTime? CompletedAt { get; set; }

    public bool Completed { get; set; }
}

[GenerateSqlMapper]
public partial record ListSummary(string Id, string Name, [property: Column("todo_count")] long TodoCount);

var todos = await db.GetAll<TodoItem>("SELECT * FROM todos");
var lists = await db.GetAll<ListSummary>(
    "SELECT lists.id, lists.name, count(todos.id) AS todo_count FROM lists LEFT JOIN todos ON todos.list_id = lists.id GROUP BY lists.id");

Mapping rules

  • Each settable property is read from the column named by its [Column] attribute, or otherwise the column with the property's name. Column names are matched case-insensitively, like SQLite identifiers.
  • Constructor parameters are matched to properties of the same name (ignoring case) and use that property's column. A primary constructor, such as that of a positional record, is used if there is one. Otherwise the parameterless constructor is used, or failing that the constructor with the most parameters.
  • Properties marked with [Ignored], private properties, and properties without an accessible setter are skipped.
  • Nullable members (string?, int?, ...) map SQL NULL to null. Non-nullable members throw if the column is NULL. A column missing from the result set always throws.
  • Supported types are string, bool, all integer types, float, double, decimal, DateTime, DateTimeOffset, Guid, enums (stored as integers), byte[], and their nullable forms. Any other type is a compile error: mark the property with [Ignored] or implement IFromRow<T> yourself.

The package must be used alongside PowerSync.Common, which provides IFromRow<T>, [Column] and [Ignored].

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

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-alpha.1 58 11/23/2026
0.1.0-alpha.2 60 11/23/2026
0.1.0-alpha.1 66 11/19/2026