DATE:
AUTHOR:
PowerSync Product Team
.NET SDK

.NET Client SDK Is Generally Available

DATE:
AUTHOR: PowerSync Product Team

The PowerSync .NET client SDK is now generally available, starting with PowerSync.Common version 1.0.1. That means you can build on it confidently in production, with the same support and SLA guarantees as our other stable SDKs. It also means that we keep the API backward compatible as far as possible and communicate any breaking change clearly.

Since the beta, we've reworked the query API for faster queries and merged the two packages (Common and Maui) into one for simpler setup. We also added .NET 10 support, raw tables, and more.

Several of these changes are breaking. The new query API replaces Dapper, PowerSync.Common replaces PowerSync.Maui, and the SDK no longer supports .NET Framework, .NET Standard 2.0, or .NET 6. If you're upgrading from the beta, see the v1 upgrade guide.

What's new in v1

One package for every platform

MAUI apps now need only one package. PowerSync.Common includes the native libraries for Android, iOS, and Mac Catalyst, so you no longer install PowerSync.Maui alongside it. (PR #94)

As a result, PowerSync.Maui is deprecated, and we no longer publish new versions of it. You can switch in two steps: remove the package and rename two classes. See Replace the PowerSync.Maui Package in the v1 upgrade guide for details.

.NET 10 support

Your app can now target .NET 10. In line with our supported platforms policy of supporting the LTS and current .NET versions, the SDK supports .NET 8, 9, and 10. Desktop and console apps can target .NET 8 or later, and MAUI apps can target .NET 9 or 10.

We removed support for .NET Standard 2.0, .NET Framework, and .NET 6. As far as we know, few apps use these targets, and they caused issues in the SDK's code. If your app still needs one of them, let us know. (PR #79)

Faster queries without Dapper dependency

When a query returns a result type, such as GetAll<ListResult>(), the SDK turns each row into a ListResult object. In the beta, we switched this mapping to Dapper, because it was about 2.8x faster than the JSON parsing the SDK used before. Since then, we found that Dapper's speed depends on generating mapping code at runtime, which not every platform supports.

In v1, you define the mapping for each result type or generate it when you build, which has these benefits:

  • In our benchmark on macOS, GetAll read 10,000 to 1,000,000 rows about 20% faster than with Dapper, and used about 18% less memory. (benchmark)

  • This future-proofs the SDK for iOS and iPadOS. These platforms don't support generating code at runtime, so Dapper fell back to slower reflection there. The new mapping doesn't need runtime code generation.

  • The SDK now defines its own query API instead of following Dapper's conventions. You decide how each column maps to a property, and result types can be classes, structs, or records.

This is a breaking change. For each result type, implement IFromRow<T> or pass a mapper function to the query. The PowerSync.Common.SourceGenerators package, currently in alpha, can also generate the IFromRow<T> implementation when you build (PR #108). To update your queries, see Update Queries in the v1 upgrade guide, which has before-and-after examples.

Connect for downloads or uploads only

Your app can now connect for downloads only or uploads only, as in our other client SDKs. For example, an app that shows a product catalog offline connects with only an authenticator, so you don't write upload code for it.

Implement IAuthenticator to return a JWT for downloads, and IMutationUploader to upload your app's mutations, then pass one or both to Connect(). Your existing IPowerSyncBackendConnector keeps working, because it implements both interfaces. (PR #106, docs)

Raw tables

You can now sync data into native SQLite tables that you define, with full control over constraints and indexes. By default, PowerSync syncs data into JSON-based views that it creates. To use your own tables instead, define them with RawTable in your schema. (PR #104, docs)

Note that we released managed tables as an alpha in our other client SDKs. They store synced data in native SQLite tables too, but PowerSync creates and migrates the tables, so you don't write CREATE TABLE statements or migrations. We plan to add managed tables to the .NET SDK in a later release.

Other new features

We've also added these features since the beta release:

  • Sync files such as photos with AttachmentQueue. (PR #68, docs)

  • Call RequestCheckpoint() from the client to catch up with the server on demand. (PR #97, announcement)

  • Call DisconnectAndClear(soft: true) when a user signs out. It deletes your app's synced data but keeps PowerSync's internal copy, so when the user signs back in, the next sync doesn't download everything again. (PR #101, docs)

  • Load your own SQLite extensions with MDSQLiteOptions.Extensions. (PR #72, docs)

  • Run your app on Mac Catalyst and Windows ARM. (PR #64, PR #55)

  • Look up the SDK's public classes and methods in its API reference. (PR #88)

Upgrading from the beta

The v1 upgrade guide walks through each breaking change with examples. Here's a summary:

  • Target .NET 8 or later for desktop and console apps, and .NET 9 or later for MAUI apps.

  • If you use PowerSync.Maui, remove it. Replace MAUISQLiteAdapter with MDSQLiteAdapter, and MAUISQLiteDBOpenFactory with MDSQLiteDBOpenFactory.

  • Update your queries to use IFromRow<T>, a mapper function, or the source generator. This also applies to classes with [Column] attributes.

  • GetAll<T> and Watch<T> return List<T> instead of an array. Untyped queries return IQueryRow values instead of dynamic, and untyped GetAll and Watch return them in a QueryResult.

  • If you compare table names from OnChange with view names, use the underlying table names, such as ps_data__todo_lists.

  • If your code uses operation IDs, write checkpoints, or checkpoint request IDs, change them from string to long.

  • If your connector implements only ICustomCheckpointRequestConnector, also implement IPowerSyncBackendConnector.

  • If you listen to OnTablesUpdated on the database adapter, read the table names from TablesUpdated, which is now a HashSet<string>. INotification, UpdateNotification, and BatchedUpdateNotification are removed.

Get started

New to PowerSync or the .NET SDK? Start with our setup guide. To get a feel for the SDK, or to see a reference implementation, try the demo apps.

Thank you to everyone who tested the beta and reported issues, and thanks especially to Austin Hale for contributing the file attachments feature. If something doesn't work the way you expect, please chat with us on Discord or open an issue on GitHub.

Powered by LaunchNotes