AutoRepo 0.1.0
dotnet add package AutoRepo --version 0.1.0
NuGet\Install-Package AutoRepo -Version 0.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AutoRepo" Version="0.1.0"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AutoRepo" Version="0.1.0" />
<PackageReference Include="AutoRepo"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AutoRepo --version 0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: AutoRepo, 0.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AutoRepo@0.1.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AutoRepo&version=0.1.0
#tool nuget:?package=AutoRepo&version=0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
AutoRepo
A C# source generator that automatically creates API client code from repository interfaces.
What it generates
Given a repository interface annotated with [GenerateApi], AutoRepo generates:
IApi{Name}- Refit-compatible interface with HTTP method attributesApi{Name}Client- HttpClient-based implementationFallback{Name}- Local-first wrapper with API fallbackCombined{Name}- Merged wrapper that queries both local and remote sources in parallel
Usage
Add AutoRepo as an analyzer reference:
<ProjectReference Include="path/to/AutoRepo.csproj"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false" />
Annotate your repository interfaces:
using AutoRepo;
[GenerateApi(RoutePrefix = "/api/products")]
public interface IProductRepository
{
Task<IReadOnlyList<Product>> GetAllAsync(CancellationToken ct = default);
Task<Product?> GetAsync(int id, CancellationToken ct = default);
Task UpsertAsync(Product product, CancellationToken ct = default);
Task DeleteAsync(int id, CancellationToken ct = default);
}
Custom JSON serialization
If your entities need custom JSON converters (e.g., for strongly-typed IDs), specify a JsonOptionsType:
[GenerateApi(RoutePrefix = "/api/products", JsonOptionsType = "MyApp.MyJsonOptions")]
public interface IProductRepository { ... }
The type must have a static Default property returning JsonSerializerOptions.
Conventions
- HTTP method inference:
Get*/Search*/Find*→ GET,Delete*/Remove*→ DELETE,Create*/Add*→ POST,Update*→ PUT,Upsert*→ POST (with body) or PUT - Route parameters: Parameters named
idor ending withIdin Get/Delete methods - Body parameters: Complex types in POST/PUT methods
- Query parameters: Primitive types that aren't route parameters
- Source tracking: If entities have a
Sourceproperty of typeDataSource, generated wrappers set it toLocal,Remote, orBoth - Fallback strategy: Single items → local-first; Collections → API-first; Mutations → local-only
- Combined strategy: All reads query both sources in parallel and merge; Mutations → local-only
- Local-only methods: Methods starting with
GetStoredorGetLibrarystay local-only in Combined wrapper
Requirements
- .NET SDK with Roslyn source generators support
- Refit (for the generated Refit interface)
Microsoft.Extensions.Logging(for Fallback/Combined wrappers)
There are no supported framework assets in this package.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- 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 |
|---|---|---|
| 0.1.0 | 41 | 3/2/2026 |