Remove newtonsoft, make the library native aot compatible

Open
#195 2 comments 6 reactions 1 assignee View on GitHub

@Tr00d is already working on this.

Since Jul 1, 2026.

Assessment

This issue has not been assessed yet.

Description

newtonsoft

Chore

Describe the chore

Bring supabase-csharp (and the sub-packages we use) up to .NET Native AOT so a dotnet publish -c Release -p:PublishAot=true build succeeds, and there are no runtime errors.

Acceptance criteria

  • AOT publish finishes without linker errors or reflection warnings.
  • App boots and runs basic Supabase flows (auth, simple CRUD) in the published binary.
  • CI job produces an AOT artifact.

Steps

  1. Add a repo-level Directory.Build.props with:

    <Project>
      <PropertyGroup>
        <PublishAot>true</PublishAot>
        <PublishTrimmed>true</PublishTrimmed>
        <InvariantGlobalization>true</InvariantGlobalization>
        <EnableDynamicLoading>false</EnableDynamicLoading>
      </PropertyGroup>
    </Project>
    
  2. Swap Newtonsoft.Json for System.Text.Json + source-generated context.

  3. Mark BaseModel with DynamicallyAccessedMembers and tag helper methods that use reflection with RequiresUnreferencedCode.

  4. Replace Activator.CreateInstance calls with new T().

  5. Run:

    dotnet restore
    dotnet build -c Release
    dotnet publish -c Release -p\:PublishAot=true -p\:SelfContained=true -o ./aot
    

    Fix any remaining trim warnings.

  6. Update CI pipeline to run the publish step and cache the output.

Additional context

Reference the detailed checklist in docs/aot-supabase-notes.md.

Dominant language
C#
Stars
701
Forks
106
Avg merge
16h 35m
Merged PRs (30d)
45

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from supabase/supabase-csharp

All issues in supabase/supabase-csharp

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.