PowerSync.Common.SourceGenerators
0.1.0-alpha.2
See the version list below for details.
dotnet add package PowerSync.Common.SourceGenerators --version 0.1.0-alpha.2
NuGet\Install-Package PowerSync.Common.SourceGenerators -Version 0.1.0-alpha.2
<PackageReference Include="PowerSync.Common.SourceGenerators" Version="0.1.0-alpha.2"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="PowerSync.Common.SourceGenerators" Version="0.1.0-alpha.2" />
<PackageReference Include="PowerSync.Common.SourceGenerators"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add PowerSync.Common.SourceGenerators --version 0.1.0-alpha.2
#r "nuget: PowerSync.Common.SourceGenerators, 0.1.0-alpha.2"
#:package PowerSync.Common.SourceGenerators@0.1.0-alpha.2
#addin nuget:?package=PowerSync.Common.SourceGenerators&version=0.1.0-alpha.2&prerelease
#tool nuget:?package=PowerSync.Common.SourceGenerators&version=0.1.0-alpha.2&prerelease
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 SQLNULLtonull. Non-nullable members throw if the column isNULL. 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 implementIFromRow<T>yourself.
The package must be used alongside PowerSync.Common, which provides IFromRow<T>, [Column] and [Ignored].
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 |