機能ファイルから API 契約を生成する .NET API フレームワーク。Generate API contracts from feature files.

1ファイル1つの機能API契約は自動生成 One file. One feature. Generated API contracts.

Minimal API の書き味はそのまま。1つの機能定義から登録、診断、型付きクライアントを生成します。 Keep Minimal APIs. Generate registration, checks, and typed clients from one feature definition.

コードを見るView code
dotnet run --project samples/SliceFx.Sample

Native AOT を意識Native AOT-minded SLICE 診断SLICE diagnostics Core は FrameworkReference のみFramework-only Core

リリース状況: 0.1.0-preview.5 が NuGet で公開されました (2026-05-30)。Release status: 0.1.0-preview.5 is available on NuGet (2026-05-30).

pre-1.0 の実験的ソフトウェアです。API は安定版リリース前に変更される可能性があります。公開済みの本番採用は 0、公開済みの個人 dogfooding ログも 0 です。Pre-1.0 experimental software. APIs may change before a stable release. Public production adoption is 0, and published personal dogfooding logs are 0.

SliceFxが解決したいことWhat SliceFx solves

ルート、DTO、バリデーション、クライアント、移植性チェックを別々に管理せず、1つの機能ファイルからつなげます。Keep routes, DTOs, validation, clients, and portability checks connected to one feature file.

機能単位で構成Feature-shaped APIs

1つの静的クラスが1つのエンドポイント。リクエスト、レスポンス、ハンドラー、バリデーションを同じ場所で確認できます。One static class maps to one endpoint, keeping request, response, handler, and validation close together.

API契約がずれにくいAPI contracts stay aligned

ルートメタデータ、互換性レポート、型付きクライアント、OpenAPI projection を、同じ機能ファイルから生成します。Route metadata, compatibility reports, typed clients, and OpenAPI projections are generated from the same feature files.

ASP.NET Core から離れないStill ASP.NET Core

Minimal API のバインディング、DI、エンドポイントフィルター、DataAnnotations をそのまま利用できます。必要な場面では ASP.NET 固有の IResult も使えます。Keep Minimal API binding, DI, endpoint filters, and DataAnnotations; use ASP.NET-specific IResult when a slice needs it.

SliceFx は ASP.NET の機能を制限しません。認可・レート制限・キャッシュ・CORS・カスタム検証はそのまま使えます。ASP.NET 機能とエスケープハッチ → SliceFx doesn't restrict any ASP.NET feature — authorization, rate limiting, caching, CORS, and custom validation all stay available. ASP.NET features and escape hatches →

SliceFxを選ぶ理由Why SliceFx

Minimal API はそのまま、ずれやすい周辺だけを生成Standard Minimal APIs, generated around the pieces that drift

SliceFxはASP.NET Coreの上に乗ります。実行時は Minimal API に近く、ずれやすい登録・診断・クライアント生成だけを機能ファイルから補います。 SliceFx sits on ASP.NET Core. Runtime behavior stays close to Minimal APIs; the generator handles the registration, checks, and clients that tend to drift.

Minimal APIs
手書きの柔軟さが魅力です。一方で、ルート文字列、DTO、クライアント、移植性チェックは自分たちで同期し続ける必要があります。Great for handwritten flexibility, but route strings, DTOs, clients, and portability checks are yours to keep in sync.
FastEndpoints
エンドポイントを機能単位でまとめやすい構成です。SliceFxは独自パイプラインではなく、生成した Minimal API 登録を使う方針です。Provides an endpoint-per-feature shape. SliceFx chooses generated Minimal API registration instead of a custom endpoint pipeline.
SliceFx
機能のまとまり、SLICE001 などのビルド時診断、slicefx routesslicefx client csharpslicefx openapi を同じメタデータでつなぎます。Uses the same metadata for feature locality, build-time diagnostics such as SLICE001, slicefx routes, slicefx client csharp, and slicefx openapi.

どんなチームに向いている?Who is SliceFx for?

API 層は軽く保ちたい。でもルート、クライアント、将来の実行環境をばらばらに管理したくない。そんな個人やチームに向いています。For individual developers and teams that want a light API layer without letting routes, clients, and future runtime choices drift apart.

小さなAPIチームSmall API teams
1エンドポイントを1ファイルで管理できます。リクエスト、レスポンス、バリデーション、ハンドラーがまとまるので、担当範囲も見えやすくなります。One endpoint is one file. Request, response, validation, and handler stay together, so feature ownership stays visible.
Blazor/.NETクライアントBlazor/.NET clients
サーバー側の機能定義から型付き HttpClient を生成し、ルート文字列やDTOを手で合わせ続ける手間を減らします。Generate typed HttpClient wrappers from server features and avoid hand-maintained route strings and DTO wiring.
Serverless/AOT も視野に入れるチームServerless/AOT-minded teams
slicefx routes で移植性を早めに確認しながら、普段は ASP.NET Core を主な実行環境として使い続けられます。slicefx routes surfaces portability early while ASP.NET Core remains the primary runtime.

SliceFx の強みWhat you get

Core は NuGet 依存ゼロZero-dependency core

コアランタイムが依存するのは Microsoft.AspNetCore.App だけです。FluentValidation や MediatR を前提にせず、必要なアダプタだけを後から追加できます。The core runtime only depends on Microsoft.AspNetCore.App. FluentValidation and MediatR are not required; optional adapters can be added later.

生成された登録コードGenerated registrations

AddSlice()MapSlices() はソースジェネレータが出力します。登録経路を1つに絞り、無効な機能定義は SLICE### 診断としてビルド時に出します。AddSlice() and MapSlices() are emitted by the source generator. Invalid feature shapes become SLICE### diagnostics at build time.

Native AOT を意識した起動経路Native AOT-minded startup path

生成コードは標準の MapMethods 呼び出しに展開され、起動時のルートスキャンを避けます。SliceFx.Core は NuGet 依存を増やさず、trimming/AOT 向けの小さな土台を保ちます。Generated code expands to standard MapMethods calls and avoids startup route scanning. SliceFx.Core avoids extra NuGet dependencies to keep the base small for trimming and Native AOT.

必要なアダプタだけ追加Optional adapters

AWS Lambda、wasi:http、TestHost へのアダプタはサテライトパッケージです。普段は ASP.NET Core で使いながら、移植できる機能を slicefx routes で確認できます。Lambda, wasi:http, and TestHost support live in satellite packages. Use ASP.NET Core day to day while slicefx routes shows which features remain portable.

ルートマニフェストRoute-manifest tooling

ルートマニフェストをもとに、slicefx routesslicefx client csharpslicefx client typescriptslicefx openapi が同じ定義を使います。The route manifest powers slicefx routes, slicefx client csharp, slicefx client typescript, and slicefx openapi from the same definitions.

ロックインが小さいLow lock-in

ジェネレータが出力するのは標準の MapMethods 呼び出しです。ジェネレータ参照を外して生成コードをその場で展開すれば、フレームワーク残留物の少ない離脱経路になります。The generator emits standard MapMethods calls. Remove the source generator reference and expand the generated output in place for a low-residue exit path.

ASP.NET の機能はそのままFull ASP.NET surface

生成コードは純粋な Minimal API 展開です。[Authorize]、認証・認可ポリシー、出力キャッシュ、レート制限、CORS、OpenAPI、標準バインディングはすべて使い続けられます。ASP.NET 機能とエスケープハッチ →Generated code is pure Minimal API expansion. [Authorize], auth policies, output caching, rate limiting, CORS, OpenAPI, and standard binding all stay available. ASP.NET features and escape hatches →

いま使える機能What works today

  • [Feature("METHOD /path")] でルートを宣言[Feature("METHOD /path")] declarative routing
  • ソースジェネレータで登録コードを生成Source-generated registrations
  • Minimal API バインディングに対応した静的ハンドラーStatic handlers with Minimal API binding
  • [Filter<T>] でエンドポイントフィルターを適用[Filter<T>] endpoint filters
  • DataAnnotations と ISliceValidator<T> で検証DataAnnotations and ISliceValidator<T>
  • 名前空間から OpenAPI タグを推論OpenAPI tags inferred from namespaces
  • ルートメタデータの出力と移植性レポートRoute metadata export and portability reporting
  • C# / TypeScript 型付きクライアント生成C# / TypeScript typed client generation

Hello, SliceFx

リクエスト、レスポンス、ハンドラー、バリデーション、フィルターまで、機能に関わるコードを1つのファイルにまとめられます。Request, response, handler, validation, and filters in one feature file.

Features/Users/CreateUser.cs C# 機能C# feature
using System.ComponentModel.DataAnnotations;

namespace SliceFx.Sample.Features.Users;

[Feature("POST /users", Summary = "Create a new user")]
public static class CreateUser
{
    public record Request(
        [Required, MinLength(2)] string Name,
        [Required, EmailAddress] string Email);

    public record Response(Guid Id, string Name, string Email, DateTime CreatedAt);

    public static async Task<Response> Handle(Request req, IUserStore store, CancellationToken ct)
    {
        var user = await store.AddAsync(req.Name, req.Email, ct);

        return new Response(user.Id, user.Name, user.Email, user.CreatedAt);
    }
}
Program.cs ホスト設定Host setup
var builder = WebApplication.CreateSlimBuilder(args);

builder.Services.AddSlice();
builder.Services.AddSingleton<IUserStore, InMemoryUserStore>();

var app = builder.Build();

app.MapSlices();

app.Run();
SliceFx CLI コマンドCommands
slicefx routes
slicefx routes --format json
slicefx client csharp --output SliceApiClient.g.cs
slicefx client typescript --output slice-api-client.ts
slicefx openapi --output openapi.json

ポータビリティのヒント: [FromServices]Portability tip: [FromServices]

ASP.NET パスのバインディングは生の Minimal API と同一で、登録済みサービス(具象・インターフェイス問わず)は [FromServices] なしで DI 解決されます。WASI / Lambda にもポータブルにしたい場合は、具象クラスの DI サービスに [FromServices]、キー付きサービスに [FromKeyedServices(key)] を付けてください。パラメータバインディングの詳細 →On the ASP.NET path binding is plain Minimal API — any registered service (concrete or interface) resolves from DI automatically. Annotate concrete services with [FromServices] (keyed: [FromKeyedServices(key)]) only to keep handlers portable across WASI and Lambda, where the generator uses a compile-time heuristic. Parameter binding details →

WASI / WebAssembly / edgeWASI / WebAssembly / edge

まずは ASP.NET Core。WASI は必須ではありませんStart with ASP.NET Core. WASI is optional.

SliceFx の既定は普通の ASP.NET Core アプリです。WASI / edge は、同じ機能ファイルを将来 ASP.NET 以外にも持っていけるかを確認するための実験的な選択肢です。 SliceFx defaults to a normal ASP.NET Core app. WASI / edge support is an experimental way to see whether the same feature files can move beyond ASP.NET later.

edge は利用者に近い場所でコードを動かす考え方、WASI はサーバー側コードを WebAssembly component として動かす仕組みです。SliceFx.Wasi は、生成されたルートテーブルを使って ASP.NET の外でも portable な機能を dispatch します。 Edge means running code closer to users. WASI packages server-side code as a WebAssembly component; SliceFx.Wasi uses a generated route table to dispatch portable features outside ASP.NET.

ほとんどのプロジェクトは 3 つの移植性クラスを同じコードベースで併用します。分類はツールに「どこで動かせるか」を伝えるもので、コードの良し悪しを表すものではありません。 Most projects use all three portability classes in the same codebase — the classification tells tooling where a feature can run, not whether it is well-written.

portableportable

プレーンな request / response を返す機能。型付きクライアント、WASI dispatch、function-per-feature Lambda の候補になります。Plain request / response features. Candidates for typed clients, WASI dispatch, and function-per-feature Lambda.

partialpartial

ハンドラー形状は移植しやすいが、一部のフィルターなど ASP.NET 固有の振る舞いがあります。The handler shape is portable, but some attached behavior such as endpoint filters is ASP.NET-specific today.

aspnet-onlyaspnet-only

IResult など ASP.NET の機能を意図的に使う機能。悪いコードではなく、ASP.NET に残る判断です。Features that intentionally use ASP.NET concepts such as IResult. Not bad code; simply an ASP.NET-specific choice.

コアは小さく、必要なアダプタだけを追加Small core, optional adapters

ホスティングやテストに必要な依存関係は、用途ごとのサテライトパッケージに分けています。すべてのパッケージは NuGet で公開されています。Hosting and testing dependencies stay in satellite packages. All packages are available on NuGet.

SliceFx.Core

属性、バリデーションフィルター、エンドポイントフィルターを含むコアランタイムです。Core runtime: attributes, validation filters, and endpoint filters.

SliceFx.SourceGenerator

機能ルートの登録コードを、AOT に適した形で生成します。AOT-friendly generated registrations for feature routes.

SliceFx.Lambda

ASP.NET Core 上で AWS Lambda ホスティングを使うための連携パッケージです。AWS Lambda hosting integration over ASP.NET Core.

SliceFx.Wasi

Cloudflare Workers や Fermyon Spin などの wasi:http ホスト向けに、ASP.NET に依存しない実験的なディスパッチを提供します。Experimental ASP.NET-independent dispatch for wasi:http hosts such as Cloudflare Workers and Fermyon Spin.

SliceFx.TestHost

SliceFx アプリをインプロセスで HTTP テストするためのヘルパーです。In-process HTTP testing helpers for SliceFx apps.

SliceFx.Cli

slicefx コマンドで、スキャフォールディング、ルート確認、互換性レポート、型付きクライアント生成、OpenAPI projection を実行できます。Scaffolding, route inspection, compatibility reports, typed client generation, and OpenAPI projections through the slicefx command.

技術詳細Engineering deep dives

設計の意思決定と運用基準Design decisions and operating criteria

SliceFx がどんな原則で動いていて、実運用に向けてどの基準をまだ満たす必要があるかをまとめたドキュメント群です。How SliceFx is built, what invariants it defends, and which production-readiness criteria it still needs to meet.

設計判断 FAQDesign decisions FAQ

なぜ IMediator を入れないか、なぜ CreateSlimBuilder か、なぜインクリメンタル生成か。よく聞かれる設計判断をまとめています。Why no IMediator, why CreateSlimBuilder, why an incremental generator. Frequently asked design questions, answered.

GitHub で読むRead on GitHub

ソースジェネレータSource generator

機能定義、移植性、検証、移行時の重複をカバーする SLICE 診断、ルートマニフェストのスキーマ、インクリメンタルキャッシュの仕組み。SLICE diagnostics for feature shape, portability, validation, and migration overlap, plus the route manifest schema and incremental cache shape.

GitHub で読むRead on GitHub

移行ガイドMigration guides

既存の Minimal API や MVC コントローラーから、1エンドポイントずつ機能ファイルへ移す PoC 手順。Endpoint-by-endpoint PoC paths from existing Minimal APIs or MVC controllers into feature files.

Minimal APIMVC Minimal API · Controllers

ASP.NET 機能と逃げ道ASP.NET features and escape hatches

SliceFx では何が使えるか。認可・レート制限・CORS・キャッシュ・検証の拡張パス、そして ASP.NET / WASI / Lambda 間でハンドラをポータブルに保つためのバインディング規則。What you keep: Authorization, rate limiting, CORS, caching, custom validation with ISliceValidator<T>, and how binding rules differ between ASP.NET (plain Minimal API) and portable targets (WASI / Lambda).

GitHub で読むRead on GitHub

プロダクション準備基準Production readiness targets

まだ達成済みの主張ではありません。6 つの強み保全インバリアント、ベンチマーク基準値、perf ゲート、採用マトリクスをまとめています。Targets, not a completed claim: strength-preservation invariants, benchmark baselines, perf gates, and the adoption matrix.

GitHub で読むRead on GitHub

最新ベンチ結果Latest benchmark chart

毎晩の GitHub Actions perf 実行から生成される、ソースジェネレータの ColdRun / WarmRun_NoOpEdit SVG チャート。An SVG chart generated from the nightly GitHub Actions perf run for source-generator ColdRun and WarmRun_NoOpEdit timings.

SVG を開くOpen SVG