Replies: 2 comments
|
I agree that we should restructure this the packages. To some extent having everything in Common would be nice from an end user perspective, however I am worried that we might have platform specific code in the future (looks at Blazor menacingly) - but it's hard to say without investigating. I am leaning towards something close to solution 2 if it is feasible. |
0 replies
|
IMO, we should default to a single package unless there's an unavoidable platform-inherited reason not to. Looking at our other SDKs:
I don't have enough experience with DotNet to make an informed comment on these proposals. If it is possible to offer a single package that works everywhere (#87 seems to suggest it is?), I think we should do that. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Future PowerSync .NET SDK Package Architecture
Overview
The current architecture of the PowerSync .NET SDK revolves around a core
PowerSync.Commonpackage which implements the main SDK behaviours and additionally bundles desktop libraries to be able to run the PowerSync SQLite extension. The library also includes interfaces which can be implemented by other packages to allow customizing the PowerSync SDK's behavior and also to allow for running the PowerSync SQLite extension on non-desktop platforms. Currently, the only official package which does this isPowerSync.Maui, which extendsPowerSync.Commonto include mobile builds of the PowerSync SQLite extension and behavior for loading them.This document is on how the future architecture of the PowerSync .NET SDKs, including what will happen to the existing
PowerSync.CommonandPowerSync.Mauipackages. This document focuses primarily on changes happening in version 1.0.0 of the PowerSync .NET SDKs.Problem and Current Architecture
As stated above, the current architecture focuses on
PowerSync.Common. ThePowerSync.Commonpackage includes SDK behaviour and loading and bundling for desktop builds of the PowerSync SQLite extension. ThePowerSync.Mauipackage provides loading and bundling for mobile builds for the PowerSync SQLite extension.This works, and for targets with unique/esoteric runtimes (e.g. mobile, Unity, web via Blazor), it's nice to have a
Common-style package which we can depend on for behavior. However, the problem with how we currently do things is thatCommonis not just a behavior package; it bundles its own native libraries for desktop and has some platform-dependent code which needs to be overridden or worked around on non-desktop runtimes.While unneeded runtimes can often be stripped from release builds using clever conditional MSBuild /
.csprojproperties, it is still something which needs to be worked around when designing support for a new platform and often leads to users needing to install two packages instead of one (e.g. needing to install bothPowerSync.MauiandPowerSync.Commonin MAUI apps).Proposed Solutions
Solution 1: Consolidate more into PowerSync.Common
This approach goes all in on one SDK which can do almost everything.
Include mobile libraries in PowerSync.Common and only override for very specific platforms. This approach is what I implemented in this PR and would make things simpler for the most common PowerSync use cases (cross-platform mobile apps, desktop apps).
Pros: easy to develop for maintainers and consumers, simpler flow for most common use case (cross-platform mobile app).
Cons: doesn't help much with supporting other platforms; could lead to package/bundle bloat if not managed carefully.
Solution 2: Split more into separate packages, provide wrappers
This approach delegates as little native behavior as possible to the core SDK.
Introduce a new package called
PowerSync.Corewhich includes purely cross-platform behaviour and no native code. Implement a number of provider packages which provide behavior for loading native libraries on different platforms. Finally, provide wrapper packages that bundlePowerSync.Corewith a specific set of providers for common use cases.Pros: Flexible structure, separation of native and cross-platform concerns, one package for most use cases, extensible.
Cons: Much more complex package structure; not sure how feasible this is in DotNet. Needs further testing.
Conclusion
I prefer Solution 2 in concept, but I'm not sure if it's actually feasible to make the SDK so flexible while keeping the happy-path DX that Solution 1 offers. I'd like feedback on the solutions proposed above and am open to other solutions which could help solve the problems outlined above. Thank you for reading this spiel :)
All reactions