機能単位で構成Feature-shaped APIs
1つの静的クラスが1つのエンドポイント。リクエスト、レスポンス、ハンドラー、バリデーションを同じ場所で確認できます。One static class maps to one endpoint, keeping request, response, handler, and validation close together.
機能ファイルから API 契約を生成する .NET API フレームワーク。Generate API contracts from feature files.
Minimal API の書き味はそのまま。1つの機能定義から登録、診断、型付きクライアントを生成します。 Keep Minimal APIs. Generate registration, checks, and typed clients from one feature definition.
dotnet run --project samples/SliceFx.Sample
リリース状況: 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.
ルート、DTO、バリデーション、クライアント、移植性チェックを別々に管理せず、1つの機能ファイルからつなげます。Keep routes, DTOs, validation, clients, and portability checks connected to one feature file.
1つの静的クラスが1つのエンドポイント。リクエスト、レスポンス、ハンドラー、バリデーションを同じ場所で確認できます。One static class maps to one endpoint, keeping request, response, handler, and validation close together.
ルートメタデータ、互換性レポート、型付きクライアント、OpenAPI projection を、同じ機能ファイルから生成します。Route metadata, compatibility reports, typed clients, and OpenAPI projections are generated from the same feature files.
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
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.
SLICE001 などのビルド時診断、slicefx routes、slicefx client csharp、slicefx openapi を同じメタデータでつなぎます。Uses the same metadata for feature locality, build-time diagnostics such as SLICE001, slicefx routes, slicefx client csharp, and slicefx openapi.API 層は軽く保ちたい。でもルート、クライアント、将来の実行環境をばらばらに管理したくない。そんな個人やチームに向いています。For individual developers and teams that want a light API layer without letting routes, clients, and future runtime choices drift apart.
slicefx routes で移植性を早めに確認しながら、普段は ASP.NET Core を主な実行環境として使い続けられます。slicefx routes surfaces portability early while ASP.NET Core remains the primary runtime.コアランタイムが依存するのは 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.
AddSlice() と MapSlices() はソースジェネレータが出力します。登録経路を1つに絞り、無効な機能定義は SLICE### 診断としてビルド時に出します。AddSlice() and MapSlices() are emitted by the source generator. Invalid feature shapes become SLICE### diagnostics at build time.
生成コードは標準の 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.
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.
ルートマニフェストをもとに、slicefx routes、slicefx client csharp、slicefx client typescript、slicefx openapi が同じ定義を使います。The route manifest powers slicefx routes, slicefx client csharp, slicefx client typescript, and slicefx openapi from the same definitions.
ジェネレータが出力するのは標準の 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.
生成コードは純粋な 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 →
[Feature("METHOD /path")] でルートを宣言[Feature("METHOD /path")] declarative routing[Filter<T>] でエンドポイントフィルターを適用[Filter<T>] endpoint filtersISliceValidator<T> で検証DataAnnotations and ISliceValidator<T>リクエスト、レスポンス、ハンドラー、バリデーション、フィルターまで、機能に関わるコードを1つのファイルにまとめられます。Request, response, handler, validation, and filters in one feature file.
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);
}
}
var builder = WebApplication.CreateSlimBuilder(args);
builder.Services.AddSlice();
builder.Services.AddSingleton<IUserStore, InMemoryUserStore>();
var app = builder.Build();
app.MapSlices();
app.Run();
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
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.
プレーンな request / response を返す機能。型付きクライアント、WASI dispatch、function-per-feature Lambda の候補になります。Plain request / response features. Candidates for typed clients, WASI dispatch, and function-per-feature Lambda.
ハンドラー形状は移植しやすいが、一部のフィルターなど ASP.NET 固有の振る舞いがあります。The handler shape is portable, but some attached behavior such as endpoint filters is ASP.NET-specific today.
IResult など ASP.NET の機能を意図的に使う機能。悪いコードではなく、ASP.NET に残る判断です。Features that intentionally use ASP.NET concepts such as IResult. Not bad code; simply an ASP.NET-specific choice.
ホスティングやテストに必要な依存関係は、用途ごとのサテライトパッケージに分けています。すべてのパッケージは NuGet で公開されています。Hosting and testing dependencies stay in satellite packages. All packages are available on NuGet.
属性、バリデーションフィルター、エンドポイントフィルターを含むコアランタイムです。Core runtime: attributes, validation filters, and endpoint filters.
機能ルートの登録コードを、AOT に適した形で生成します。AOT-friendly generated registrations for feature routes.
ASP.NET Core 上で AWS Lambda ホスティングを使うための連携パッケージです。AWS Lambda hosting integration over ASP.NET Core.
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 アプリをインプロセスで HTTP テストするためのヘルパーです。In-process HTTP testing helpers for SliceFx apps.
slicefx コマンドで、スキャフォールディング、ルート確認、互換性レポート、型付きクライアント生成、OpenAPI projection を実行できます。Scaffolding, route inspection, compatibility reports, typed client generation, and OpenAPI projections through the slicefx command.
技術詳細Engineering deep dives
SliceFx がどんな原則で動いていて、実運用に向けてどの基準をまだ満たす必要があるかをまとめたドキュメント群です。How SliceFx is built, what invariants it defends, and which production-readiness criteria it still needs to meet.
なぜ IMediator を入れないか、なぜ CreateSlimBuilder か、なぜインクリメンタル生成か。よく聞かれる設計判断をまとめています。Why no IMediator, why CreateSlimBuilder, why an incremental generator. Frequently asked design questions, answered.
GitHub で読むRead on GitHub
機能定義、移植性、検証、移行時の重複をカバーする SLICE 診断、ルートマニフェストのスキーマ、インクリメンタルキャッシュの仕組み。SLICE diagnostics for feature shape, portability, validation, and migration overlap, plus the route manifest schema and incremental cache shape.
GitHub で読むRead on GitHub
既存の Minimal API や MVC コントローラーから、1エンドポイントずつ機能ファイルへ移す PoC 手順。Endpoint-by-endpoint PoC paths from existing Minimal APIs or MVC controllers into feature files.
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
まだ達成済みの主張ではありません。6 つの強み保全インバリアント、ベンチマーク基準値、perf ゲート、採用マトリクスをまとめています。Targets, not a completed claim: strength-preservation invariants, benchmark baselines, perf gates, and the adoption matrix.
GitHub で読むRead on GitHub
毎晩の 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