coreex-adapter

Creates CoreEx anti-corruption layer adapters with typed HTTP clients and unit tests.

28|8|Updated Feb 21, 2022
One-click install
npx skills add https://github.com/Avanade/CoreEx --skill coreex-adapter-avanade
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: coreex-adapter
Source: https://github.com/Avanade/CoreEx/tree/main/.github/skills/coreex-adapter
Command: npx skills add https://github.com/Avanade/CoreEx --skill coreex-adapter-avanade

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Integrating external systems into a .NET application without leaking foreign API shapes into your domain requires a disciplined anti-corruption layer. This Skill guides the creation of CoreEx adapters — Application-layer interfaces, Infrastructure-layer implementations, and typed HTTP clients — so external dependencies stay isolated, testable, and consistent with CoreEx conventions. ## Core Features & Use Cases - Adapter Interface Generation: Creates domain-idiomatic IXxxAdapter interfaces in Application/Adapters/{ExternalDomain}/ returning Result/Result<T> instead of throwing exceptions. - Typed HTTP Client & Implementation: Scaffolds XxxHttpClient classes with response.ToResultAsync() status mapping, [ScopedService]-registered adapter implementations, and AddTypedHttpClient registration in Program.cs. - Replication & Sync Adapters: Supports event-driven IXxxSyncAdapter implementations for EF-based local data synchronization alongside synchronous real-time adapters. - HTTP Client Unit Tests: Generates MockHttpClientFactory-based tests covering success (2xx), server error (5xx), and business error (422/ProblemDetails) responses per endpoint. - Use Case: You need your checkout service to reserve inventory in an external Products API. The Skill produces the IProductAdapter interface, a ProductsHttpClient, the ProductAdapter implementation with event publication, and unit tests verifying each HTTP response path. ## Quick Start Ask the AI to create a CoreEx adapter for an external system, for example: create a Products adapter with get, reserve, and cancel operations backed by a typed HTTP client.

Frequently Asked Questions about coreex-adapter

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create an anti-corruption layer adapter in CoreEx?▼

Define a domain-idiomatic interface in Application/Adapters/{ExternalDomain}/ returning Result or Result<T>, then implement it in Infrastructure/Adapters/{ExternalDomain}/ with [ScopedService<IXxxAdapter>]. HTTP calls go through a typed client class, never HttpClient directly in the adapter.

How do I unit test a typed HTTP client in .NET with mocked responses?▼

Use UnitTestEx MockHttpClientFactory with WithGenericTester<EntryPoint>, register the client via AddTypedHttpClient in the test EntryPoint, and mock responses per status code. Cover success (2xx), server error (5xx), and business error (422/ProblemDetails) for each endpoint.

What is the difference between a synchronous adapter and a sync adapter in CoreEx?▼

A synchronous adapter makes real-time HTTP calls to the external system, optionally combined with local EF reads and event publication. A replication sync adapter (IXxxSyncAdapter) performs event-driven upsert/delete into the local EF store. They use separate interfaces and implementations.

When should I not use the CoreEx adapter pattern?▼

Do not use an adapter for repositories within the same domain — use a CoreEx repository instead. Application services that consume adapters and event subscriber hosts that drive sync adapters are also separate concerns handled by their own skills.

Why use CancellationToken.None in adapter compensation paths?▼

Compensation operations like rolling back a reservation after a failed checkout must not be aborted by an already-cancelled request token. Passing CancellationToken.None ensures the compensation completes even when the original request was cancelled.