Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 42 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,53 +24,56 @@ Demo applications are located in the [`demos/`](./demos/) directory. Also see ou
- [demos/CommandLine](./demos/CommandLine/README.md): A CLI-based app demonstrating real-time data sync
- [demos/WPF](./demos/WPF/README.md): A Windows desktop to-do list app real-time data sync
- [demos/MAUITodo](./demos/MAUITodo/README.md): A cross-platform mobile and desktop to-do list app built with .NET MAUI, running on iOS, Android and Windows
- [demos/UnoTodo](./demos/UnoTodo/ReadMe.md): A cross-platform mobile and desktop to-do list app built with Uno Platform

# Supported Frameworks

## Target Frameworks

This PowerSync SDK supports the following target frameworks:

- **.NET 9** - [Latest version](https://dotnet.microsoft.com/en-us/download/dotnet/9.0)
- **.NET 8** - [Current LTS Version, used for development of this project](https://dotnet.microsoft.com/en-us/download/dotnet/8.0)
- **.NET 8** - [Current LTS Version, used for development of this project](https://dotnet.microsoft.com/en-us/download/dotnet/8.0)
- **.NET 6** - supported for compatibility with older projects
- **.NET Standard 2.0** - for compatibility with older libraries and frameworks, tested/verified older versions will be listed below.
- **.NET Standard 2.0** - for compatibility with older libraries and frameworks, tested/verified older versions will be listed below.

- .NET Framework 4.8:
To get a .NET Framework 4.8 working with this SDK add the following to your `.csproj` file:

```xml
<PropertyGroup>
...
<!-- Ensures the correct SQLite DLL is available -->
<RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>

<ItemGroup>
...
<!-- Ensures the HTTP client resolves in the SDK -->
<PackageReference Include="System.Net.Http" Version="4.3.4" />
</ItemGroup>
```

and create a `IsExternalInit.cs` file in your project with the following contents:
```cs
using System.ComponentModel;

namespace System.Runtime.CompilerServices
{
[EditorBrowsable(EditorBrowsableState.Never)]
internal class IsExternalInit { }
}
```
-------

To get a .NET Framework 4.8 working with this SDK add the following to your `.csproj` file:

```xml
<PropertyGroup>
...
<!-- Ensures the correct SQLite DLL is available -->
<RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>

<ItemGroup>
...
<!-- Ensures the HTTP client resolves in the SDK -->
<PackageReference Include="System.Net.Http" Version="4.3.4" />
</ItemGroup>
```

and create a `IsExternalInit.cs` file in your project with the following contents:

```cs
using System.ComponentModel;

namespace System.Runtime.CompilerServices
{
[EditorBrowsable(EditorBrowsableState.Never)]
internal class IsExternalInit { }
}
```

---

When running commands such as `dotnet run` or `dotnet test`, you may need to specify the target framework explicitly using the `--framework` flag.

## Application Frameworks

- MAUI - Cross-platform native apps for mobile and desktop
- Platforms: iOS, Android, Windows
- WPF - Windows desktop applications
Expand All @@ -94,7 +97,7 @@ This project uses [EditorConfig](https://editorconfig.org/) for formatting, whic
Download PowerSync extension

```bash
dotnet run --project Tools/Setup
dotnet run --project Tools/Setup
```

Install dependencies
Expand All @@ -114,11 +117,12 @@ dotnet test -v n --framework net8.0
Run a specific test

```bash
dotnet test -v n --framework net8.0 --filter "test-file-pattern"
dotnet test -v n --framework net8.0 --filter "test-file-pattern"
```

### Integration Tests
Integration tests in `PowerSync.Common.IntegrationTests` are intended to run against the [self-host nodejs demo](https://github.com/powersync-ja/self-host-demo/tree/main/demos/nodejs).

Integration tests in `PowerSync.Common.IntegrationTests` are intended to run against the [self-host nodejs demo](https://github.com/powersync-ja/self-host-demo/tree/main/demos/nodejs).
The integration tests are disabled by default, define the following environment variable when running the tests.

```bash
Expand All @@ -132,6 +136,7 @@ RUN_INTEGRATION_TESTS=true dotnet test -v n --framework net8.0 --filter "Categor
```

### Performance Tests

Performance tests in `PowerSync.Common.PerformanceTests` are disabled by default, define the following environment variable when running the tests.

```bash
Expand All @@ -145,6 +150,7 @@ RUN_PERFORMANCE_TESTS=true dotnet test -v n --framework net8.0 --filter "Categor
```

## Using the PowerSync.Common package in your project

```bash
dotnet add package PowerSync.Common
```
2 changes: 1 addition & 1 deletion demos/MAUITodo/Platforms/MacCatalyst/AppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ namespace MAUITodo;
[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
15 changes: 8 additions & 7 deletions demos/MAUITodo/Platforms/MacCatalyst/Program.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
using ObjCRuntime;

using UIKit;

namespace MAUITodo;

public class Program
{
// This is the main entry point of the application.
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, typeof(AppDelegate));
}
// This is the main entry point of the application.
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, typeof(AppDelegate));
}
}
29 changes: 29 additions & 0 deletions demos/UnoTodo/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Application x:Class="UnoTodo.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:utum="using:Uno.Toolkit.UI.Material">

<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!-- Load WinUI resources -->
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<utum:MaterialToolkitTheme
ColorOverrideSource="ms-appx:///Styles/ColorPaletteOverride.xaml">
<!-- NOTE: You can override the default Roboto font by providing your font assets here. -->
<!-- <utum:MaterialToolkitTheme.FontOverrideDictionary>
<ResourceDictionary>
<FontFamily x:Key="MaterialLightFontFamily">ms-appx:///Uno.Fonts.Roboto/Fonts/Roboto-Light.ttf#Roboto</FontFamily>
<FontFamily x:Key="MaterialMediumFontFamily">ms-appx:///Uno.Fonts.Roboto/Fonts/Roboto-Medium.ttf#Roboto</FontFamily>
<FontFamily x:Key="MaterialRegularFontFamily">ms-appx:///Uno.Fonts.Roboto/Fonts/Roboto-Regular.ttf#Roboto</FontFamily>
</ResourceDictionary>
</utum:MaterialToolkitTheme.FontOverrideDictionary> -->
</utum:MaterialToolkitTheme>
</ResourceDictionary.MergedDictionaries>

<!-- Add resources here -->

</ResourceDictionary>
</Application.Resources>

</Application>
82 changes: 82 additions & 0 deletions demos/UnoTodo/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using System.Diagnostics.CodeAnalysis;

using Uno.Resizetizer;

namespace UnoTodo;

public partial class App : Application
{
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
InitializeComponent();
}

protected Window? MainWindow { get; private set; }
public IHost? Host { get; private set; }

// [SuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "Uno.Extensions APIs are used in a way that is safe for trimming in this template context.")]
protected async override void OnLaunched(LaunchActivatedEventArgs args)
{
var builder = this.CreateBuilder(args)
// Add navigation support for toolkit controls such as TabBar and NavigationView
.UseToolkitNavigation()
.Configure(host => host
#if DEBUG
// Switch to Development environment when running in DEBUG
.UseEnvironment(Environments.Development)
#endif
.UseLogging(configure: (context, logBuilder) =>
// Configure log levels for different categories of logging
logBuilder
.SetMinimumLevel(
context.HostingEnvironment.IsDevelopment() ?
LogLevel.Information :
LogLevel.Warning)

// Default filters for core Uno Platform namespaces
.CoreLogLevel(LogLevel.Warning), enableUnoLogging: true)
.UseConfiguration(configure: builder => builder.EmbeddedSource<App>())
.ConfigureServices((context, services) => services.AddSingleton<PowerSyncData>())
.UseNavigation(ReactiveViewModelMappings.ViewModelMappings, RegisterRoutes)
);
MainWindow = builder.Window;

#if DEBUG
MainWindow.UseStudio();
#endif
MainWindow.SetWindowIcon();

Host = await builder.NavigateAsync<Shell>();
}

private static void RegisterRoutes(IViewRegistry views, IRouteRegistry routes)
{
views.Register(
new ViewMap(ViewModel: typeof(ShellModel)),
new ViewMap<MainPage, MainModel>(),
new ViewMap<ListsPage, ListsModel>(),
new ViewMap<SqlConsolePage, SqlConsoleModel>(),
new DataViewMap<TodoPage, TodoModel, TodoList>()
);

routes.Register(
new RouteMap("", View: views.FindByViewModel<ShellModel>(),
Nested:
[
new ("Main", View: views.FindByViewModel<MainModel>(), IsDefault:true,
Nested:
[
new ("Lists", View: views.FindByViewModel<ListsModel>(), IsDefault:true),
new ("SqlConsole", View: views.FindByViewModel<SqlConsoleModel>()),
]
),
new ("Todo", View: views.FindByViewModel<TodoModel>()),
]
)
);
}
}
42 changes: 42 additions & 0 deletions demos/UnoTodo/Assets/Icons/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading