diff --git a/CLAUDE.md b/CLAUDE.md index deff540f..613cb2de 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -33,8 +33,8 @@ runtime has to be installed as well for the `net10.0` test runs. - `dotnet build TailoredApps.Shared.slnx -c Release -p:ValidatePublicApi=true` compares the public API of every library with the same package at the baseline version on nuget.org (`PublicApiBaselineVersion` in `src/Directory.Build.targets`, currently `2.0.0`) and fails on a breaking change (`CP0001`, `CP0002`, ...). Adding API passes. The *Build & Test PR* workflow builds with the switch on. -- On `master` (3.0) the `TailoredApps.Shared.MediatR*` libraries are left out of the comparison (a group in `src/Directory.Build.targets`): - their public API changed on purpose. A deliberate break in another library is recorded member by member in that library's +- On `master` (3.0) the `TailoredApps.Shared.Mediator*` libraries are left out of the comparison (a group in `src/Directory.Build.targets`): + 3.0 renamed them from `TailoredApps.Shared.MediatR*`, so the baseline has no package with their id, and their public API changed on purpose. A deliberate break in another library is recorded member by member in that library's `CompatibilitySuppressions.xml` (build it with `-p:ValidatePublicApi=true -p:ApiCompatGenerateSuppressionFile=true`, review it), so the rest of its API stays guarded; DateTime, ExceptionHandling, PayNow and Tpay have one for the obsolete members 3.0 removed. When `3.0.0` is published, remove the group and the suppression files and raise the baseline to `3.0.0`. @@ -72,8 +72,8 @@ with the other tests. A new library is added to the demo with a test of its scen - `Directory.Build.props` (root): artifacts output, `TargetFrameworks` (`net10.0;net11.0` for every project) and `LangVersion=latest`, so both target frameworks compile with the same C# version. It stamps the build time into `SourceRevisionId` for Release builds only, and a Debug build carries no commit id either: a value that changes with every build (or commit) made every build recompile everything and renamed the content-named files of the WebAssembly client each time. - `eng/RuntimeAsync.targets` (imported by `src/Directory.Build.targets` and `samples/Directory.Build.targets`): turns on runtime async for the `net11.0` assets of the libraries and the demo (`UseRuntimeAsync`, opt out per project or per build). Tests are compiled the classic way on purpose. Never set `Features` or `EnablePreviewFeatures` in a csproj. - Trimming and NativeAOT: options are bound by the generated configuration binder (`EnableConfigurationBindingGenerator` in `src/Directory.Build.props`; `Email.Office365` opts out because of its certificate options). A library that is AOT-safe sets `true` in its csproj; `eng/AotCompatible.globalconfig` then turns every trimming/AOT analyzer warning into an error there. JSON in those libraries goes through a `JsonSerializerContext` (`JsonSerializer` with a `JsonTypeInfo`, never the reflection overloads); generic parameters that reach the container carry `DynamicallyAccessedMembers`. -- `tests/TailoredApps.Shared.AotSmoke` (console: payments, options, signatures, the mediator with its behaviors but no cache), `tests/TailoredApps.Shared.AotSmoke.Web` (minimal API: WebApi, ExceptionHandling, Email, `[Authorize]` with JWT) and `tests/TailoredApps.Shared.AotSmoke.Caching` (the MediatR response cache) are applications, not test projects: the *NativeAOT smoke test* job publishes them with NativeAOT for `net10.0` and `net11.0` on Linux and Windows and runs them. Together they reference exactly the `IsAotCompatible` libraries; add a library and a check there when it becomes AOT-safe. The first two allow no trim/AOT warning at all. The caching one exists because `Microsoft.Extensions.Caching.Hybrid` still reports warnings for a JSON fallback: it lets `IL2026`/`IL2070`/`IL3050` through and the job fails when such a warning names any other assembly - never loosen the other two instead. Publishing needs clang and zlib (Linux) or the C++ build tools (Windows). With Visual Studio 2026 a `net10.0` publish fails unless `C:\Program Files (x86)\Microsoft Visual Studio\Installer` (vswhere.exe) is on the PATH. -- Known platform limits, verified on .NET 11: MVC controllers do not work under NativeAOT (routes answer 404) and EF Core is not AOT-ready, so the EntityFramework family stays outside the AOT set (as do `MediatR.ML`, Stripe and `Email.Office365`, because of their dependencies); the container cannot close an open generic service over a value type under NativeAOT, which is why the MediatR behaviors have a closed, per-request registration; Blazor WebAssembly (Mono) cannot execute runtime-async methods, so the `net11.0` assets fail there with `PlatformNotSupportedException`. +- `tests/TailoredApps.Shared.AotSmoke` (console: payments, options, signatures, the mediator with its behaviors but no cache), `tests/TailoredApps.Shared.AotSmoke.Web` (minimal API: WebApi, ExceptionHandling, Email, `[Authorize]` with JWT) and `tests/TailoredApps.Shared.AotSmoke.Caching` (the mediator response cache) are applications, not test projects: the *NativeAOT smoke test* job publishes them with NativeAOT for `net10.0` and `net11.0` on Linux and Windows and runs them. Together they reference exactly the `IsAotCompatible` libraries; add a library and a check there when it becomes AOT-safe. The first two allow no trim/AOT warning at all. The caching one exists because `Microsoft.Extensions.Caching.Hybrid` still reports warnings for a JSON fallback: it lets `IL2026`/`IL2070`/`IL3050` through and the job fails when such a warning names any other assembly - never loosen the other two instead. Publishing needs clang and zlib (Linux) or the C++ build tools (Windows). With Visual Studio 2026 a `net10.0` publish fails unless `C:\Program Files (x86)\Microsoft Visual Studio\Installer` (vswhere.exe) is on the PATH. +- Known platform limits, verified on .NET 11: MVC controllers do not work under NativeAOT (routes answer 404) and EF Core is not AOT-ready, so the EntityFramework family stays outside the AOT set (as do `Mediator.ML`, Stripe and `Email.Office365`, because of their dependencies); the container cannot close an open generic service over a value type under NativeAOT, which is why the mediator behaviors have a closed, per-request registration; Blazor WebAssembly (Mono) cannot execute runtime-async methods, so the `net11.0` assets fail there with `PlatformNotSupportedException`. - Package versions are managed centrally in `Directory.Packages.props`; a project file lists `` without a version. Packages tied to the runtime generation (`Microsoft.Extensions.*`, `Microsoft.EntityFrameworkCore*`) have one `PackageVersion` per target framework in conditional groups (`net10.0` -> `10.*`, `net11.0` -> `11.*`). Adding such a dependency means adding it to both groups. @@ -90,18 +90,18 @@ with the other tests. A new library is added to the demo with a test of its scen Signature checks must fail closed and use `Payments/Security/WebhookSignature` (constant time); identifiers placed in gateway URLs go through `PaymentIdentifier`. A gateway that cannot handle a call (5xx, 408, 429, no answer) is `PaymentGatewayException` from every provider; creating a payment turns a 4xx into `Rejected`, and a failed status query is always `PaymentGatewayException`. A provider on an SDK translates its exceptions (Stripe: `StripeException`). -- **MediatR** - built on **ForkForward.Mediator** (a fork of MediatR 12.5.0; namespace `ForkForward.Mediator`, registration `AddMediator`), not on the - MediatR package; the library and namespace names keep `MediatR`. `PipelineRegistration` adds the behaviours in a fixed order: +- **Mediator** - built on **ForkForward.Mediator** (a fork of MediatR 12.5.0; namespace `ForkForward.Mediator`, registration `AddMediator`), not on the + MediatR package; 3.0 renamed the libraries, packages and namespaces from `TailoredApps.Shared.MediatR*` to `TailoredApps.Shared.Mediator*` (the old ids stay on nuget.org with 2.x and the first two previews). Inside `TailoredApps.Shared.*` namespaces the class `Mediator` of the fork has to be written `ForkForward.Mediator.Mediator`: the short name is a namespace there (CS0118). `PipelineRegistration` adds the behaviours in a fixed order: Logging -> Validation (FluentValidation) -> Caching -> Fallback -> Retry. A request opts in by having an `ICachePolicy<,>`, `IFallbackHandler<,>` or `IRetryableRequest<,>` implementation, which assembly scanning (Scrutor) registers. Caching uses `HybridCache` (registered by `RegisterPipelineBehaviors()`). Scanning is marked `RequiresUnreferencedCode`; a trimmed or NativeAOT application registers by name instead (`AddPipelineBehaviors<,>()` / `AddPipelineBehaviorsWithoutCaching<,>()`, `AddCachePolicy`, `AddFallbackHandler`, - `AddRetryPolicy`, `AddCacheSerialization(JsonSerializerContext)`), and the default cache key refuses to run without reflection-based JSON. Satellites: `MediatR.Caching` (marker contracts), `MediatR.Email`, - `MediatR.PagedRequest`, and `MediatR.ML`, whose namespace is `TailoredApps.Shared.MediatR.ImageClassification`, not the project name. + `AddRetryPolicy`, `AddCacheSerialization(JsonSerializerContext)`), and the default cache key refuses to run without reflection-based JSON. Satellites: `Mediator.Caching` (marker contracts), `Mediator.Email`, + `Mediator.PagedRequest`, and `Mediator.ML`, whose namespace is `TailoredApps.Shared.Mediator.ImageClassification`, not the project name. - **EntityFramework** - a unit of work over `DbContext` with hooks (before/after save, commit, rollback) that also drive audit change collection, plus paging/sorting/filtering extensions (dynamic LINQ with sort-field validation). `EntityFramework.UnitOfWork.WebApiCore` adds the MVC transaction filter (`AddUnitOfWorkForWebApi<,>`); `EntityFramework.UnitOfWork.MinimalApi` is the same rule as an endpoint filter - (`WithUnitOfWorkTransaction()`). `Querying` holds the framework-free query contracts used by both EntityFramework and `MediatR.PagedRequest`. + (`WithUnitOfWorkTransaction()`). `Querying` holds the framework-free query contracts used by both EntityFramework and `Mediator.PagedRequest`. - **ExceptionHandling** - `AddExceptionHandlingForWebApi<,>` plus a filter and middleware; an `IExceptionHandlingProvider` maps exceptions to the response model. Unexpected exceptions are answered with 500 and a generic message. Exceptions mapped to 4xx are not logged as errors (middleware diagnostics suppressed, Debug entry instead), and `LoggingBehavior` logs validation refusals and cancellations at Information. @@ -111,13 +111,13 @@ with the other tests. A new library is added to the demo with a test of its scen - **WebApi** - `builder.AddTailoredWebApiDefaults()` and `app.MapTailoredWebApiDefaults()` wire OpenTelemetry (OTLP), health checks and HTTP client resilience with service discovery from the `WebApiDefaults` configuration section. -`Payments.Tests` covers the core library and every provider; `MediatR.Tests` also covers `MediatR.Email` and `MediatR.PagedRequest`; `Email.Tests` also covers `Email.Office365`. +`Payments.Tests` covers the core library and every provider; `Mediator.Tests` also covers `Mediator.Email` and `Mediator.PagedRequest`; `Email.Tests` also covers `Email.Office365`. # Branches and releases - `master` is the **3.0** line, in a test phase: pre-releases are tagged `v3.0.0-preview.N`, and breaking changes are allowed until `3.0.0` but must be deliberate (the PR build still compares the libraries with `2.0.0`, see *Public API compatibility*). 3.0 replaces MediatR with - ForkForward.Mediator in the `MediatR*` libraries; `docs/Migration/v3.md` lists what an application has to change. + ForkForward.Mediator and renames the `MediatR*` libraries to `Mediator*`; `docs/Migration/v3.md` lists what an application has to change. - `release/2.1` is the **2.1.x** maintenance line (branched from `v2.1.0`): fixes only, tagged `v2.1.N` from that branch, compatible with `2.0.0`. - `release/1.x` is the **1.6.x** maintenance line (it still builds `net8.0`, `net9.0` and the `netstandard` assets): security fixes only, tagged `v1.6.N` from that branch, binary compatible with `1.6.0`. diff --git a/TailoredApps.Shared.slnx b/TailoredApps.Shared.slnx index e0c44aa8..d79f1f83 100644 --- a/TailoredApps.Shared.slnx +++ b/TailoredApps.Shared.slnx @@ -40,11 +40,11 @@ - - - - - + + + + + @@ -68,8 +68,8 @@ - - + + diff --git a/docs-en/Demo/index.md b/docs-en/Demo/index.md index a06668fe..cf04e633 100644 --- a/docs-en/Demo/index.md +++ b/docs-en/Demo/index.md @@ -1,7 +1,7 @@ # Sample service and integration tests !!! info "3.0 line (test phase)" - The sample is in the repository from the 3.0 line (`master`) and uses the MediatR libraries on **ForkForward.Mediator** + The sample is in the repository from the 3.0 line (`master`) and uses the Mediator libraries on **ForkForward.Mediator** (see [Upgrading to 3.0](../Migration/v3.md)). It is not a NuGet package and is never published to nuget.org. `samples/` holds a small shop built the way a real service of ours is built: the contract, the logic and the HTTP host, with a browser @@ -44,7 +44,7 @@ dotnet test tests/TailoredApps.Shared.IntegrationTests/TailoredApps.Shared.Integ | Project | What it holds | Depends on | |---|---|---| -| `TailoredApps.Shared.Demo.DataModel` | The contract. Per feature (`Catalog`, `Orders`): `Messages/Commands`, `Messages/Queries`, `Messages/Notifications`, `Responses/…`, `Model` | the mediator contracts, `MediatR.PagedRequest`, `MediatR.Caching`, `Payments` - no EF Core, no handlers | +| `TailoredApps.Shared.Demo.DataModel` | The contract. Per feature (`Catalog`, `Orders`): `Messages/Commands`, `Messages/Queries`, `Messages/Notifications`, `Responses/…`, `Model` | the mediator contracts, `Mediator.PagedRequest`, `Mediator.Caching`, `Payments` - no EF Core, no handlers | | `TailoredApps.Shared.Demo.Services` | The logic. Per feature: `Entities`, `Handlers` (one interface each under `Interfaces/Handlers`), `Infrastructure` (repositories over the unit of work, behind `Interfaces/Infrastructure`), `Validation`, `Policies` (cache, retry, fallback), `Processing` (pre/post-processors, exception action and handler, stream behavior), `Exceptions`, the EF mapping (`IModelBuilder`) and the mapper profile. `ShopDataContext` at the root | `DataModel`, EF Core, the libraries - nothing of ASP.NET Core | | `TailoredApps.Shared.Demo.WebApi` | The host. `Program` (builds, seeds, runs) and `Startup` (`ConfigureServices`, `Configure`), `Controllers`, `Endpoints` (minimal API), `Authentication`, `ExceptionHandling`. It also serves the client's files | both, and every library | | `TailoredApps.Shared.Demo.Client` | The browser client: Blazor WebAssembly with MudBlazor, no JavaScript of its own. `Pages` (catalogue, product, basket, order), `Services` (`ShopApi`, `Session`, `Basket`) | `DataModel` only - the messages and responses are the server's own types | @@ -65,12 +65,12 @@ filter** commits or rolls back; the **exception provider** shapes the error. No | [ExceptionHandling](../Libraries/ExceptionHandling/index.md) | `ShopExceptionHandlingProvider`: a `ShopException` answers with its own status and message, everything else with the defaults | `GET /api/products/999` (404), a duplicate product (409) | | [EntityFramework](../Libraries/EntityFramework/index.md), [UnitOfWork.WebApiCore](../Libraries/EntityFramework/UnitOfWork.WebApiCore.md) | `ShopDataContext` with one `IModelBuilder` per feature, repositories on `IUnitOfWork`, the transaction filter | `POST /api/orders` with a missing product: 400, and nothing is left in the database | | [UnitOfWork.MinimalApi](../Libraries/EntityFramework/UnitOfWork.MinimalApi.md), [ExceptionHandling.MinimalApi](../Libraries/ExceptionHandling/MinimalApi.md) | `Endpoints/ProductEndpoints.cs`: a group with `WithExceptionHandling()`, `WithUnitOfWorkTransaction()` and `WithValidation()`, sending the same messages | `POST /api/minimal/products`, `GET /api/minimal/products/{name}` | -| [Querying](../Libraries/Querying/index.md), [MediatR.PagedRequest](../Libraries/MediatR/PagedRequest.md) | `GetProducts` with `ProductFilter`; in `ProductRepository`: `ApplySorting` with an allow-list, the mapper's `ProjectTo`, `PagingAsync` | `GET /api/products?page=1&count=3&sortField=Price&sortDir=Desc&filter.category=tea` | -| [MediatR](../Libraries/MediatR/index.md), [MediatR.Caching](../Libraries/MediatR/Caching.md) | the five behaviors around every request; `GetProduct` (cache policy), `GetRecommendations` (retry, fallback) | `GET /api/products/1`, `GET /api/products/0`, `GET /api/products/1/recommendations` | +| [Querying](../Libraries/Querying/index.md), [Mediator.PagedRequest](../Libraries/Mediator/PagedRequest.md) | `GetProducts` with `ProductFilter`; in `ProductRepository`: `ApplySorting` with an allow-list, the mapper's `ProjectTo`, `PagingAsync` | `GET /api/products?page=1&count=3&sortField=Price&sortDir=Desc&filter.category=tea` | +| [Mediator](../Libraries/Mediator/index.md), [Mediator.Caching](../Libraries/Mediator/Caching.md) | the five behaviors around every request; `GetProduct` (cache policy), `GetRecommendations` (retry, fallback) | `GET /api/products/1`, `GET /api/products/0`, `GET /api/products/1/recommendations` | | [Payments](../Libraries/Payments/index.md) + 9 providers | `AddPayments().Register…Provider()`, `CheckoutOrderCommandHandler`, `ReceivePaymentNotificationCommandHandler` | `POST /api/orders/{number}/checkout`, `POST /api/webhooks/{provider}`, `GET /api/payments/providers` | -| [Email](../Libraries/Email/index.md), [Email.Models](../Libraries/Email/Models.md), [MediatR.Email](../Libraries/MediatR/Email.md) | `SendOrderConfirmation`: `SendMail` with the `EmailTemplates/order-confirmation.html` template, the console provider | the message on the console once the order is paid | +| [Email](../Libraries/Email/index.md), [Email.Models](../Libraries/Email/Models.md), [Mediator.Email](../Libraries/Mediator/Email.md) | `SendOrderConfirmation`: `SendMail` with the `EmailTemplates/order-confirmation.html` template, the console provider | the message on the console once the order is paid | | [Email.Office365](../Libraries/Email/Office365.md) | `GET /api/inbox` - only with `Demo:Office365Inbox` and an Azure AD application | without configuration: 501 | -| [MediatR.ML](../Libraries/MediatR/ML.md) | `POST /api/images/classify` - only with `ImageClassification:ModelFilePath` | without a model: 501 | +| [Mediator.ML](../Libraries/Mediator/ML.md) | `POST /api/images/classify` - only with `ImageClassification:ModelFilePath` | without a model: 501 | --- diff --git a/docs-en/Libraries/MediatR/Caching.md b/docs-en/Libraries/Mediator/Caching.md similarity index 68% rename from docs-en/Libraries/MediatR/Caching.md rename to docs-en/Libraries/Mediator/Caching.md index 9d8ab529..7ff4bc90 100644 --- a/docs-en/Libraries/MediatR/Caching.md +++ b/docs-en/Libraries/Mediator/Caching.md @@ -1,22 +1,22 @@ -# TailoredApps.Shared.MediatR.Caching +# TailoredApps.Shared.Mediator.Caching -[![NuGet](https://img.shields.io/nuget/v/TailoredApps.Shared.MediatR.Caching)](https://www.nuget.org/packages/TailoredApps.Shared.MediatR.Caching/) +[![NuGet](https://img.shields.io/nuget/v/TailoredApps.Shared.Mediator.Caching)](https://www.nuget.org/packages/TailoredApps.Shared.Mediator.Caching/) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/tailored-apps/SharedComponents/blob/master/LICENSE) --- ## Description -A lightweight package defining `ICachableRequest` — a contract for MediatR requests that name their own cache key. A request implementing this interface provides a `GetCacheKey()` method that generates a unique cache key for that particular query instance. +A lightweight package defining `ICachableRequest` — a contract for mediator requests that name their own cache key. A request implementing this interface provides a `GetCacheKey()` method that generates a unique cache key for that particular query instance. -The package contains the contract only: it has no services and nothing to register. `CachingBehavior` from `TailoredApps.Shared.MediatR` does **not** read `ICachableRequest` — it caches a request only when an `ICachePolicy` is registered for it. Use the interface to keep the key logic in the request itself, and add a cache policy that returns that key (shown below) when the response is to be cached by that behavior. +The package contains the contract only: it has no services and nothing to register. `CachingBehavior` from `TailoredApps.Shared.Mediator` does **not** read `ICachableRequest` — it caches a request only when an `ICachePolicy` is registered for it. Use the interface to keep the key logic in the request itself, and add a cache policy that returns that key (shown below) when the response is to be cached by that behavior. --- ## Installation ```bash -dotnet add package TailoredApps.Shared.MediatR.Caching +dotnet add package TailoredApps.Shared.Mediator.Caching ``` --- @@ -24,7 +24,7 @@ dotnet add package TailoredApps.Shared.MediatR.Caching ## Usage example ```csharp -using TailoredApps.Shared.MediatR.Caching; +using TailoredApps.Shared.Mediator.Caching; using ForkForward.Mediator; // Request with built-in cache key logic @@ -37,7 +37,7 @@ public class GetUserProfileQuery : ICachableRequest public string GetCacheKey() => $"user-profile:{UserId}:{Language}"; } -// Handler — standard MediatR +// Handler — a standard request handler public class GetUserProfileQueryHandler : IRequestHandler { private readonly IUserRepository _repo; @@ -55,7 +55,7 @@ public class GetUserProfileQueryHandler : IRequestHandler @@ -65,12 +65,12 @@ public class GetUserProfileQueryCachePolicy : ICachePolicy` is registered for it (`PipelineRegistration.RegisterPipelineBehaviors(assembly)` scans for policies). Without a policy the request above runs its handler every time. + `ICachableRequest` is a marker interface — on its own it does not trigger caching, and `CachingBehavior` from the `TailoredApps.Shared.Mediator` package does not look at it. A request is cached only when an `ICachePolicy` is registered for it (`PipelineRegistration.RegisterPipelineBehaviors(assembly)` scans for policies). Without a policy the request above runs its handler every time. !!! info "Trimming and NativeAOT" The package holds a contract only and is safe for trimming and NativeAOT. In such an application a policy that returns `request.GetCacheKey()` is also the simplest way to a cache key: the default key of `ICachePolicy` needs reflection. The policy is - registered by name (`AddCachePolicy<,,>()`) - see [MediatR: Trimming and NativeAOT](index.md#trimming-and-nativeaot). + registered by name (`AddCachePolicy<,,>()`) - see [Mediator: Trimming and NativeAOT](index.md#trimming-and-nativeaot). --- @@ -86,9 +86,9 @@ public class GetUserProfileQueryCachePolicy : ICachePolicy public string GetCacheKey() => $"product:{Id}"; } -// Needed for CachingBehavior (TailoredApps.Shared.MediatR) to cache the request: +// Needed for CachingBehavior (TailoredApps.Shared.Mediator) to cache the request: public class GetProductQueryCachePolicy : ICachePolicy { public string GetCacheKey(GetProductQuery request) => request.GetCacheKey(); @@ -111,7 +111,7 @@ public class GetProductQueryCachePolicy : ICachePolicy extends IRequest - GetCacheKey() must return a unique key for this combination of parameters -- The interface alone does not cache, and CachingBehavior from TailoredApps.Shared.MediatR does not read it +- The interface alone does not cache, and CachingBehavior from TailoredApps.Shared.Mediator does not read it - CachingBehavior caches only requests that have a registered ICachePolicy — add a policy that returns request.GetCacheKey() - An application with PublishAot: register the policy by name - new PipelineRegistration(services).AddCachePolicy() - scanning is not available there ```` diff --git a/docs-en/Libraries/MediatR/Email.md b/docs-en/Libraries/Mediator/Email.md similarity index 76% rename from docs-en/Libraries/MediatR/Email.md rename to docs-en/Libraries/Mediator/Email.md index 180a5327..41f6be49 100644 --- a/docs-en/Libraries/MediatR/Email.md +++ b/docs-en/Libraries/Mediator/Email.md @@ -1,13 +1,13 @@ -# TailoredApps.Shared.MediatR.Email +# TailoredApps.Shared.Mediator.Email -[![NuGet](https://img.shields.io/nuget/v/TailoredApps.Shared.MediatR.Email)](https://www.nuget.org/packages/TailoredApps.Shared.MediatR.Email/) +[![NuGet](https://img.shields.io/nuget/v/TailoredApps.Shared.Mediator.Email)](https://www.nuget.org/packages/TailoredApps.Shared.Mediator.Email/) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/tailored-apps/SharedComponents/blob/master/LICENSE) --- ## Description -MediatR pipeline integration for email sending. The library provides the `SendMail` command and its `SendMailCommandHandler`, making email sending a natural part of CQRS architecture — you can send an email via `_mediator.Send(new SendMail { ... })` without a direct dependency on `IEmailProvider`. +Mediator pipeline integration for email sending. The library provides the `SendMail` command and its `SendMailCommandHandler`, making email sending a natural part of CQRS architecture — you can send an email via `_mediator.Send(new SendMail { ... })` without a direct dependency on `IEmailProvider`. This approach makes it easy to enrich the sending process with logging, retry, and auditing from the pipeline behaviors level, without modifying the handler. @@ -16,7 +16,7 @@ This approach makes it easy to enrich the sending process with logging, retry, a ## Installation ```bash -dotnet add package TailoredApps.Shared.MediatR.Email +dotnet add package TailoredApps.Shared.Mediator.Email ``` --- @@ -26,7 +26,7 @@ dotnet add package TailoredApps.Shared.MediatR.Email ```csharp // Program.cs using TailoredApps.Shared.Email; -using TailoredApps.Shared.MediatR.Email.Handlers; +using TailoredApps.Shared.Mediator.Email.Handlers; using TailoredApps.Shared.Email.MailMessageBuilder; // 1. Register the email provider (SMTP or console) @@ -40,7 +40,7 @@ builder.Services.Configure(o => o.FileExtension = "html"; }); -// 3. MediatR: scan the library assembly as well - that is where SendMailCommandHandler lives +// 3. Mediator: scan the library assembly as well - that is where SendMailCommandHandler lives builder.Services.AddMediator(cfg => { cfg.RegisterServicesFromAssembly(typeof(Program).Assembly); @@ -48,7 +48,7 @@ builder.Services.AddMediator(cfg => }); ``` -The package has no registration extension of its own. MediatR resolves the handler as `IRequestHandler`, so registering `SendMailCommandHandler` only under `ISendMailCommandHandler` does not let `_mediator.Send(new SendMail { ... })` find it. Either scan the library assembly as above or register the handler under the MediatR interface yourself: +The package has no registration extension of its own. The mediator resolves the handler as `IRequestHandler`, so registering `SendMailCommandHandler` only under `ISendMailCommandHandler` does not let `_mediator.Send(new SendMail { ... })` find it. Either scan the library assembly as above or register the handler under the mediator interface yourself: ```csharp builder.Services.AddTransient, SendMailCommandHandler>(); @@ -62,14 +62,14 @@ builder.Services.AddMediator(cfg => ``` The library is NativeAOT-compatible together with the SMTP and console providers of `TailoredApps.Shared.Email`; the `Email.Office365` -provider is not. The other rules: [MediatR: Trimming and NativeAOT](index.md#trimming-and-nativeaot). +provider is not. The other rules: [Mediator: Trimming and NativeAOT](index.md#trimming-and-nativeaot). --- ## Usage example ```csharp -using TailoredApps.Shared.MediatR.Email.Messages.Commands; +using TailoredApps.Shared.Mediator.Email.Messages.Commands; public class UserRegistrationService { @@ -81,7 +81,7 @@ public class UserRegistrationService { // Registration logic... - // Send the welcome email through the MediatR pipeline + // Send the welcome email through the mediator pipeline var result = await _mediator.Send(new SendMail { Recipent = email, @@ -137,9 +137,9 @@ public class UserRegistrationService ## 🤖 AI Agent Prompt ````markdown -## TailoredApps.Shared.MediatR.Email - instructions for an AI agent +## TailoredApps.Shared.Mediator.Email - instructions for an AI agent -You are using TailoredApps.Shared.MediatR.Email to send emails through the MediatR pipeline. +You are using TailoredApps.Shared.Mediator.Email to send emails through the mediator pipeline. ### Registration ```csharp @@ -166,7 +166,7 @@ var result = await _mediator.Send(new SendMail ``` ### Rules -- MediatR must find the handler as IRequestHandler: scan the library assembly; registering it only as ISendMailCommandHandler is not enough +- The mediator must find the handler as IRequestHandler: scan the library assembly; registering it only as ISendMailCommandHandler is not enough - Template and Recipent are required - the handler throws ArgumentException when either is null - Template is the template key passed to IMailMessageBuilder.Build() - TemplateVariables replace {{token}} in the template diff --git a/docs-en/Libraries/MediatR/ML.md b/docs-en/Libraries/Mediator/ML.md similarity index 85% rename from docs-en/Libraries/MediatR/ML.md rename to docs-en/Libraries/Mediator/ML.md index 991d36d1..720ea077 100644 --- a/docs-en/Libraries/MediatR/ML.md +++ b/docs-en/Libraries/Mediator/ML.md @@ -1,13 +1,13 @@ -# TailoredApps.Shared.MediatR.ML +# TailoredApps.Shared.Mediator.ML -[![NuGet](https://img.shields.io/nuget/v/TailoredApps.Shared.MediatR.ML)](https://www.nuget.org/packages/TailoredApps.Shared.MediatR.ML/) +[![NuGet](https://img.shields.io/nuget/v/TailoredApps.Shared.Mediator.ML)](https://www.nuget.org/packages/TailoredApps.Shared.Mediator.ML/) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/tailored-apps/SharedComponents/blob/master/LICENSE) --- ## Description -This library integrates **ML.NET** image classification with the MediatR pipeline. It provides ready-made commands (`ClassifyImage`, `TrainImageClassificationModel`) and their handlers, making image classification a first-class citizen in CQRS architecture. +This library integrates **ML.NET** image classification with the mediator pipeline. It provides ready-made commands (`ClassifyImage`, `TrainImageClassificationModel`) and their handlers, making image classification a first-class citizen in CQRS architecture. Under the hood, `ImageClassificationService` uses ML.NET with a `PredictionEnginePool` for efficient concurrent inference. The library also supports in-app model training — you can train a new model by providing a labeled image dataset. @@ -16,7 +16,7 @@ Under the hood, `ImageClassificationService` uses ML.NET with a `PredictionEngin ## Installation ```bash -dotnet add package TailoredApps.Shared.MediatR.ML +dotnet add package TailoredApps.Shared.Mediator.ML ``` --- @@ -26,10 +26,10 @@ dotnet add package TailoredApps.Shared.MediatR.ML ```csharp // Program.cs using Microsoft.Extensions.ML; -using TailoredApps.Shared.MediatR.ImageClassification.Infrastructure; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Domain.Models; +using TailoredApps.Shared.Mediator.ImageClassification.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Domain.Models; -// MediatR: the handlers of both commands live in the library assembly, so scan it as well +// Mediator: the handlers of both commands live in the library assembly, so scan it as well builder.Services.AddMediator(cfg => { cfg.RegisterServicesFromAssembly(typeof(Program).Assembly); @@ -46,9 +46,9 @@ builder.Services.AddPredictionEngine(config => }); ``` -`AddPredictionEngine` registers `IImageClassificationService`, `IModelInfoService` and `IModelHelper` (scoped) and binds `ImageClassificationOptions`. It does not register the MediatR handlers - that is what scanning the library assembly is for. `RegisterMachineLearningModel` adds the ML.NET `PredictionEnginePool`; where the model is loaded from is decided by the pool builder (`FromFile` above). Register the model without a name: predictions use the default model of the pool. +`AddPredictionEngine` registers `IImageClassificationService`, `IModelInfoService` and `IModelHelper` (scoped) and binds `ImageClassificationOptions`. It does not register the mediator handlers - that is what scanning the library assembly is for. `RegisterMachineLearningModel` adds the ML.NET `PredictionEnginePool`; where the model is loaded from is decided by the pool builder (`FromFile` above). Register the model without a name: predictions use the default model of the pool. -The types live in the namespace `TailoredApps.Shared.MediatR.ImageClassification`, not under the package name. +The types live in the namespace `TailoredApps.Shared.Mediator.ImageClassification`, not under the package name. ### `appsettings.json` configuration @@ -143,7 +143,7 @@ Training reads the files with the extension `.jpg` or `.png` from the source dir | `InMemoryImageData` | Class | Model input data: the image as `byte[]` | | `ImagePredictionScore` | Class | Raw model output: `Score` (per class), `PredictedLabel` | | `ImageClassificationOptions` | Class | Options bound from the `ImageClassification` section: `ModelFilePath`, `TrainingRoot`, `ModelsRoot`, `MaxImageBytes` | -| `AddPredictionEngineExtension.AddPredictionEngine` | Ext. method | Registers `IImageClassificationService`, `IModelInfoService`, `IModelHelper` and the options in DI (not the MediatR handlers) | +| `AddPredictionEngineExtension.AddPredictionEngine` | Ext. method | Registers `IImageClassificationService`, `IModelInfoService`, `IModelHelper` and the options in DI (not the mediator handlers) | | `PredictionEngineServiceConfiguration.RegisterMachineLearningModel` | Method | Adds the ML.NET `PredictionEnginePool` and its adapter; called inside `AddPredictionEngine` | --- @@ -169,15 +169,15 @@ Training reads the files with the extension `.jpg` or `.png` from the source dir ## 🤖 AI Agent Prompt ````markdown -## TailoredApps.Shared.MediatR.ML - instructions for an AI agent +## TailoredApps.Shared.Mediator.ML - instructions for an AI agent -You are using TailoredApps.Shared.MediatR.ML to classify images through ML.NET and MediatR. +You are using TailoredApps.Shared.Mediator.ML to classify images through ML.NET and the mediator. ### Registration ```csharp // using Microsoft.Extensions.ML; -// using TailoredApps.Shared.MediatR.ImageClassification.Infrastructure; -// using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Domain.Models; +// using TailoredApps.Shared.Mediator.ImageClassification.Infrastructure; +// using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Domain.Models; builder.Services.AddMediator(cfg => { cfg.RegisterServicesFromAssembly(typeof(Program).Assembly); @@ -191,7 +191,7 @@ builder.Services.AddPredictionEngine(config => ### What gets configured - IImageClassificationService, IModelInfoService, IModelHelper (scoped) and ImageClassificationOptions - The ML.NET PredictionEnginePool with the model (default, unnamed) -- The handlers of ClassifyImage and TrainImageClassificationModel - only through the MediatR scan of the library assembly +- The handlers of ClassifyImage and TrainImageClassificationModel - only through the mediator scan of the library assembly ### Configuration (section "ImageClassification") - ModelFilePath - the model file (used for the model metadata and by the registration above) @@ -220,7 +220,7 @@ var result = await _mediator.Send(new TrainImageClassificationModel ``` ### Rules -- The namespace is TailoredApps.Shared.MediatR.ImageClassification, not the package name +- The namespace is TailoredApps.Shared.Mediator.ImageClassification, not the package name - AddMediator must scan the library assembly - AddPredictionEngine does not register the handlers - The model must be a ZIP file (ML.NET format) - The `ImageClassification` configuration section is required — a missing section throws `InvalidOperationException` when the options are first used diff --git a/docs-en/Libraries/MediatR/PagedRequest.md b/docs-en/Libraries/Mediator/PagedRequest.md similarity index 89% rename from docs-en/Libraries/MediatR/PagedRequest.md rename to docs-en/Libraries/Mediator/PagedRequest.md index ce593549..cfdaf6b6 100644 --- a/docs-en/Libraries/MediatR/PagedRequest.md +++ b/docs-en/Libraries/Mediator/PagedRequest.md @@ -1,13 +1,13 @@ -# TailoredApps.Shared.MediatR.PagedRequest +# TailoredApps.Shared.Mediator.PagedRequest -[![NuGet](https://img.shields.io/nuget/v/TailoredApps.Shared.MediatR.PagedRequest)](https://www.nuget.org/packages/TailoredApps.Shared.MediatR.PagedRequest/) +[![NuGet](https://img.shields.io/nuget/v/TailoredApps.Shared.Mediator.PagedRequest)](https://www.nuget.org/packages/TailoredApps.Shared.Mediator.PagedRequest/) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/tailored-apps/SharedComponents/blob/master/LICENSE) --- ## Description -This library provides a base `PagedAndSortedRequest` class for MediatR requests that require pagination and sorting. It standardizes paging (`Page`, `Count`) and sorting (`SortField`, `SortDir`) parameters across all list queries in the application. +This library provides a base `PagedAndSortedRequest` class for mediator requests that require pagination and sorting. It standardizes paging (`Page`, `Count`) and sorting (`SortField`, `SortDir`) parameters across all list queries in the application. The class is tightly integrated with `TailoredApps.Shared.Querying` — requires `TQuery` to inherit from `QueryBase` and `TResponse` to implement `IPagedResult`. @@ -16,7 +16,7 @@ The class is tightly integrated with `TailoredApps.Shared.Querying` — requires ## Installation ```bash -dotnet add package TailoredApps.Shared.MediatR.PagedRequest +dotnet add package TailoredApps.Shared.Mediator.PagedRequest ``` --- @@ -27,7 +27,7 @@ dotnet add package TailoredApps.Shared.MediatR.PagedRequest ```csharp using TailoredApps.Shared.Querying; -using TailoredApps.Shared.MediatR.PagedRequest; +using TailoredApps.Shared.Mediator.PagedRequest; // 1. The filter inherits from QueryBase public class ProductFilter : QueryBase @@ -112,7 +112,7 @@ public async Task GetProducts([FromQuery] GetProductsQuery query) !!! info "Trimming and NativeAOT" The types of this package (`PagedAndSortedRequest<,,>`, `IPagedResult<>`) are safe for trimming and NativeAOT; the handler is then - registered by name - see [MediatR: Trimming and NativeAOT](index.md#trimming-and-nativeaot). The paging and sorting extensions + registered by name - see [Mediator: Trimming and NativeAOT](index.md#trimming-and-nativeaot). The paging and sorting extensions used in the example come from `TailoredApps.Shared.EntityFramework`, which is not NativeAOT-compatible (EF Core). --- @@ -121,7 +121,7 @@ public async Task GetProducts([FromQuery] GetProductsQuery query) | Type | Kind | Description | |-----|--------|------| -| `PagedAndSortedRequest` | Base class | Base MediatR request with paging and sorting | +| `PagedAndSortedRequest` | Base class | Base mediator request with paging and sorting | | `Page` | Property `int?` | Page number (1-based) | | `Count` | Property `int?` | Number of items per page | | `IsPagingSpecified` | Property `bool` | `true` when Page and Count have a value | @@ -142,9 +142,9 @@ public async Task GetProducts([FromQuery] GetProductsQuery query) ## 🤖 AI Agent Prompt ````markdown -## TailoredApps.Shared.MediatR.PagedRequest - instructions for an AI agent +## TailoredApps.Shared.Mediator.PagedRequest - instructions for an AI agent -You are using PagedAndSortedRequest as the base class for paged MediatR requests. +You are using PagedAndSortedRequest as the base class for paged mediator requests. ### Definition ```csharp diff --git a/docs-en/Libraries/MediatR/index.md b/docs-en/Libraries/Mediator/index.md similarity index 93% rename from docs-en/Libraries/MediatR/index.md rename to docs-en/Libraries/Mediator/index.md index 700b441a..b49503aa 100644 --- a/docs-en/Libraries/MediatR/index.md +++ b/docs-en/Libraries/Mediator/index.md @@ -1,13 +1,13 @@ -# TailoredApps.Shared.MediatR +# TailoredApps.Shared.Mediator -[![NuGet](https://img.shields.io/nuget/v/TailoredApps.Shared.MediatR)](https://www.nuget.org/packages/TailoredApps.Shared.MediatR/) +[![NuGet](https://img.shields.io/nuget/v/TailoredApps.Shared.Mediator)](https://www.nuget.org/packages/TailoredApps.Shared.Mediator/) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/tailored-apps/SharedComponents/blob/master/LICENSE) --- ## Description -This library provides a ready-made set of **pipeline behaviors** for MediatR that cover the most common enterprise application needs: logging, validation, caching, fallback, and retry. Instead of manually implementing these cross-cutting concerns in every handler, register them once via `PipelineRegistration` and they apply to all requests. +This library provides a ready-made set of **pipeline behaviors** for the mediator that cover the most common enterprise application needs: logging, validation, caching, fallback, and retry. Instead of manually implementing these cross-cutting concerns in every handler, register them once via `PipelineRegistration` and they apply to all requests. Behaviors execute in order: **Logging → Validation → Caching → Fallback → Retry → Handler**. @@ -18,7 +18,7 @@ The library supports auto-discovery (via Scrutor) — cache policies, fallback h ## Installation ```bash -dotnet add package TailoredApps.Shared.MediatR +dotnet add package TailoredApps.Shared.Mediator ``` --- @@ -27,9 +27,9 @@ dotnet add package TailoredApps.Shared.MediatR ```csharp // Program.cs -using TailoredApps.Shared.MediatR.DI; +using TailoredApps.Shared.Mediator.DI; -// Register MediatR +// Register the mediator builder.Services.AddMediator(cfg => cfg.RegisterServicesFromAssembly(typeof(Program).Assembly)); @@ -54,7 +54,7 @@ builder.Services.AddStackExchangeRedisCache(options => options.Configuration = " ``` !!! info "Changes in 3.0 (test phase)" - The `TailoredApps.Shared.MediatR*` libraries use [ForkForward.Mediator](https://www.nuget.org/packages/ForkForward.Mediator) - a fork of MediatR 12.5.0 under the Apache-2.0 licence - instead of the MediatR package. The types and the behaviour are the same; in the application replace `using MediatR;` with `using ForkForward.Mediator;` and `AddMediatR(...)` with `AddMediator(...)`. Details: [Upgrading to 3.0](../../Migration/v3.md). From ForkForward.Mediator 13 the library also works in an application published with NativeAOT - see [Trimming and NativeAOT](#trimming-and-nativeaot). + The `TailoredApps.Shared.Mediator*` libraries use [ForkForward.Mediator](https://www.nuget.org/packages/ForkForward.Mediator) - a fork of MediatR 12.5.0 under the Apache-2.0 licence - instead of the MediatR package. In 2.x they were named `TailoredApps.Shared.MediatR*`. The types and the behaviour are the same; in the application replace `using MediatR;` with `using ForkForward.Mediator;` and `AddMediatR(...)` with `AddMediator(...)`. Details: [Upgrading to 3.0](../../Migration/v3.md). From ForkForward.Mediator 13 the library also works in an application published with NativeAOT - see [Trimming and NativeAOT](#trimming-and-nativeaot). !!! info "Changes in 2.0" `CachingBehavior` uses `HybridCache`. The `ICache` interface and the `Cache` class are removed together with the Newtonsoft.Json dependency — delete your own `ICache` registration. Responses are serialized with System.Text.Json, and `ICachePolicy.SlidingExpiration` is no longer supported (an entry lives until it expires). After upgrading, clear the shared cache or change the key prefix: entries written by 1.x have a different format. @@ -230,9 +230,9 @@ internal sealed partial class AppJsonContext : JsonSerializerContext; ## 🤖 AI Agent Prompt ````markdown -## TailoredApps.Shared.MediatR - instructions for an AI agent +## TailoredApps.Shared.Mediator - instructions for an AI agent -You are using the TailoredApps.Shared.MediatR library with pipeline behaviors in a .NET project. +You are using the TailoredApps.Shared.Mediator library with pipeline behaviors in a .NET project. ### Registration ```csharp diff --git a/docs-en/Libraries/Querying/index.md b/docs-en/Libraries/Querying/index.md index bab246fe..d215f892 100644 --- a/docs-en/Libraries/Querying/index.md +++ b/docs-en/Libraries/Querying/index.md @@ -125,7 +125,7 @@ public async Task GetCustomersAsync( | `ISortingParameters` | Interface | `SortField`, `SortDir`, `IsSortingSpecified` | | `IQueryParameters` | Interface | Combines `IPagingParameters` + `ISortingParameters` | | `IQuery` | Interface | Query with a filter object: `Filter` | -| `IPagedAndSortedRequest` | Interface | MediatR request contract with paging (used by MediatR.PagedRequest) | +| `IPagedAndSortedRequest` | Interface | Mediator request contract with paging (used by Mediator.PagedRequest) | | `IsSortBy(string)` | Method | Case-insensitive comparison with `SortField` | | `QueryMap` | Class | A pair of expressions, `Destination` (a field of the model/DTO) and `Source` (the matching field of the entity). It only holds them - nothing in this package interprets the mapping | diff --git a/docs-en/Migration/v2.md b/docs-en/Migration/v2.md index 42b40be0..19315c22 100644 --- a/docs-en/Migration/v2.md +++ b/docs-en/Migration/v2.md @@ -154,7 +154,7 @@ Described on: [Payments](../Libraries/Payments/index.md). - `ICachePolicy.SlidingExpiration` is no longer supported, - after upgrading, clear the shared cache or change the key prefix - entries written by 1.x have a different format. -Retries and the circuit breaker no longer use Polly. Described on: [MediatR](../Libraries/MediatR/index.md). +Retries and the circuit breaker no longer use Polly. Described on: [Mediator](../Libraries/Mediator/index.md) (named MediatR in 2.x). --- diff --git a/docs-en/Migration/v3.md b/docs-en/Migration/v3.md index d2babe13..b832a60e 100644 --- a/docs-en/Migration/v3.md +++ b/docs-en/Migration/v3.md @@ -10,12 +10,28 @@ This page collects what has to be done **in application code** when moving from ## What changes -The `TailoredApps.Shared.MediatR*` libraries no longer depend on the **MediatR** package and use +The mediator libraries no longer depend on the **MediatR** package and use [**ForkForward.Mediator**](https://www.nuget.org/packages/ForkForward.Mediator) - a community fork of MediatR 12.5.0, the last version under the Apache-2.0 licence (MediatR is commercially licensed from version 13). The fork has the same types, members and behaviour, but **its own namespace and assembly**: `ForkForward.Mediator` instead of `MediatR`. -The package names and namespaces of these libraries (`TailoredApps.Shared.MediatR`, `TailoredApps.Shared.MediatR.Caching`, …) **do not change**. +### The mediator libraries are renamed + +With the MediatR package gone, the libraries drop its name as well. The packages, the assemblies and the namespaces change together: + +| 2.x | 3.0 | +|---|---| +| `TailoredApps.Shared.MediatR` | `TailoredApps.Shared.Mediator` | +| `TailoredApps.Shared.MediatR.Caching` | `TailoredApps.Shared.Mediator.Caching` | +| `TailoredApps.Shared.MediatR.Email` | `TailoredApps.Shared.Mediator.Email` | +| `TailoredApps.Shared.MediatR.PagedRequest` | `TailoredApps.Shared.Mediator.PagedRequest` | +| `TailoredApps.Shared.MediatR.ML` (namespace `TailoredApps.Shared.MediatR.ImageClassification`) | `TailoredApps.Shared.Mediator.ML` (namespace `TailoredApps.Shared.Mediator.ImageClassification`) | + +Every namespace below them follows (`TailoredApps.Shared.MediatR.DI` → `TailoredApps.Shared.Mediator.DI` and so on). Types, members and +configuration keys keep their names. + +The old package ids stay on nuget.org with their 2.x versions and get no 3.0 release. The pre-releases `3.0.0-preview.1` and +`3.0.0-preview.2` were still published under the old names. The libraries depend on **ForkForward.Mediator 13**: line 13 is published for `net10.0` and `net11.0` only (as these libraries are), its `net11.0` asset is compiled with runtime async and it works in applications published with NativeAOT. Application code sees no difference @@ -37,7 +53,7 @@ Stripe with the same block. Stripe webhook handling does not change. ### Refused requests are no longer logged as errors -- **MediatR** - `LoggingBehavior` logs a request refused by validation (`ValidationException`) at **Information** level: +- **Mediator** - `LoggingBehavior` logs a request refused by validation (`ValidationException`) at **Information** level: `Request GetProduct rejected by validation …; invalid: Id`, with the property names only (validation messages can quote the values the client sent). A request cancelled by its caller (`OperationCanceledException` while the request's token is cancelled) is Information too. Every other handler exception is Error, as before. @@ -78,11 +94,11 @@ declare in 3.0 that they are safe for trimming and NativeAOT (in a Web API: with Nothing changes for an application - request bodies and signatures are identical. Details and the list of libraries: [Trimming and NativeAOT](../Platform/index.md#trimming-and-nativeaot). -The same goes for `MediatR`, `MediatR.Caching`, `MediatR.Email` and `MediatR.PagedRequest` (on ForkForward.Mediator 13). An ordinary +The same goes for `Mediator`, `Mediator.Caching`, `Mediator.Email` and `Mediator.PagedRequest` (on ForkForward.Mediator 13). An ordinary application changes nothing: scanning and `RegisterPipelineBehaviors()` work as before. An application that is trimmed or published with NativeAOT registers handlers, behaviors and policies by name with the new methods of `PipelineRegistration` (`AddPipelineBehaviors<,>()`, `AddCachePolicy<,,>()`, `AddFallbackHandler<,,>()`, `AddRetryPolicy<,,>()`, `AddCacheSerialization(...)`) - see -[MediatR: Trimming and NativeAOT](../Libraries/MediatR/index.md#trimming-and-nativeaot). `RegisterPipelineBehaviors(assembly)` now carries +[Mediator: Trimming and NativeAOT](../Libraries/Mediator/index.md#trimming-and-nativeaot). `RegisterPipelineBehaviors(assembly)` now carries `RequiresUnreferencedCode` / `RequiresDynamicCode`: a project with the trimming analyzers on gets an `IL2026` / `IL3050` warning at the call. One behaviour change: `CashbillHttpClient.MakeFormRequest()` reads answers only as types the library has JSON metadata for - the @@ -97,13 +113,15 @@ Apart from that, the libraries have no change in 3.0 that requires code modifica | # | What to do | If skipped | |---|------------|------------| -| 1 | Remove the `MediatR` package (and `MediatR.Contracts`) from the application and add `ForkForward.Mediator` - or rely on the transitive dependency of `TailoredApps.Shared.MediatR` | Two different sets of `IRequest` / `IRequestHandler` types; handlers are not found | +| 1 | Remove the `MediatR` package (and `MediatR.Contracts`) from the application and add `ForkForward.Mediator` - or rely on the transitive dependency of `TailoredApps.Shared.Mediator` | Two different sets of `IRequest` / `IRequestHandler` types; handlers are not found | | 2 | Replace `using MediatR;` with `using ForkForward.Mediator;` (also `MediatR.Pipeline` → `ForkForward.Mediator.Pipeline` and so on) | Compile errors (CS0246) or type mismatches | | 3 | Replace `AddMediatR(...)` with `AddMediator(...)`, and `MediatRServiceConfiguration` with `MediatorServiceConfiguration` | Compile error (CS1061) | -| 4 | Raise **every** `TailoredApps.Shared.*` package to the same 3.0 version | Mixing 2.x and 3.0 puts two mediators in one process | -| 5 | Stripe: handle an outage with `catch (HttpRequestException)` and a refusal with `PaymentStatus == Rejected`; remove `catch (StripeException)` around `RegisterPayment` and `GetStatus` | A Stripe outage bypasses the old `catch (StripeException)` block, and a refusal is no longer an exception and goes unhandled | -| 6 | Review alerts and queries that count Error entries or `error.type` for 4xx answers | An alert on "validation errors" stops firing | -| 7 | Replace `UtcTimeOfDaty` with `UtcTimeOfDay`, `AddExceptionHAndlingFilterAttribute` with `AddExceptionHandlingFilterAttribute`, and the `ApiUrl` key of the PayNow and Tpay configuration with `ServiceUrl` | A compile error, or a host that does not start | +| 4 | Replace the package references `TailoredApps.Shared.MediatR*` with `TailoredApps.Shared.Mediator*` | The old packages stop at `3.0.0-preview.2`: the restore fails or quietly keeps the old pre-release | +| 5 | Replace `using TailoredApps.Shared.MediatR` with `using TailoredApps.Shared.Mediator` (every sub-namespace) | Compile error (CS0234) | +| 6 | Raise **every** `TailoredApps.Shared.*` package to the same 3.0 version | Mixing 2.x and 3.0 puts two mediators in one process | +| 7 | Stripe: handle an outage with `catch (HttpRequestException)` and a refusal with `PaymentStatus == Rejected`; remove `catch (StripeException)` around `RegisterPayment` and `GetStatus` | A Stripe outage bypasses the old `catch (StripeException)` block, and a refusal is no longer an exception and goes unhandled | +| 8 | Review alerts and queries that count Error entries or `error.type` for 4xx answers | An alert on "validation errors" stops firing | +| 9 | Replace `UtcTimeOfDaty` with `UtcTimeOfDay`, `AddExceptionHAndlingFilterAttribute` with `AddExceptionHandlingFilterAttribute`, and the `ApiUrl` key of the PayNow and Tpay configuration with `ServiceUrl` | A compile error, or a host that does not start | --- @@ -112,6 +130,7 @@ Apart from that, the libraries have no change in 3.0 that requires code modifica ```csharp // 2.x using MediatR; +using TailoredApps.Shared.MediatR.DI; builder.Services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(typeof(Program).Assembly)); @@ -130,10 +149,11 @@ public class GetProductHandler : IRequestHandler ```csharp // 3.0 using ForkForward.Mediator; +using TailoredApps.Shared.Mediator.DI; builder.Services.AddMediator(cfg => cfg.RegisterServicesFromAssembly(typeof(Program).Assembly)); -var pipeline = new PipelineRegistration(builder.Services); // the TailoredApps registration - unchanged +var pipeline = new PipelineRegistration(builder.Services); // the TailoredApps registration - the same type and methods pipeline.RegisterPipelineBehaviors(); pipeline.RegisterPipelineBehaviors(typeof(Program).Assembly); @@ -145,10 +165,11 @@ public class GetProductHandler : IRequestHandler } ``` -Only the `using` directive and the name of the method that registers the mediator change. `IRequest<>`, `IRequestHandler<,>`, +Only the `using` directives and the name of the method that registers the mediator change. `IRequest<>`, `IRequestHandler<,>`, `IPipelineBehavior<,>`, `IMediator`, `ISender`, `INotification` and the other types keep their names and members. -In a large project two replacements across the solution are enough: `using MediatR` → `using ForkForward.Mediator` and `AddMediatR(` → `AddMediator(`. +In a large project three replacements across the solution are enough: `TailoredApps.Shared.MediatR` → `TailoredApps.Shared.Mediator` +(source files and project files), `using MediatR` → `using ForkForward.Mediator` and `AddMediatR(` → `AddMediator(`. A working example on ForkForward.Mediator - the whole pipeline (validation, caching, retry, fallback) together with the other libraries - is the [demo application](../Demo/index.md). @@ -159,6 +180,9 @@ the [demo application](../Demo/index.md). - **Do not mix the two mediators.** A handler that implements `MediatR.IRequestHandler<,>` is not called by `ForkForward.Mediator.IMediator` and the other way round - they are different types. After the migration no reference to the `MediatR` package should remain in the application. +- **`Mediator` is now also a namespace.** Code whose own namespace starts with `TailoredApps.Shared.` and names the class `Mediator` of + ForkForward.Mediator by its short name stops compiling (CS0118); write `ForkForward.Mediator.Mediator` there. `IMediator`, `ISender` and the + other types are not affected, and neither is code in any other namespace. - **Third-party libraries built on MediatR** (your own packages with handlers, for example) have to be rebuilt on `ForkForward.Mediator` before they work with 3.0. - **The behaviour is that of MediatR 12.5.0** - the order of behaviours, notification publishing and registration from an assembly work the same way. - `ForkForward.Mediator` is a young package. That is why 3.0 is in a test phase: try it in one application before moving the others. @@ -169,7 +193,7 @@ the [demo application](../Demo/index.md). - **An exception the provider answers with a 4xx** no longer shows in the log at Error level. If the application maps exceptions that are really server errors to 4xx, have the provider give them a 5xx. -The libraries: [MediatR](../Libraries/MediatR/index.md). Upgrading from 1.x: [Upgrading to 2.0](v2.md). +The libraries: [Mediator](../Libraries/Mediator/index.md). Upgrading from 1.x: [Upgrading to 2.0](v2.md). --- @@ -178,14 +202,16 @@ The libraries: [MediatR](../Libraries/MediatR/index.md). Upgrading from 1.x: [Up ````markdown ## Upgrading TailoredApps.Shared.* from 2.x to 3.0 (preview) - instructions for an AI agent -You are upgrading a .NET 10 or .NET 11 application from the TailoredApps.Shared.* 2.x packages to 3.0.0-preview. The changes that need code modifications: the mediator, Stripe error handling and the removed obsolete members. +You are upgrading a .NET 10 or .NET 11 application from the TailoredApps.Shared.* 2.x packages to 3.0.0-preview. The changes that need code modifications: the mediator and the new names of its libraries, Stripe error handling and the removed obsolete members. ### Registration - Raise every TailoredApps.Shared.* package to the same 3.0.0-preview.N version - Remove references to the MediatR and MediatR.Contracts packages; add ForkForward.Mediator where needed +- Replace the package references TailoredApps.Shared.MediatR, .MediatR.Caching, .MediatR.Email, .MediatR.PagedRequest and .MediatR.ML with TailoredApps.Shared.Mediator, .Mediator.Caching, .Mediator.Email, .Mediator.PagedRequest and .Mediator.ML - Replace builder.Services.AddMediatR(...) with builder.Services.AddMediator(...) ### What needs code changes +- using TailoredApps.Shared.MediatR... -> using TailoredApps.Shared.Mediator... (every sub-namespace, e.g. .DI, .PipelineBehaviours, .ImageClassification) - using MediatR; -> using ForkForward.Mediator; (and MediatR.Pipeline -> ForkForward.Mediator.Pipeline and so on) - MediatRServiceConfiguration -> MediatorServiceConfiguration - The names and members of IRequest, IRequestHandler, IPipelineBehavior, IMediator, ISender, INotification do not change @@ -197,8 +223,9 @@ You are upgrading a .NET 10 or .NET 11 application from the TailoredApps.Shared. - No new configuration keys ### Rules -- After the migration no reference to the MediatR package or namespace may remain in the solution -- Do not rename the TailoredApps.Shared.MediatR.* namespaces - they are library names, not the MediatR package +- After the migration no reference to the MediatR package or namespace may remain in the solution, TailoredApps.Shared.MediatR* included +- Only package ids and namespaces are renamed: do not rename types or members of the TailoredApps libraries +- In code whose namespace starts with TailoredApps.Shared. write ForkForward.Mediator.Mediator for the Mediator class (CS0118 otherwise) - Do not mix TailoredApps.Shared.* packages of versions 2.x and 3.0 in one application - 3.0 is a pre-release: do not deploy it to production without an explicit decision of the application owner ```` diff --git a/docs-en/Platform/index.md b/docs-en/Platform/index.md index 549a134a..31e5d98f 100644 --- a/docs-en/Platform/index.md +++ b/docs-en/Platform/index.md @@ -11,7 +11,7 @@ Every `TailoredApps.Shared.*` package is built for several target frameworks at | Libraries | Target frameworks | |---|---| -| `DateTime`, `Email`, `Email.Models`, `Email.Office365`, `EntityFramework`, `EntityFramework.UnitOfWork.MinimalApi`, `EntityFramework.UnitOfWork.WebApiCore`, `ExceptionHandling`, `ExceptionHandling.MinimalApi`, `MediatR`, `MediatR.Caching`, `MediatR.Email`, `MediatR.ML`, `MediatR.PagedRequest`, `Payments` and every payment provider, `Querying`, `WebApi` | `net10.0`, `net11.0` | +| `DateTime`, `Email`, `Email.Models`, `Email.Office365`, `EntityFramework`, `EntityFramework.UnitOfWork.MinimalApi`, `EntityFramework.UnitOfWork.WebApiCore`, `ExceptionHandling`, `ExceptionHandling.MinimalApi`, `Mediator`, `Mediator.Caching`, `Mediator.Email`, `Mediator.ML`, `Mediator.PagedRequest`, `Payments` and every payment provider, `Querying`, `WebApi` | `net10.0`, `net11.0` | !!! info "Version 2.0 and older frameworks" From version **2.0** every library targets `net10.0` and `net11.0` only. Applications on `net8.0`, `net9.0`, @@ -45,7 +45,7 @@ The libraries in this repository use it in their `net11.0` assets: - **No environment variables** and no `` are needed. !!! warning "Requires CoreCLR or NativeAOT" - Runtime async works on CoreCLR and NativeAOT. The Mono runtime — used by **Blazor WebAssembly**, among others — cannot execute such methods in .NET 11. If you want to use one of the libraries that contain `async` code on the Blazor WebAssembly client side on `net11.0`, build it with runtime async switched off (see below). `DateTime`, `Email.Models`, `MediatR.Caching` and `Querying` contain no `async` code and are not affected. + Runtime async works on CoreCLR and NativeAOT. The Mono runtime — used by **Blazor WebAssembly**, among others — cannot execute such methods in .NET 11. If you want to use one of the libraries that contain `async` code on the Blazor WebAssembly client side on `net11.0`, build it with runtime async switched off (see below). `DateTime`, `Email.Models`, `Mediator.Caching` and `Querying` contain no `async` code and are not affected. !!! info "Feature status" In .NET 11 runtime async is an opt-in feature that Microsoft's documentation still describes as a preview: [What's new in the .NET 11 runtime](https://learn.microsoft.com/dotnet/core/whats-new/dotnet-11/runtime). @@ -88,9 +88,9 @@ and their code works once compiled to native code. |---|---| | `DateTime`, `Querying`, `Email.Models`, `Payments`, `Payments.Provider.Adyen`, `.CashBill`, `.HotPay`, `.PayNow`, `.PayU`, `.Przelewy24`, `.Revolut`, `.Tpay` | **Compatible.** Checked natively in CI on `net10.0` and `net11.0`, on Linux and Windows | | `Email`, `ExceptionHandling`, `ExceptionHandling.MinimalApi`, `WebApi` | **Compatible** in a minimal-API application (see below). The MVC filter of `ExceptionHandling` does not apply: ASP.NET Core does not support controllers under NativeAOT | -| `MediatR`, `MediatR.Caching`, `MediatR.Email`, `MediatR.PagedRequest` | **Compatible** (on ForkForward.Mediator 13) when handlers, behaviors and policies are registered by name instead of by scanning - see [MediatR: Trimming and NativeAOT](../Libraries/MediatR/index.md#trimming-and-nativeaot). An application that caches responses gets warnings from `Microsoft.Extensions.Caching.Hybrid` itself; the cache works natively | +| `Mediator`, `Mediator.Caching`, `Mediator.Email`, `Mediator.PagedRequest` | **Compatible** (on ForkForward.Mediator 13) when handlers, behaviors and policies are registered by name instead of by scanning - see [Mediator: Trimming and NativeAOT](../Libraries/Mediator/index.md#trimming-and-nativeaot). An application that caches responses gets warnings from `Microsoft.Extensions.Caching.Hybrid` itself; the cache works natively | | `EntityFramework`, `EntityFramework.UnitOfWork.WebApiCore`, `EntityFramework.UnitOfWork.MinimalApi` | Not compatible: EF Core builds its model and queries at run time; change auditing creates types with `MakeGenericType` | -| `Email.Office365`, `MediatR.ML`, `Payments.Provider.Stripe` | Not compatible: their dependencies (Microsoft.Identity.Web, ML.NET, Stripe.net) rely on reflection | +| `Email.Office365`, `Mediator.ML`, `Payments.Provider.Stripe` | Not compatible: their dependencies (Microsoft.Identity.Web, ML.NET, Stripe.net) rely on reflection | ### Web API: minimal APIs yes, controllers no @@ -130,7 +130,7 @@ Minimal APIs have packages of their own with the counterparts of the MVC filters signatures are identical byte for byte. The same goes for the error response of `ExceptionHandling`. - **Container registrations** with a generic parameter (`RegisterPaymentProvider()`, `AddPayments<,>()`, `AddExceptionHandlingForWebApi<,>()`) carry annotations that make the trimmer keep the constructors dependency injection calls. -- **MediatR** has registration without scanning (`AddPipelineBehaviors<,>()`, `AddCachePolicy<,,>()`, `AddFallbackHandler<,,>()`, +- **Mediator** has registration without scanning (`AddPipelineBehaviors<,>()`, `AddCachePolicy<,,>()`, `AddFallbackHandler<,,>()`, `AddRetryPolicy<,,>()`), cached responses serialized with generated metadata (`AddCacheSerialization`) and a cache key built from a `JsonTypeInfo`. Assembly scanning stays for ordinary applications and is marked `RequiresUnreferencedCode`. @@ -227,14 +227,14 @@ You are working with TailoredApps.Shared.* packages or with the SharedComponents in both conditional groups: 10.* and 11.*); test project under tests/. - Build the repository with .NET SDK 11.0.100 or newer. - Safe for trimming and NativeAOT (IsAotCompatible): DateTime, Querying, Email, Email.Models, ExceptionHandling, - ExceptionHandling.MinimalApi, WebApi, MediatR, MediatR.Caching, MediatR.Email, MediatR.PagedRequest, + ExceptionHandling.MinimalApi, WebApi, Mediator, Mediator.Caching, Mediator.Email, Mediator.PagedRequest, Payments and the providers Adyen, CashBill, HotPay, PayNow, PayU, Przelewy24, Revolut, Tpay. - NativeAOT in ASP.NET Core means minimal APIs: MVC controllers do not work natively (their routes answer 404). [Authorize] and JWT do. - Blazor WebAssembly on net11.0 does not execute runtime-async methods (PlatformNotSupportedException): do not call the async methods of the libraries from the net11.0 asset there. IL2xxx/IL3xxx warnings are compile errors there: no reflection, no JsonSerializer without a JsonTypeInfo, no ConfigurationBinder outside the generator. -- The EntityFramework*, Email.Office365, MediatR.ML and Payments.Provider.Stripe libraries are not +- The EntityFramework*, Email.Office365, Mediator.ML and Payments.Provider.Stripe libraries are not NativeAOT-compatible - do not suggest them for an application published with PublishAot. -- MediatR in an application with PublishAot: no scanning - cfg.AddRequestHandler<,,>() for handlers, AddPipelineBehaviors<,>() for +- Mediator in an application with PublishAot: no scanning - cfg.AddRequestHandler<,,>() for handlers, AddPipelineBehaviors<,>() for every request, AddCachePolicy / AddFallbackHandler / AddRetryPolicy, AddCacheSerialization(context) and your own GetCacheKey. ``` diff --git a/docs-en/Security/index.md b/docs-en/Security/index.md index 150f3d59..d08e64fe 100644 --- a/docs-en/Security/index.md +++ b/docs-en/Security/index.md @@ -3,6 +3,8 @@ This page records the security review of the shared libraries performed on 2 September 2026, the fixes that shipped with it, and the items that still need a human decision. +The libraries are named as they were on the day of the review: `MediatR` and `MediatR.ML` are `Mediator` and `Mediator.ML` from 3.0. + ## Scope and method - Every library under `src/` (25 projects, about 12 000 lines of C#), the test projects, the diff --git a/docs-en/contributing.md b/docs-en/contributing.md index b156c8f4..6d897bf0 100644 --- a/docs-en/contributing.md +++ b/docs-en/contributing.md @@ -169,8 +169,8 @@ You are using the TailoredApps.Shared.XXXXX library in a .NET project. ## Public API compatibility The `master` branch is the **3.0 line in a test phase** (`3.0.0-preview.N`): breaking changes are allowed until `3.0.0`, but only on -purpose. The `release/2.1` branch is the 2.1.x fix line, compatible with `2.0.0`. On `master` the `TailoredApps.Shared.MediatR*` libraries are -left out of the comparison (they moved from MediatR to ForkForward.Mediator); the others are still compared, so that a breaking change does +purpose. The `release/2.1` branch is the 2.1.x fix line, compatible with `2.0.0`. On `master` the `TailoredApps.Shared.Mediator*` libraries are +left out of the comparison (they moved from MediatR to ForkForward.Mediator and were renamed from `TailoredApps.Shared.MediatR*`); the others are still compared, so that a breaking change does not happen by accident. The 2.x line must stay compatible with `2.0.0`: code compiled against any 2.x version has to work with every later 2.x. The diff --git a/docs-en/index.md b/docs-en/index.md index 2c2520a9..9b3e01c2 100644 --- a/docs-en/index.md +++ b/docs-en/index.md @@ -3,7 +3,7 @@ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/tailored-apps/SharedComponents/blob/master/LICENSE) [![GitHub](https://img.shields.io/badge/GitHub-SharedComponents-181717?logo=github)](https://github.com/tailored-apps/SharedComponents) -Welcome to the documentation of **TailoredApps Shared Components** — a set of reusable .NET libraries that accelerate the development of professional web applications. Each library solves one specific problem and is designed for testability, extensibility, and integration with the ASP.NET Core + MediatR ecosystem. +Welcome to the documentation of **TailoredApps Shared Components** — a set of reusable .NET libraries that accelerate the development of professional web applications. Each library solves one specific problem and is designed for testability, extensibility, and integration with the ASP.NET Core + mediator ecosystem. --- @@ -20,11 +20,11 @@ Welcome to the documentation of **TailoredApps Shared Components** — a set of | [EntityFramework.UnitOfWork.MinimalApi](Libraries/EntityFramework/UnitOfWork.MinimalApi.md) | `TailoredApps.Shared.EntityFramework.UnitOfWork.MinimalApi` | Automatic transactions for minimal APIs through an endpoint filter | | [ExceptionHandling](Libraries/ExceptionHandling/index.md) | `TailoredApps.Shared.ExceptionHandling` | Middleware and filter for exception handling in Web API | | [ExceptionHandling.MinimalApi](Libraries/ExceptionHandling/MinimalApi.md) | `TailoredApps.Shared.ExceptionHandling.MinimalApi` | Exception handling and FluentValidation for minimal APIs (endpoint filters), NativeAOT-compatible | -| [MediatR](Libraries/MediatR/index.md) | `TailoredApps.Shared.MediatR` | Pipeline behaviors: Logging, Validation, Caching, Fallback, Retry | -| [MediatR.Caching](Libraries/MediatR/Caching.md) | `TailoredApps.Shared.MediatR.Caching` | `ICachableRequest` marker interface for caching requests | -| [MediatR.Email](Libraries/MediatR/Email.md) | `TailoredApps.Shared.MediatR.Email` | `SendMail` command + handler — email via MediatR pipeline | -| [MediatR.ML](Libraries/MediatR/ML.md) | `TailoredApps.Shared.MediatR.ML` | Image classification via ML.NET in MediatR pipelines | -| [MediatR.PagedRequest](Libraries/MediatR/PagedRequest.md) | `TailoredApps.Shared.MediatR.PagedRequest` | Base MediatR request with pagination and sorting | +| [Mediator](Libraries/Mediator/index.md) | `TailoredApps.Shared.Mediator` | Pipeline behaviors: Logging, Validation, Caching, Fallback, Retry | +| [Mediator.Caching](Libraries/Mediator/Caching.md) | `TailoredApps.Shared.Mediator.Caching` | `ICachableRequest` marker interface for caching requests | +| [Mediator.Email](Libraries/Mediator/Email.md) | `TailoredApps.Shared.Mediator.Email` | `SendMail` command + handler — email via the mediator pipeline | +| [Mediator.ML](Libraries/Mediator/ML.md) | `TailoredApps.Shared.Mediator.ML` | Image classification via ML.NET in mediator pipelines | +| [Mediator.PagedRequest](Libraries/Mediator/PagedRequest.md) | `TailoredApps.Shared.Mediator.PagedRequest` | Base mediator request with pagination and sorting | | [Payments](Libraries/Payments/index.md) | `TailoredApps.Shared.Payments` | Payment gateway abstraction — IPaymentService + IPaymentProvider | | [Payments.Provider.Adyen](Libraries/Payments/Providers/Adyen.md) | `TailoredApps.Shared.Payments.Provider.Adyen` | Adyen integration | | [Payments.Provider.CashBill](Libraries/Payments/Providers/CashBill.md) | `TailoredApps.Shared.Payments.Provider.CashBill` | CashBill integration | @@ -52,7 +52,7 @@ HTTP in CI. Moving from 1.x to 2.0? The changes required in application code - handling a failing payment gateway, the required members of `PaymentRequest`, Tpay and Adyen webhooks - are collected on the [Upgrading to 2.0](Migration/v2.md) page. -The **3.0** line is in a test phase (`3.0.0-preview.N`): the MediatR libraries move to ForkForward.Mediator. What to change in an application: [Upgrading to 3.0](Migration/v3.md). +The **3.0** line is in a test phase (`3.0.0-preview.N`): the mediator libraries move to ForkForward.Mediator and are renamed from `TailoredApps.Shared.MediatR*` to `TailoredApps.Shared.Mediator*`. What to change in an application: [Upgrading to 3.0](Migration/v3.md). --- @@ -66,7 +66,7 @@ From version 2.0 the libraries ship for `net10.0` and `net11.0`; older framework ```bash # Install the chosen library -dotnet add package TailoredApps.Shared.MediatR +dotnet add package TailoredApps.Shared.Mediator dotnet add package TailoredApps.Shared.EntityFramework dotnet add package TailoredApps.Shared.Payments ``` diff --git a/docs/Demo/index.md b/docs/Demo/index.md index 0d118639..11aa6637 100644 --- a/docs/Demo/index.md +++ b/docs/Demo/index.md @@ -1,7 +1,7 @@ # Przykładowy serwis i testy integracyjne !!! info "Linia 3.0 (faza testowa)" - Przykład jest w repozytorium od linii 3.0 (`master`) i korzysta z bibliotek MediatR na **ForkForward.Mediator** + Przykład jest w repozytorium od linii 3.0 (`master`) i korzysta z bibliotek Mediator na **ForkForward.Mediator** (zob. [Aktualizacja do 3.0](../Migration/v3.md)). Nie jest paczką NuGet — nie trafia na nuget.org. W `samples/` jest mały sklep zbudowany tak, jak budujemy prawdziwy serwis: kontrakt, logika i host HTTP, a wokół nich klient @@ -43,7 +43,7 @@ dotnet test tests/TailoredApps.Shared.IntegrationTests/TailoredApps.Shared.Integ | Projekt | Co zawiera | Od czego zależy | |---|---|---| -| `TailoredApps.Shared.Demo.DataModel` | Kontrakt. Dla każdej funkcji (`Catalog`, `Orders`): `Messages/Commands`, `Messages/Queries`, `Messages/Notifications`, `Responses/…`, `Model` | kontrakty mediatora, `MediatR.PagedRequest`, `MediatR.Caching`, `Payments` — bez EF Core i bez handlerów | +| `TailoredApps.Shared.Demo.DataModel` | Kontrakt. Dla każdej funkcji (`Catalog`, `Orders`): `Messages/Commands`, `Messages/Queries`, `Messages/Notifications`, `Responses/…`, `Model` | kontrakty mediatora, `Mediator.PagedRequest`, `Mediator.Caching`, `Payments` — bez EF Core i bez handlerów | | `TailoredApps.Shared.Demo.Services` | Logika. Dla każdej funkcji: `Entities`, `Handlers` (każdy z interfejsem w `Interfaces/Handlers`), `Infrastructure` (repozytoria na unit of work, za `Interfaces/Infrastructure`), `Validation`, `Policies` (cache, retry, fallback), `Processing` (pre- i post-procesory, akcja i handler wyjątku, behavior strumienia), `Exceptions`, mapowanie EF (`IModelBuilder`) i profil mappera. W katalogu głównym `ShopDataContext` | `DataModel`, EF Core, biblioteki — nic z ASP.NET Core | | `TailoredApps.Shared.Demo.WebApi` | Host. `Program` (buduje, zasila bazę, uruchamia) i `Startup` (`ConfigureServices`, `Configure`), `Controllers`, `Endpoints` (minimal API), `Authentication`, `ExceptionHandling`. Serwuje też pliki klienta | oba powyższe i każda biblioteka | | `TailoredApps.Shared.Demo.Client` | Klient w przeglądarce: Blazor WebAssembly z MudBlazor, bez własnego JavaScriptu. `Pages` (katalog, produkt, koszyk, zamówienie), `Services` (`ShopApi`, `Session`, `Basket`) | tylko `DataModel` — komunikaty i odpowiedzi to typy serwera | @@ -64,12 +64,12 @@ wycofuje; **provider wyjątków** nadaje kształt błędowi. Żadna warstwa nie | [ExceptionHandling](../Libraries/ExceptionHandling/index.md) | `ShopExceptionHandlingProvider`: `ShopException` odpowiada własnym statusem i komunikatem, reszta domyślnie | `GET /api/products/999` (404), duplikat produktu (409) | | [EntityFramework](../Libraries/EntityFramework/index.md), [UnitOfWork.WebApiCore](../Libraries/EntityFramework/UnitOfWork.WebApiCore.md) | `ShopDataContext` z jednym `IModelBuilder` na funkcję, repozytoria na `IUnitOfWork`, filtr transakcji | `POST /api/orders` z nieistniejącym produktem: 400 i nic nie zostaje w bazie | | [UnitOfWork.MinimalApi](../Libraries/EntityFramework/UnitOfWork.MinimalApi.md), [ExceptionHandling.MinimalApi](../Libraries/ExceptionHandling/MinimalApi.md) | `Endpoints/ProductEndpoints.cs`: grupa z `WithExceptionHandling()`, `WithUnitOfWorkTransaction()` i `WithValidation()`, wysyłająca te same komunikaty | `POST /api/minimal/products`, `GET /api/minimal/products/{name}` | -| [Querying](../Libraries/Querying/index.md), [MediatR.PagedRequest](../Libraries/MediatR/PagedRequest.md) | `GetProducts` z `ProductFilter`; w `ProductRepository`: `ApplySorting` z listą dozwolonych pól, `ProjectTo` mappera, `PagingAsync` | `GET /api/products?page=1&count=3&sortField=Price&sortDir=Desc&filter.category=tea` | -| [MediatR](../Libraries/MediatR/index.md), [MediatR.Caching](../Libraries/MediatR/Caching.md) | pięć behaviorów wokół każdego requestu; `GetProduct` (polityka cache), `GetRecommendations` (retry, fallback) | `GET /api/products/1`, `GET /api/products/0`, `GET /api/products/1/recommendations` | +| [Querying](../Libraries/Querying/index.md), [Mediator.PagedRequest](../Libraries/Mediator/PagedRequest.md) | `GetProducts` z `ProductFilter`; w `ProductRepository`: `ApplySorting` z listą dozwolonych pól, `ProjectTo` mappera, `PagingAsync` | `GET /api/products?page=1&count=3&sortField=Price&sortDir=Desc&filter.category=tea` | +| [Mediator](../Libraries/Mediator/index.md), [Mediator.Caching](../Libraries/Mediator/Caching.md) | pięć behaviorów wokół każdego requestu; `GetProduct` (polityka cache), `GetRecommendations` (retry, fallback) | `GET /api/products/1`, `GET /api/products/0`, `GET /api/products/1/recommendations` | | [Payments](../Libraries/Payments/index.md) + 9 providerów | `AddPayments().Register…Provider()`, `CheckoutOrderCommandHandler`, `ReceivePaymentNotificationCommandHandler` | `POST /api/orders/{number}/checkout`, `POST /api/webhooks/{provider}`, `GET /api/payments/providers` | -| [Email](../Libraries/Email/index.md), [Email.Models](../Libraries/Email/Models.md), [MediatR.Email](../Libraries/MediatR/Email.md) | `SendOrderConfirmation`: `SendMail` z szablonem `EmailTemplates/order-confirmation.html`, provider konsolowy | wiadomość na konsoli po opłaceniu zamówienia | +| [Email](../Libraries/Email/index.md), [Email.Models](../Libraries/Email/Models.md), [Mediator.Email](../Libraries/Mediator/Email.md) | `SendOrderConfirmation`: `SendMail` z szablonem `EmailTemplates/order-confirmation.html`, provider konsolowy | wiadomość na konsoli po opłaceniu zamówienia | | [Email.Office365](../Libraries/Email/Office365.md) | `GET /api/inbox` — tylko z `Demo:Office365Inbox` i aplikacją Azure AD | bez konfiguracji: 501 | -| [MediatR.ML](../Libraries/MediatR/ML.md) | `POST /api/images/classify` — tylko z `ImageClassification:ModelFilePath` | bez modelu: 501 | +| [Mediator.ML](../Libraries/Mediator/ML.md) | `POST /api/images/classify` — tylko z `ImageClassification:ModelFilePath` | bez modelu: 501 | --- diff --git a/docs/Libraries/MediatR/Caching.md b/docs/Libraries/Mediator/Caching.md similarity index 68% rename from docs/Libraries/MediatR/Caching.md rename to docs/Libraries/Mediator/Caching.md index a29792d4..ced6ad2a 100644 --- a/docs/Libraries/MediatR/Caching.md +++ b/docs/Libraries/Mediator/Caching.md @@ -1,22 +1,22 @@ -# TailoredApps.Shared.MediatR.Caching +# TailoredApps.Shared.Mediator.Caching -[![NuGet](https://img.shields.io/nuget/v/TailoredApps.Shared.MediatR.Caching)](https://www.nuget.org/packages/TailoredApps.Shared.MediatR.Caching/) +[![NuGet](https://img.shields.io/nuget/v/TailoredApps.Shared.Mediator.Caching)](https://www.nuget.org/packages/TailoredApps.Shared.Mediator.Caching/) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/tailored-apps/SharedComponents/blob/master/LICENSE) --- ## Opis -Lekki pakiet definiujący `ICachableRequest` — kontrakt dla requestów MediatR, które same podają swój klucz cache. Request implementujący ten interfejs dostarcza metodę `GetCacheKey()`, która generuje unikalny klucz cache dla danej instancji zapytania. +Lekki pakiet definiujący `ICachableRequest` — kontrakt dla requestów mediatora, które same podają swój klucz cache. Request implementujący ten interfejs dostarcza metodę `GetCacheKey()`, która generuje unikalny klucz cache dla danej instancji zapytania. -Pakiet zawiera wyłącznie kontrakt: nie ma serwisów ani niczego do zarejestrowania. `CachingBehavior` z pakietu `TailoredApps.Shared.MediatR` **nie** czyta `ICachableRequest` — cache'uje request tylko wtedy, gdy jest dla niego zarejestrowana `ICachePolicy`. Używaj interfejsu, żeby trzymać logikę klucza w samym requeście, a gdy odpowiedź ma być cache'owana przez ten behavior, dodaj politykę cache zwracającą ten klucz (przykład niżej). +Pakiet zawiera wyłącznie kontrakt: nie ma serwisów ani niczego do zarejestrowania. `CachingBehavior` z pakietu `TailoredApps.Shared.Mediator` **nie** czyta `ICachableRequest` — cache'uje request tylko wtedy, gdy jest dla niego zarejestrowana `ICachePolicy`. Używaj interfejsu, żeby trzymać logikę klucza w samym requeście, a gdy odpowiedź ma być cache'owana przez ten behavior, dodaj politykę cache zwracającą ten klucz (przykład niżej). --- ## Instalacja ```bash -dotnet add package TailoredApps.Shared.MediatR.Caching +dotnet add package TailoredApps.Shared.Mediator.Caching ``` --- @@ -24,7 +24,7 @@ dotnet add package TailoredApps.Shared.MediatR.Caching ## Przykład użycia ```csharp -using TailoredApps.Shared.MediatR.Caching; +using TailoredApps.Shared.Mediator.Caching; using ForkForward.Mediator; // Request z wbudowaną logiką cache key @@ -37,7 +37,7 @@ public class GetUserProfileQuery : ICachableRequest public string GetCacheKey() => $"user-profile:{UserId}:{Language}"; } -// Handler — standardowy MediatR +// Handler — zwykły handler requestu public class GetUserProfileQueryHandler : IRequestHandler { private readonly IUserRepository _repo; @@ -55,7 +55,7 @@ public class GetUserProfileQueryHandler : IRequestHandler @@ -65,12 +65,12 @@ public class GetUserProfileQueryCachePolicy : ICachePolicy` (polityki skanuje `PipelineRegistration.RegisterPipelineBehaviors(assembly)`). Bez polityki powyższy request za każdym razem wykonuje handler. + `ICachableRequest` to marker interface — sam w sobie nie uruchamia cache'owania, a `CachingBehavior` z pakietu `TailoredApps.Shared.Mediator` nie bierze go pod uwagę. Request jest cache'owany tylko wtedy, gdy jest dla niego zarejestrowana `ICachePolicy` (polityki skanuje `PipelineRegistration.RegisterPipelineBehaviors(assembly)`). Bez polityki powyższy request za każdym razem wykonuje handler. !!! info "Trimming i NativeAOT" Pakiet zawiera sam kontrakt i jest zgodny z trimmingiem i NativeAOT. W takiej aplikacji polityka zwracająca `request.GetCacheKey()` jest też najprostszym sposobem na klucz cache: domyślny klucz `ICachePolicy` wymaga refleksji. Politykę rejestruje się po nazwie - (`AddCachePolicy<,,>()`) — zob. [MediatR: Trimming i NativeAOT](index.md#trimming-i-nativeaot). + (`AddCachePolicy<,,>()`) — zob. [Mediator: Trimming i NativeAOT](index.md#trimming-i-nativeaot). --- @@ -86,9 +86,9 @@ public class GetUserProfileQueryCachePolicy : ICachePolicy public string GetCacheKey() => $"product:{Id}"; } -// Potrzebne, żeby CachingBehavior (TailoredApps.Shared.MediatR) cache'ował request: +// Potrzebne, żeby CachingBehavior (TailoredApps.Shared.Mediator) cache'ował request: public class GetProductQueryCachePolicy : ICachePolicy { public string GetCacheKey(GetProductQuery request) => request.GetCacheKey(); @@ -111,7 +111,7 @@ public class GetProductQueryCachePolicy : ICachePolicy rozszerza IRequest - GetCacheKey() musi zwracać unikalny klucz dla tej kombinacji parametrów -- Sam interfejs nie cache'uje, a CachingBehavior z TailoredApps.Shared.MediatR go nie czyta +- Sam interfejs nie cache'uje, a CachingBehavior z TailoredApps.Shared.Mediator go nie czyta - CachingBehavior cache'uje tylko requesty z zarejestrowaną ICachePolicy — dodaj politykę zwracającą request.GetCacheKey() - Aplikacja z PublishAot: politykę rejestruj po nazwie — new PipelineRegistration(services).AddCachePolicy() — skanowanie nie jest tam dostępne ```` diff --git a/docs/Libraries/MediatR/Email.md b/docs/Libraries/Mediator/Email.md similarity index 75% rename from docs/Libraries/MediatR/Email.md rename to docs/Libraries/Mediator/Email.md index 66d83c94..1be43e8e 100644 --- a/docs/Libraries/MediatR/Email.md +++ b/docs/Libraries/Mediator/Email.md @@ -1,13 +1,13 @@ -# TailoredApps.Shared.MediatR.Email +# TailoredApps.Shared.Mediator.Email -[![NuGet](https://img.shields.io/nuget/v/TailoredApps.Shared.MediatR.Email)](https://www.nuget.org/packages/TailoredApps.Shared.MediatR.Email/) +[![NuGet](https://img.shields.io/nuget/v/TailoredApps.Shared.Mediator.Email)](https://www.nuget.org/packages/TailoredApps.Shared.Mediator.Email/) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/tailored-apps/SharedComponents/blob/master/LICENSE) --- ## Opis -Integracja wysyłania emaili z pipeline MediatR. Biblioteka dostarcza command `SendMail` oraz jego handler `SendMailCommandHandler`, dzięki czemu wysyłka emaila staje się naturalną częścią architektury CQRS — możesz wysłać email przez `_mediator.Send(new SendMail { ... })` bez bezpośredniej zależności od `IEmailProvider`. +Integracja wysyłania emaili z pipeline'em mediatora. Biblioteka dostarcza command `SendMail` oraz jego handler `SendMailCommandHandler`, dzięki czemu wysyłka emaila staje się naturalną częścią architektury CQRS — możesz wysłać email przez `_mediator.Send(new SendMail { ... })` bez bezpośredniej zależności od `IEmailProvider`. To podejście umożliwia łatwe wzbogacenie procesu wysyłki o logowanie, retry i auditing z poziomu pipeline behaviors, bez modyfikowania handlera. @@ -16,7 +16,7 @@ To podejście umożliwia łatwe wzbogacenie procesu wysyłki o logowanie, retry ## Instalacja ```bash -dotnet add package TailoredApps.Shared.MediatR.Email +dotnet add package TailoredApps.Shared.Mediator.Email ``` --- @@ -26,7 +26,7 @@ dotnet add package TailoredApps.Shared.MediatR.Email ```csharp // Program.cs using TailoredApps.Shared.Email; -using TailoredApps.Shared.MediatR.Email.Handlers; +using TailoredApps.Shared.Mediator.Email.Handlers; using TailoredApps.Shared.Email.MailMessageBuilder; // 1. Zarejestruj email provider (SMTP lub konsola) @@ -40,7 +40,7 @@ builder.Services.Configure(o => o.FileExtension = "html"; }); -// 3. MediatR: przeskanuj także assembly biblioteki — tam znajduje się SendMailCommandHandler +// 3. Mediator: przeskanuj także assembly biblioteki — tam znajduje się SendMailCommandHandler builder.Services.AddMediator(cfg => { cfg.RegisterServicesFromAssembly(typeof(Program).Assembly); @@ -48,7 +48,7 @@ builder.Services.AddMediator(cfg => }); ``` -Pakiet nie ma własnej metody rejestrującej. MediatR rozwiązuje handler jako `IRequestHandler`, więc rejestracja `SendMailCommandHandler` wyłącznie pod `ISendMailCommandHandler` nie wystarczy, żeby `_mediator.Send(new SendMail { ... })` go znalazł. Przeskanuj assembly biblioteki jak wyżej albo samodzielnie zarejestruj handler pod interfejsem MediatR: +Pakiet nie ma własnej metody rejestrującej. Mediator rozwiązuje handler jako `IRequestHandler`, więc rejestracja `SendMailCommandHandler` wyłącznie pod `ISendMailCommandHandler` nie wystarczy, żeby `_mediator.Send(new SendMail { ... })` go znalazł. Przeskanuj assembly biblioteki jak wyżej albo samodzielnie zarejestruj handler pod interfejsem mediatora: ```csharp builder.Services.AddTransient, SendMailCommandHandler>(); @@ -62,14 +62,14 @@ builder.Services.AddMediator(cfg => ``` Biblioteka jest zgodna z NativeAOT razem z providerem SMTP i konsolowym z `TailoredApps.Shared.Email`; provider `Email.Office365` nie jest. -Pozostałe zasady: [MediatR: Trimming i NativeAOT](index.md#trimming-i-nativeaot). +Pozostałe zasady: [Mediator: Trimming i NativeAOT](index.md#trimming-i-nativeaot). --- ## Przykład użycia ```csharp -using TailoredApps.Shared.MediatR.Email.Messages.Commands; +using TailoredApps.Shared.Mediator.Email.Messages.Commands; public class UserRegistrationService { @@ -81,7 +81,7 @@ public class UserRegistrationService { // Logika rejestracji... - // Wyślij email powitalny przez MediatR pipeline + // Wyślij email powitalny przez pipeline mediatora var result = await _mediator.Send(new SendMail { Recipent = email, @@ -137,9 +137,9 @@ public class UserRegistrationService ## 🤖 AI Agent Prompt ````markdown -## TailoredApps.Shared.MediatR.Email — Instrukcja dla agenta AI +## TailoredApps.Shared.Mediator.Email — Instrukcja dla agenta AI -Używasz TailoredApps.Shared.MediatR.Email do wysyłania emaili przez MediatR pipeline. +Używasz TailoredApps.Shared.Mediator.Email do wysyłania emaili przez pipeline mediatora. ### Rejestracja ```csharp @@ -166,7 +166,7 @@ var result = await _mediator.Send(new SendMail ``` ### Zasady -- MediatR musi znaleźć handler jako IRequestHandler: przeskanuj assembly biblioteki; sama rejestracja jako ISendMailCommandHandler nie wystarczy +- Mediator musi znaleźć handler jako IRequestHandler: przeskanuj assembly biblioteki; sama rejestracja jako ISendMailCommandHandler nie wystarczy - Template i Recipent są wymagane — handler rzuca ArgumentException, gdy któreś jest null - Template to klucz szablonu przekazywany do IMailMessageBuilder.Build() - TemplateVariables zastępują {{token}} w szablonie diff --git a/docs/Libraries/MediatR/ML.md b/docs/Libraries/Mediator/ML.md similarity index 86% rename from docs/Libraries/MediatR/ML.md rename to docs/Libraries/Mediator/ML.md index b1afd2a8..114bd048 100644 --- a/docs/Libraries/MediatR/ML.md +++ b/docs/Libraries/Mediator/ML.md @@ -1,13 +1,13 @@ -# TailoredApps.Shared.MediatR.ML +# TailoredApps.Shared.Mediator.ML -[![NuGet](https://img.shields.io/nuget/v/TailoredApps.Shared.MediatR.ML)](https://www.nuget.org/packages/TailoredApps.Shared.MediatR.ML/) +[![NuGet](https://img.shields.io/nuget/v/TailoredApps.Shared.Mediator.ML)](https://www.nuget.org/packages/TailoredApps.Shared.Mediator.ML/) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/tailored-apps/SharedComponents/blob/master/LICENSE) --- ## Opis -Biblioteka integruje klasyfikację obrazów przez **ML.NET** z pipeline MediatR. Dostarcza gotowe komendy (`ClassifyImage`, `TrainImageClassificationModel`) i ich handlery, dzięki czemu klasyfikacja obrazów staje się pełnoprawnym elementem architektury CQRS. +Biblioteka integruje klasyfikację obrazów przez **ML.NET** z pipeline'em mediatora. Dostarcza gotowe komendy (`ClassifyImage`, `TrainImageClassificationModel`) i ich handlery, dzięki czemu klasyfikacja obrazów staje się pełnoprawnym elementem architektury CQRS. Pod spodem działa `ImageClassificationService` oparty na ML.NET z poolem silników predykcji (`PredictionEnginePool`) dla wydajnej współbieżnej inferencji. Biblioteka obsługuje też trening modelu z poziomu aplikacji — możesz wytrenować nowy model podając zestaw oznaczonych obrazów. @@ -16,7 +16,7 @@ Pod spodem działa `ImageClassificationService` oparty na ML.NET z poolem silnik ## Instalacja ```bash -dotnet add package TailoredApps.Shared.MediatR.ML +dotnet add package TailoredApps.Shared.Mediator.ML ``` --- @@ -26,10 +26,10 @@ dotnet add package TailoredApps.Shared.MediatR.ML ```csharp // Program.cs using Microsoft.Extensions.ML; -using TailoredApps.Shared.MediatR.ImageClassification.Infrastructure; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Domain.Models; +using TailoredApps.Shared.Mediator.ImageClassification.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Domain.Models; -// MediatR: handlery obu komend są w assembly biblioteki, więc trzeba je także przeskanować +// Mediator: handlery obu komend są w assembly biblioteki, więc trzeba je także przeskanować builder.Services.AddMediator(cfg => { cfg.RegisterServicesFromAssembly(typeof(Program).Assembly); @@ -46,9 +46,9 @@ builder.Services.AddPredictionEngine(config => }); ``` -`AddPredictionEngine` rejestruje `IImageClassificationService`, `IModelInfoService` i `IModelHelper` (scoped) oraz wiąże `ImageClassificationOptions`. Nie rejestruje handlerów MediatR — do tego służy skanowanie assembly biblioteki. `RegisterMachineLearningModel` dodaje `PredictionEnginePool` z ML.NET; o tym, skąd ładowany jest model, decyduje builder poola (powyżej `FromFile`). Model rejestruj bez nazwy: predykcje korzystają z domyślnego modelu poola. +`AddPredictionEngine` rejestruje `IImageClassificationService`, `IModelInfoService` i `IModelHelper` (scoped) oraz wiąże `ImageClassificationOptions`. Nie rejestruje handlerów mediatora — do tego służy skanowanie assembly biblioteki. `RegisterMachineLearningModel` dodaje `PredictionEnginePool` z ML.NET; o tym, skąd ładowany jest model, decyduje builder poola (powyżej `FromFile`). Model rejestruj bez nazwy: predykcje korzystają z domyślnego modelu poola. -Typy znajdują się w przestrzeni nazw `TailoredApps.Shared.MediatR.ImageClassification`, a nie pod nazwą pakietu. +Typy znajdują się w przestrzeni nazw `TailoredApps.Shared.Mediator.ImageClassification`, a nie pod nazwą pakietu. ### Konfiguracja `appsettings.json` @@ -143,7 +143,7 @@ Trening czyta pliki z rozszerzeniem `.jpg` lub `.png` z katalogu źródłowego i | `InMemoryImageData` | Klasa | Dane wejściowe do modelu: obraz jako `byte[]` | | `ImagePredictionScore` | Klasa | Surowy wynik modelu: `Score` (per klasa), `PredictedLabel` | | `ImageClassificationOptions` | Klasa | Opcje wiązane z sekcji `ImageClassification`: `ModelFilePath`, `TrainingRoot`, `ModelsRoot`, `MaxImageBytes` | -| `AddPredictionEngineExtension.AddPredictionEngine` | Metoda ext. | Rejestruje w DI `IImageClassificationService`, `IModelInfoService`, `IModelHelper` i opcje (bez handlerów MediatR) | +| `AddPredictionEngineExtension.AddPredictionEngine` | Metoda ext. | Rejestruje w DI `IImageClassificationService`, `IModelInfoService`, `IModelHelper` i opcje (bez handlerów mediatora) | | `PredictionEngineServiceConfiguration.RegisterMachineLearningModel` | Metoda | Dodaje `PredictionEnginePool` z ML.NET i jego adapter; wywoływana wewnątrz `AddPredictionEngine` | --- @@ -169,15 +169,15 @@ Trening czyta pliki z rozszerzeniem `.jpg` lub `.png` z katalogu źródłowego i ## 🤖 AI Agent Prompt ````markdown -## TailoredApps.Shared.MediatR.ML — Instrukcja dla agenta AI +## TailoredApps.Shared.Mediator.ML — Instrukcja dla agenta AI -Używasz TailoredApps.Shared.MediatR.ML do klasyfikacji obrazów przez ML.NET i MediatR. +Używasz TailoredApps.Shared.Mediator.ML do klasyfikacji obrazów przez ML.NET i mediator. ### Rejestracja ```csharp // using Microsoft.Extensions.ML; -// using TailoredApps.Shared.MediatR.ImageClassification.Infrastructure; -// using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Domain.Models; +// using TailoredApps.Shared.Mediator.ImageClassification.Infrastructure; +// using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Domain.Models; builder.Services.AddMediator(cfg => { cfg.RegisterServicesFromAssembly(typeof(Program).Assembly); @@ -191,7 +191,7 @@ builder.Services.AddPredictionEngine(config => ### Co jest konfigurowane - IImageClassificationService, IModelInfoService, IModelHelper (scoped) oraz ImageClassificationOptions - PredictionEnginePool z ML.NET z modelem (domyślnym, bez nazwy) -- Handlery ClassifyImage i TrainImageClassificationModel — wyłącznie przez skan assembly biblioteki w MediatR +- Handlery ClassifyImage i TrainImageClassificationModel — wyłącznie przez skan assembly biblioteki w mediatorze ### Konfiguracja (sekcja "ImageClassification") - ModelFilePath — plik modelu (używany do metadanych modelu i przez powyższą rejestrację) @@ -220,7 +220,7 @@ var result = await _mediator.Send(new TrainImageClassificationModel ``` ### Zasady -- Przestrzeń nazw to TailoredApps.Shared.MediatR.ImageClassification, a nie nazwa pakietu +- Przestrzeń nazw to TailoredApps.Shared.Mediator.ImageClassification, a nie nazwa pakietu - AddMediator musi przeskanować assembly biblioteki — AddPredictionEngine nie rejestruje handlerów - Model musi być plikiem ZIP (ML.NET format) - Sekcja konfiguracji `ImageClassification` jest wymagana — jej brak powoduje `InvalidOperationException` przy pierwszym użyciu opcji diff --git a/docs/Libraries/MediatR/PagedRequest.md b/docs/Libraries/Mediator/PagedRequest.md similarity index 89% rename from docs/Libraries/MediatR/PagedRequest.md rename to docs/Libraries/Mediator/PagedRequest.md index 255d3346..128c5644 100644 --- a/docs/Libraries/MediatR/PagedRequest.md +++ b/docs/Libraries/Mediator/PagedRequest.md @@ -1,13 +1,13 @@ -# TailoredApps.Shared.MediatR.PagedRequest +# TailoredApps.Shared.Mediator.PagedRequest -[![NuGet](https://img.shields.io/nuget/v/TailoredApps.Shared.MediatR.PagedRequest)](https://www.nuget.org/packages/TailoredApps.Shared.MediatR.PagedRequest/) +[![NuGet](https://img.shields.io/nuget/v/TailoredApps.Shared.Mediator.PagedRequest)](https://www.nuget.org/packages/TailoredApps.Shared.Mediator.PagedRequest/) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/tailored-apps/SharedComponents/blob/master/LICENSE) --- ## Opis -Biblioteka dostarcza bazową klasę `PagedAndSortedRequest` dla requestów MediatR, które wymagają paginacji i sortowania. Standaryzuje parametry stronicowania (`Page`, `Count`) i sortowania (`SortField`, `SortDir`) we wszystkich zapytaniach listowych aplikacji. +Biblioteka dostarcza bazową klasę `PagedAndSortedRequest` dla requestów mediatora, które wymagają paginacji i sortowania. Standaryzuje parametry stronicowania (`Page`, `Count`) i sortowania (`SortField`, `SortDir`) we wszystkich zapytaniach listowych aplikacji. Klasa jest ściśle zintegrowana z biblioteką `TailoredApps.Shared.Querying` — wymaga, aby `TQuery` dziedziczyło po `QueryBase`, a `TResponse` implementowało `IPagedResult`. @@ -16,7 +16,7 @@ Klasa jest ściśle zintegrowana z biblioteką `TailoredApps.Shared.Querying` ## Instalacja ```bash -dotnet add package TailoredApps.Shared.MediatR.PagedRequest +dotnet add package TailoredApps.Shared.Mediator.PagedRequest ``` --- @@ -27,7 +27,7 @@ dotnet add package TailoredApps.Shared.MediatR.PagedRequest ```csharp using TailoredApps.Shared.Querying; -using TailoredApps.Shared.MediatR.PagedRequest; +using TailoredApps.Shared.Mediator.PagedRequest; // 1. Filter dziedziczy po QueryBase public class ProductFilter : QueryBase @@ -112,7 +112,7 @@ public async Task GetProducts([FromQuery] GetProductsQuery query) !!! info "Trimming i NativeAOT" Typy tego pakietu (`PagedAndSortedRequest<,,>`, `IPagedResult<>`) są zgodne z trimmingiem i NativeAOT; handler rejestruje się wtedy - po nazwie — zob. [MediatR: Trimming i NativeAOT](index.md#trimming-i-nativeaot). Rozszerzenia stronicowania i sortowania użyte + po nazwie — zob. [Mediator: Trimming i NativeAOT](index.md#trimming-i-nativeaot). Rozszerzenia stronicowania i sortowania użyte w przykładzie pochodzą z `TailoredApps.Shared.EntityFramework`, która z NativeAOT zgodna nie jest (EF Core). --- @@ -121,7 +121,7 @@ public async Task GetProducts([FromQuery] GetProductsQuery query) | Typ | Rodzaj | Opis | |-----|--------|------| -| `PagedAndSortedRequest` | Klasa bazowa | Bazowy request MediatR z paginacją i sortowaniem | +| `PagedAndSortedRequest` | Klasa bazowa | Bazowy request mediatora z paginacją i sortowaniem | | `Page` | Właściwość `int?` | Numer strony (1-based) | | `Count` | Właściwość `int?` | Liczba elementów na stronie | | `IsPagingSpecified` | Właściwość `bool` | `true` gdy Page i Count mają wartość | @@ -142,9 +142,9 @@ public async Task GetProducts([FromQuery] GetProductsQuery query) ## 🤖 AI Agent Prompt ````markdown -## TailoredApps.Shared.MediatR.PagedRequest — Instrukcja dla agenta AI +## TailoredApps.Shared.Mediator.PagedRequest — Instrukcja dla agenta AI -Używasz PagedAndSortedRequest jako bazowej klasy dla stronicowanych requestów MediatR. +Używasz PagedAndSortedRequest jako bazowej klasy dla stronicowanych requestów mediatora. ### Definicja ```csharp diff --git a/docs/Libraries/MediatR/index.md b/docs/Libraries/Mediator/index.md similarity index 93% rename from docs/Libraries/MediatR/index.md rename to docs/Libraries/Mediator/index.md index 7c8881b5..4373d560 100644 --- a/docs/Libraries/MediatR/index.md +++ b/docs/Libraries/Mediator/index.md @@ -1,13 +1,13 @@ -# TailoredApps.Shared.MediatR +# TailoredApps.Shared.Mediator -[![NuGet](https://img.shields.io/nuget/v/TailoredApps.Shared.MediatR)](https://www.nuget.org/packages/TailoredApps.Shared.MediatR/) +[![NuGet](https://img.shields.io/nuget/v/TailoredApps.Shared.Mediator)](https://www.nuget.org/packages/TailoredApps.Shared.Mediator/) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/tailored-apps/SharedComponents/blob/master/LICENSE) --- ## Opis -Biblioteka dostarcza gotowy zestaw **pipeline behaviors** dla MediatR, które pokrywają najczęstsze potrzeby aplikacji enterprise: logowanie, walidację, cache'owanie, fallback i retry. Zamiast ręcznie implementować te cross-cutting concerns w każdym handlerze, rejestrujesz je raz przez `PipelineRegistration` i masz je dla wszystkich requestów. +Biblioteka dostarcza gotowy zestaw **pipeline behaviors** dla mediatora, które pokrywają najczęstsze potrzeby aplikacji enterprise: logowanie, walidację, cache'owanie, fallback i retry. Zamiast ręcznie implementować te cross-cutting concerns w każdym handlerze, rejestrujesz je raz przez `PipelineRegistration` i masz je dla wszystkich requestów. Behaviory działają w kolejności: **Logging → Validation → Caching → Fallback → Retry → Handler**. @@ -18,7 +18,7 @@ Biblioteka wspiera mechanizm auto-discovery (przez Scrutor) — cache policies, ## Instalacja ```bash -dotnet add package TailoredApps.Shared.MediatR +dotnet add package TailoredApps.Shared.Mediator ``` --- @@ -27,9 +27,9 @@ dotnet add package TailoredApps.Shared.MediatR ```csharp // Program.cs -using TailoredApps.Shared.MediatR.DI; +using TailoredApps.Shared.Mediator.DI; -// Rejestracja MediatR +// Rejestracja mediatora builder.Services.AddMediator(cfg => cfg.RegisterServicesFromAssembly(typeof(Program).Assembly)); @@ -54,7 +54,7 @@ builder.Services.AddStackExchangeRedisCache(options => options.Configuration = " ``` !!! info "Zmiany w 3.0 (wersja testowa)" - Biblioteki `TailoredApps.Shared.MediatR*` korzystają z [ForkForward.Mediator](https://www.nuget.org/packages/ForkForward.Mediator) — forka MediatR 12.5.0 na licencji Apache-2.0 — zamiast pakietu MediatR. Typy i zachowanie są te same; w aplikacji zamień `using MediatR;` na `using ForkForward.Mediator;` oraz `AddMediatR(...)` na `AddMediator(...)`. Szczegóły: [Aktualizacja do 3.0](../../Migration/v3.md). Od ForkForward.Mediator 13 biblioteka działa także w aplikacji publikowanej z NativeAOT — zob. [Trimming i NativeAOT](#trimming-i-nativeaot). + Biblioteki `TailoredApps.Shared.Mediator*` korzystają z [ForkForward.Mediator](https://www.nuget.org/packages/ForkForward.Mediator) — forka MediatR 12.5.0 na licencji Apache-2.0 — zamiast pakietu MediatR. W 2.x nazywały się `TailoredApps.Shared.MediatR*`. Typy i zachowanie są te same; w aplikacji zamień `using MediatR;` na `using ForkForward.Mediator;` oraz `AddMediatR(...)` na `AddMediator(...)`. Szczegóły: [Aktualizacja do 3.0](../../Migration/v3.md). Od ForkForward.Mediator 13 biblioteka działa także w aplikacji publikowanej z NativeAOT — zob. [Trimming i NativeAOT](#trimming-i-nativeaot). !!! info "Zmiany w 2.0" `CachingBehavior` korzysta z `HybridCache`. Interfejs `ICache` i klasa `Cache` zostały usunięte razem z zależnością od Newtonsoft.Json — usuń własną rejestrację `ICache`. Odpowiedzi są serializowane przez System.Text.Json, a `ICachePolicy.SlidingExpiration` nie jest już obsługiwane (wpis żyje do czasu wygaśnięcia). Po aktualizacji wyczyść współdzielony cache lub zmień prefiks kluczy: wpisy zapisane przez 1.x mają inny format. @@ -228,9 +228,9 @@ internal sealed partial class AppJsonContext : JsonSerializerContext; ## 🤖 AI Agent Prompt ````markdown -## TailoredApps.Shared.MediatR — Instrukcja dla agenta AI +## TailoredApps.Shared.Mediator — Instrukcja dla agenta AI -Używasz biblioteki TailoredApps.Shared.MediatR z pipeline behaviors w projekcie .NET. +Używasz biblioteki TailoredApps.Shared.Mediator z pipeline behaviors w projekcie .NET. ### Rejestracja ```csharp diff --git a/docs/Libraries/Querying/index.md b/docs/Libraries/Querying/index.md index 38b3c341..f33d761e 100644 --- a/docs/Libraries/Querying/index.md +++ b/docs/Libraries/Querying/index.md @@ -125,7 +125,7 @@ public async Task GetCustomersAsync( | `ISortingParameters` | Interfejs | `SortField`, `SortDir`, `IsSortingSpecified` | | `IQueryParameters` | Interfejs | Łączy `IPagingParameters` + `ISortingParameters` | | `IQuery` | Interfejs | Zapytanie z obiektem filtru: `Filter` | -| `IPagedAndSortedRequest` | Interfejs | Kontrakt MediatR request z paginacją (używany przez MediatR.PagedRequest) | +| `IPagedAndSortedRequest` | Interfejs | Kontrakt requestu mediatora z paginacją (używany przez Mediator.PagedRequest) | | `IsSortBy(string)` | Metoda | Case-insensitive porównanie z `SortField` | | `QueryMap` | Klasa | Para wyrażeń: `Destination` (pole modelu/DTO) i `Source` (odpowiadające mu pole encji). Tylko je przechowuje — nic w tym pakiecie nie interpretuje mapowania | diff --git a/docs/Migration/v2.md b/docs/Migration/v2.md index 48ee1bec..171f24d4 100644 --- a/docs/Migration/v2.md +++ b/docs/Migration/v2.md @@ -154,7 +154,7 @@ Opis: [Payments](../Libraries/Payments/index.md). - `ICachePolicy.SlidingExpiration` nie jest już obsługiwane, - po aktualizacji wyczyść współdzielony cache albo zmień prefiks kluczy — wpisy zapisane przez 1.x mają inny format. -Ponawianie i wyłącznik obwodu nie używają już Polly. Opis: [MediatR](../Libraries/MediatR/index.md). +Ponawianie i wyłącznik obwodu nie używają już Polly. Opis: [Mediator](../Libraries/Mediator/index.md) (w 2.x pod nazwą MediatR). --- diff --git a/docs/Migration/v3.md b/docs/Migration/v3.md index 5331c856..6d2b5868 100644 --- a/docs/Migration/v3.md +++ b/docs/Migration/v3.md @@ -10,12 +10,28 @@ Ta strona zbiera to, co trzeba zrobić **w kodzie aplikacji** przy przejściu z ## Co się zmienia -Biblioteki `TailoredApps.Shared.MediatR*` przestają zależeć od pakietu **MediatR** i korzystają z +Biblioteki mediatora przestają zależeć od pakietu **MediatR** i korzystają z [**ForkForward.Mediator**](https://www.nuget.org/packages/ForkForward.Mediator) — społecznościowego forka MediatR 12.5.0, ostatniej wersji na licencji Apache-2.0 (MediatR od wersji 13 ma licencję komercyjną). Fork ma te same typy, składowe i zachowanie, ale **własną przestrzeń nazw i własny zestaw**: `ForkForward.Mediator` zamiast `MediatR`. -Nazwy pakietów i przestrzeni nazw tych bibliotek (`TailoredApps.Shared.MediatR`, `TailoredApps.Shared.MediatR.Caching`, …) **nie zmieniają się**. +### Biblioteki mediatora zmieniają nazwę + +Skoro nie ma już pakietu MediatR, biblioteki tracą też jego nazwę. Pakiety, zestawy i przestrzenie nazw zmieniają się razem: + +| 2.x | 3.0 | +|---|---| +| `TailoredApps.Shared.MediatR` | `TailoredApps.Shared.Mediator` | +| `TailoredApps.Shared.MediatR.Caching` | `TailoredApps.Shared.Mediator.Caching` | +| `TailoredApps.Shared.MediatR.Email` | `TailoredApps.Shared.Mediator.Email` | +| `TailoredApps.Shared.MediatR.PagedRequest` | `TailoredApps.Shared.Mediator.PagedRequest` | +| `TailoredApps.Shared.MediatR.ML` (przestrzeń nazw `TailoredApps.Shared.MediatR.ImageClassification`) | `TailoredApps.Shared.Mediator.ML` (przestrzeń nazw `TailoredApps.Shared.Mediator.ImageClassification`) | + +Każda przestrzeń nazw poniżej zmienia się tak samo (`TailoredApps.Shared.MediatR.DI` → `TailoredApps.Shared.Mediator.DI` itd.). Typy, składowe +i klucze konfiguracji zachowują nazwy. + +Stare identyfikatory pakietów zostają na nuget.org z wersjami 2.x i nie dostaną wydania 3.0. Wydania `3.0.0-preview.1` i +`3.0.0-preview.2` wyszły jeszcze pod starymi nazwami. Biblioteki zależą od **ForkForward.Mediator 13**: linia 13 jest wydawana tylko dla `net10.0` i `net11.0` (tak jak te biblioteki), jej asset `net11.0` jest skompilowany z runtime async i działa w aplikacjach publikowanych z NativeAOT. Dla kodu aplikacji różnic względem 12.x nie ma; @@ -37,7 +53,7 @@ samym blokiem. Obsługa webhooków Stripe się nie zmienia. ### Odrzucone żądania nie są już logowane jako błędy -- **MediatR** — `LoggingBehavior` zapisuje żądanie odrzucone przez walidację (`ValidationException`) na poziomie **Information**: +- **Mediator** — `LoggingBehavior` zapisuje żądanie odrzucone przez walidację (`ValidationException`) na poziomie **Information**: `Request GetProduct rejected by validation …; invalid: Id`, z samymi nazwami pól (komunikaty walidacji mogą cytować wartości wysłane przez klienta). Żądanie anulowane przez wywołującego (`OperationCanceledException` przy anulowanym tokenie żądania) — też Information. Każdy inny wyjątek handlera, jak dotąd, Error. @@ -77,10 +93,10 @@ Dwie nowe, osobne paczki — nic nie zmieniają w istniejących i niczego nie tr deklarują w 3.0 zgodność z trimmingiem i NativeAOT (w Web API: na minimal API, nie na kontrolerach): opcje są wiązane kodem generowanym w czasie kompilacji, a JSON bramek serializowany przez generowane metadane. Dla aplikacji nic się nie zmienia — treść żądań i podpisy są identyczne. Szczegóły i lista bibliotek: [Trimming i NativeAOT](../Platform/index.md#trimming-i-nativeaot). -To samo dotyczy `MediatR`, `MediatR.Caching`, `MediatR.Email` i `MediatR.PagedRequest` (na ForkForward.Mediator 13). Zwykła aplikacja nie zmienia +To samo dotyczy `Mediator`, `Mediator.Caching`, `Mediator.Email` i `Mediator.PagedRequest` (na ForkForward.Mediator 13). Zwykła aplikacja nie zmienia niczego: skanowanie i `RegisterPipelineBehaviors()` działają jak dotąd. Aplikacja trimowana lub publikowana z NativeAOT rejestruje handlery, behaviory i polityki po nazwie nowymi metodami `PipelineRegistration` (`AddPipelineBehaviors<,>()`, `AddCachePolicy<,,>()`, -`AddFallbackHandler<,,>()`, `AddRetryPolicy<,,>()`, `AddCacheSerialization(...)`) — zob. [MediatR: Trimming i NativeAOT](../Libraries/MediatR/index.md#trimming-i-nativeaot). +`AddFallbackHandler<,,>()`, `AddRetryPolicy<,,>()`, `AddCacheSerialization(...)`) — zob. [Mediator: Trimming i NativeAOT](../Libraries/Mediator/index.md#trimming-i-nativeaot). `RegisterPipelineBehaviors(assembly)` ma teraz adnotacje `RequiresUnreferencedCode` / `RequiresDynamicCode`: projekt z włączonymi analizatorami trimmingu dostaje w miejscu wywołania ostrzeżenie `IL2026` / `IL3050`. @@ -96,13 +112,15 @@ Poza tym biblioteki nie mają w 3.0 zmian wymagających modyfikacji kodu. | # | Co zrobić | Skutek pominięcia | |---|-----------|-------------------| -| 1 | Usunąć z aplikacji pakiet `MediatR` (i `MediatR.Contracts`), dodać `ForkForward.Mediator` — albo polegać na zależności przechodniej z `TailoredApps.Shared.MediatR` | Dwa różne zestawy typów `IRequest` / `IRequestHandler`; handlery nie są znajdowane | +| 1 | Usunąć z aplikacji pakiet `MediatR` (i `MediatR.Contracts`), dodać `ForkForward.Mediator` — albo polegać na zależności przechodniej z `TailoredApps.Shared.Mediator` | Dwa różne zestawy typów `IRequest` / `IRequestHandler`; handlery nie są znajdowane | | 2 | Zamienić `using MediatR;` na `using ForkForward.Mediator;` (także `MediatR.Pipeline` → `ForkForward.Mediator.Pipeline` itd.) | Błędy kompilacji (CS0246) lub niezgodność typów | | 3 | Zamienić `AddMediatR(...)` na `AddMediator(...)`, a `MediatRServiceConfiguration` na `MediatorServiceConfiguration` | Błąd kompilacji (CS1061) | -| 4 | Podnieść **wszystkie** pakiety `TailoredApps.Shared.*` do tej samej wersji 3.0 | Mieszanie 2.x i 3.0 daje dwa mediatory w jednym procesie | -| 5 | Stripe: obsłużyć awarię przez `catch (HttpRequestException)`, a odmowę przez `PaymentStatus == Rejected`; usunąć `catch (StripeException)` wokół `RegisterPayment` i `GetStatus` | Awaria Stripe omija dotychczasowy blok `catch (StripeException)`, a odmowa nie jest wyjątkiem i zostaje nieobsłużona | -| 6 | Przejrzeć alerty i zapytania, które liczą wpisy Error lub `error.type` dla odpowiedzi 4xx | Alert na „błędy walidacji” przestaje się uruchamiać | -| 7 | Zamienić `UtcTimeOfDaty` na `UtcTimeOfDay`, `AddExceptionHAndlingFilterAttribute` na `AddExceptionHandlingFilterAttribute`, a w konfiguracji PayNow i Tpay klucz `ApiUrl` na `ServiceUrl` | Błąd kompilacji albo host, który nie startuje | +| 4 | Zamienić referencje do pakietów `TailoredApps.Shared.MediatR*` na `TailoredApps.Shared.Mediator*` | Stare pakiety kończą się na `3.0.0-preview.2`: restore nie powiedzie się albo po cichu zostanie stare wydanie testowe | +| 5 | Zamienić `using TailoredApps.Shared.MediatR` na `using TailoredApps.Shared.Mediator` (każda podprzestrzeń) | Błąd kompilacji (CS0234) | +| 6 | Podnieść **wszystkie** pakiety `TailoredApps.Shared.*` do tej samej wersji 3.0 | Mieszanie 2.x i 3.0 daje dwa mediatory w jednym procesie | +| 7 | Stripe: obsłużyć awarię przez `catch (HttpRequestException)`, a odmowę przez `PaymentStatus == Rejected`; usunąć `catch (StripeException)` wokół `RegisterPayment` i `GetStatus` | Awaria Stripe omija dotychczasowy blok `catch (StripeException)`, a odmowa nie jest wyjątkiem i zostaje nieobsłużona | +| 8 | Przejrzeć alerty i zapytania, które liczą wpisy Error lub `error.type` dla odpowiedzi 4xx | Alert na „błędy walidacji” przestaje się uruchamiać | +| 9 | Zamienić `UtcTimeOfDaty` na `UtcTimeOfDay`, `AddExceptionHAndlingFilterAttribute` na `AddExceptionHandlingFilterAttribute`, a w konfiguracji PayNow i Tpay klucz `ApiUrl` na `ServiceUrl` | Błąd kompilacji albo host, który nie startuje | --- @@ -111,6 +129,7 @@ Poza tym biblioteki nie mają w 3.0 zmian wymagających modyfikacji kodu. ```csharp // 2.x using MediatR; +using TailoredApps.Shared.MediatR.DI; builder.Services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(typeof(Program).Assembly)); @@ -129,6 +148,7 @@ public class GetProductHandler : IRequestHandler ```csharp // 3.0 using ForkForward.Mediator; +using TailoredApps.Shared.Mediator.DI; builder.Services.AddMediator(cfg => cfg.RegisterServicesFromAssembly(typeof(Program).Assembly)); @@ -144,10 +164,11 @@ public class GetProductHandler : IRequestHandler } ``` -Zmienia się tylko dyrektywa `using` i nazwa metody rejestrującej mediator. `IRequest<>`, `IRequestHandler<,>`, `IPipelineBehavior<,>`, +Zmieniają się tylko dyrektywy `using` i nazwa metody rejestrującej mediator. `IRequest<>`, `IRequestHandler<,>`, `IPipelineBehavior<,>`, `IMediator`, `ISender`, `INotification` i pozostałe typy mają te same nazwy i składowe. -W dużym projekcie wystarczą dwa zastąpienia w całym rozwiązaniu: `using MediatR` → `using ForkForward.Mediator` oraz `AddMediatR(` → `AddMediator(`. +W dużym projekcie wystarczą trzy zastąpienia w całym rozwiązaniu: `TailoredApps.Shared.MediatR` → `TailoredApps.Shared.Mediator` +(pliki źródłowe i pliki projektów), `using MediatR` → `using ForkForward.Mediator` oraz `AddMediatR(` → `AddMediator(`. Działający przykład na ForkForward.Mediator — cały pipeline (walidacja, cache, retry, fallback) razem z pozostałymi bibliotekami — jest w [aplikacji demo](../Demo/index.md). @@ -158,6 +179,9 @@ w [aplikacji demo](../Demo/index.md). - **Nie mieszaj obu mediatorów.** Handler implementujący `MediatR.IRequestHandler<,>` nie zostanie wywołany przez `ForkForward.Mediator.IMediator` i odwrotnie — to różne typy. Po migracji w aplikacji nie powinno zostać żadne odwołanie do pakietu `MediatR`. +- **`Mediator` jest teraz także przestrzenią nazw.** Kod, którego własna przestrzeń nazw zaczyna się od `TailoredApps.Shared.`, a który używa + klasy `Mediator` z ForkForward.Mediator po krótkiej nazwie, przestaje się kompilować (CS0118); trzeba tam pisać `ForkForward.Mediator.Mediator`. + `IMediator`, `ISender` i pozostałych typów to nie dotyczy, podobnie jak kodu w innych przestrzeniach nazw. - **Biblioteki firm trzecich oparte na MediatR** (np. własne pakiety z handlerami) trzeba przebudować na `ForkForward.Mediator`, zanim zadziałają z 3.0. - **Zachowanie jest to z MediatR 12.5.0** — kolejność behaviorów, publikowanie powiadomień i rejestracja z assembly działają tak samo. - `ForkForward.Mediator` to młody pakiet. Dlatego 3.0 jest w fazie testowej: sprawdź go w jednej aplikacji, zanim przeniesiesz kolejne. @@ -168,7 +192,7 @@ w [aplikacji demo](../Demo/index.md). - **Wyjątek zamieniany przez providera na 4xx** nie jest już widoczny w logu na poziomie Error. Jeśli aplikacja zamienia na 4xx wyjątki, które są w rzeczywistości błędami serwera, niech provider nadaje im 5xx. -Opis bibliotek: [MediatR](../Libraries/MediatR/index.md). Aktualizacja z 1.x: [Aktualizacja do 2.0](v2.md). +Opis bibliotek: [Mediator](../Libraries/Mediator/index.md). Aktualizacja z 1.x: [Aktualizacja do 2.0](v2.md). --- @@ -182,9 +206,11 @@ Aktualizujesz aplikację .NET 10 lub .NET 11 z paczek TailoredApps.Shared.* 2.x ### Rejestracja - Podnieś wszystkie paczki TailoredApps.Shared.* do tej samej wersji 3.0.0-preview.N - Usuń odwołania do paczek MediatR i MediatR.Contracts; w razie potrzeby dodaj ForkForward.Mediator +- Zamień referencje do paczek TailoredApps.Shared.MediatR, .MediatR.Caching, .MediatR.Email, .MediatR.PagedRequest i .MediatR.ML na TailoredApps.Shared.Mediator, .Mediator.Caching, .Mediator.Email, .Mediator.PagedRequest i .Mediator.ML - builder.Services.AddMediatR(...) zamień na builder.Services.AddMediator(...) ### Co wymaga zmian w kodzie +- using TailoredApps.Shared.MediatR... -> using TailoredApps.Shared.Mediator... (każda podprzestrzeń, np. .DI, .PipelineBehaviours, .ImageClassification) - using MediatR; -> using ForkForward.Mediator; (oraz MediatR.Pipeline -> ForkForward.Mediator.Pipeline itd.) - MediatRServiceConfiguration -> MediatorServiceConfiguration - Nazwy i składowe IRequest, IRequestHandler, IPipelineBehavior, IMediator, ISender, INotification pozostają bez zmian @@ -196,8 +222,9 @@ Aktualizujesz aplikację .NET 10 lub .NET 11 z paczek TailoredApps.Shared.* 2.x - Brak nowych kluczy konfiguracji ### Zasady -- Po migracji w rozwiązaniu nie może zostać żadne odwołanie do paczki ani przestrzeni nazw MediatR -- Nie zmieniaj nazw przestrzeni TailoredApps.Shared.MediatR.* — to nazwy bibliotek, nie paczki MediatR +- Po migracji w rozwiązaniu nie może zostać żadne odwołanie do paczki ani przestrzeni nazw MediatR, także TailoredApps.Shared.MediatR* +- Zmieniają się tylko identyfikatory paczek i przestrzenie nazw: nie zmieniaj nazw typów ani składowych bibliotek TailoredApps +- W kodzie, którego przestrzeń nazw zaczyna się od TailoredApps.Shared., pisz ForkForward.Mediator.Mediator dla klasy Mediator (inaczej CS0118) - Nie mieszaj paczek TailoredApps.Shared.* w wersjach 2.x i 3.0 w jednej aplikacji - 3.0 jest wersją przedpremierową: nie wdrażaj jej produkcyjnie bez wyraźnej decyzji właściciela aplikacji ```` diff --git a/docs/Platform/index.md b/docs/Platform/index.md index 3cdfa2a4..2b46868e 100644 --- a/docs/Platform/index.md +++ b/docs/Platform/index.md @@ -11,7 +11,7 @@ Każda paczka `TailoredApps.Shared.*` jest budowana dla kilku platform docelowyc | Biblioteki | Platformy docelowe | |---|---| -| `DateTime`, `Email`, `Email.Models`, `Email.Office365`, `EntityFramework`, `EntityFramework.UnitOfWork.MinimalApi`, `EntityFramework.UnitOfWork.WebApiCore`, `ExceptionHandling`, `ExceptionHandling.MinimalApi`, `MediatR`, `MediatR.Caching`, `MediatR.Email`, `MediatR.ML`, `MediatR.PagedRequest`, `Payments` i wszyscy providerzy płatności, `Querying`, `WebApi` | `net10.0`, `net11.0` | +| `DateTime`, `Email`, `Email.Models`, `Email.Office365`, `EntityFramework`, `EntityFramework.UnitOfWork.MinimalApi`, `EntityFramework.UnitOfWork.WebApiCore`, `ExceptionHandling`, `ExceptionHandling.MinimalApi`, `Mediator`, `Mediator.Caching`, `Mediator.Email`, `Mediator.ML`, `Mediator.PagedRequest`, `Payments` i wszyscy providerzy płatności, `Querying`, `WebApi` | `net10.0`, `net11.0` | !!! info "Wersja 2.0 a starsze platformy" Od wersji **2.0** każda biblioteka jest budowana wyłącznie dla `net10.0` i `net11.0`. Aplikacje na `net8.0`, @@ -45,7 +45,7 @@ Biblioteki z tego repozytorium korzystają z tego mechanizmu w assetach `net11.0 - **Nie potrzeba zmiennych środowiskowych** ani ``. !!! warning "Wymaga CoreCLR lub NativeAOT" - Runtime async działa na CoreCLR i NativeAOT. Runtime Mono — używany m.in. przez **Blazor WebAssembly** — nie potrafi w .NET 11 wykonać takich metod. Jeżeli chcesz użyć którejś z bibliotek zawierających kod `async` po stronie klienta Blazor WebAssembly na `net11.0`, zbuduj ją z wyłączonym runtime async (patrz niżej). Biblioteki `DateTime`, `Email.Models`, `MediatR.Caching` i `Querying` nie zawierają kodu `async` i nie są tym objęte. + Runtime async działa na CoreCLR i NativeAOT. Runtime Mono — używany m.in. przez **Blazor WebAssembly** — nie potrafi w .NET 11 wykonać takich metod. Jeżeli chcesz użyć którejś z bibliotek zawierających kod `async` po stronie klienta Blazor WebAssembly na `net11.0`, zbuduj ją z wyłączonym runtime async (patrz niżej). Biblioteki `DateTime`, `Email.Models`, `Mediator.Caching` i `Querying` nie zawierają kodu `async` i nie są tym objęte. !!! info "Status funkcji" W .NET 11 runtime async jest funkcją typu *opt-in*, którą dokumentacja Microsoftu wciąż opisuje jako preview: [What's new in the .NET 11 runtime](https://learn.microsoft.com/dotnet/core/whats-new/dotnet-11/runtime). @@ -88,9 +88,9 @@ a ich kod działa po skompilowaniu do kodu natywnego. |---|---| | `DateTime`, `Querying`, `Email.Models`, `Payments`, `Payments.Provider.Adyen`, `.CashBill`, `.HotPay`, `.PayNow`, `.PayU`, `.Przelewy24`, `.Revolut`, `.Tpay` | **Zgodne.** Sprawdzane natywnie w CI na `net10.0` i `net11.0`, na Linuksie i Windows | | `Email`, `ExceptionHandling`, `ExceptionHandling.MinimalApi`, `WebApi` | **Zgodne** w aplikacji na minimal API (zob. niżej). Filtr MVC z `ExceptionHandling` nie ma zastosowania: ASP.NET Core nie obsługuje kontrolerów w NativeAOT | -| `MediatR`, `MediatR.Caching`, `MediatR.Email`, `MediatR.PagedRequest` | **Zgodne** (na ForkForward.Mediator 13), gdy handlery, behaviory i polityki są rejestrowane po nazwie, a nie skanowaniem — zob. [MediatR: Trimming i NativeAOT](../Libraries/MediatR/index.md#trimming-i-nativeaot). Aplikacja, która cache'uje odpowiedzi, dostaje ostrzeżenia z samego `Microsoft.Extensions.Caching.Hybrid`; cache działa natywnie | +| `Mediator`, `Mediator.Caching`, `Mediator.Email`, `Mediator.PagedRequest` | **Zgodne** (na ForkForward.Mediator 13), gdy handlery, behaviory i polityki są rejestrowane po nazwie, a nie skanowaniem — zob. [Mediator: Trimming i NativeAOT](../Libraries/Mediator/index.md#trimming-i-nativeaot). Aplikacja, która cache'uje odpowiedzi, dostaje ostrzeżenia z samego `Microsoft.Extensions.Caching.Hybrid`; cache działa natywnie | | `EntityFramework`, `EntityFramework.UnitOfWork.WebApiCore`, `EntityFramework.UnitOfWork.MinimalApi` | Niezgodne: EF Core buduje model i zapytania w czasie działania; audyt zmian tworzy typy przez `MakeGenericType` | -| `Email.Office365`, `MediatR.ML`, `Payments.Provider.Stripe` | Niezgodne: zależności (Microsoft.Identity.Web, ML.NET, Stripe.net) opierają się na refleksji | +| `Email.Office365`, `Mediator.ML`, `Payments.Provider.Stripe` | Niezgodne: zależności (Microsoft.Identity.Web, ML.NET, Stripe.net) opierają się na refleksji | ### Web API: minimal API tak, kontrolery nie @@ -130,7 +130,7 @@ Dla minimal API są osobne paczki z odpowiednikami filtrów MVC: [ExceptionHandl są identyczne co do bajta. To samo dotyczy odpowiedzi błędu w `ExceptionHandling`. - **Rejestracje w kontenerze** z parametrem generycznym (`RegisterPaymentProvider()`, `AddPayments<,>()`, `AddExceptionHandlingForWebApi<,>()`) mają adnotacje, dzięki którym trimmer zachowuje konstruktory wywoływane przez dependency injection. -- **MediatR** ma rejestrację bez skanowania (`AddPipelineBehaviors<,>()`, `AddCachePolicy<,,>()`, `AddFallbackHandler<,,>()`, +- **Mediator** ma rejestrację bez skanowania (`AddPipelineBehaviors<,>()`, `AddCachePolicy<,,>()`, `AddFallbackHandler<,,>()`, `AddRetryPolicy<,,>()`), serializację odpowiedzi w cache generowanymi metadanymi (`AddCacheSerialization`) i klucz cache liczony z `JsonTypeInfo`. Skanowanie assembly zostaje dla zwykłych aplikacji i jest oznaczone `RequiresUnreferencedCode`. @@ -226,14 +226,14 @@ Pracujesz z paczkami TailoredApps.Shared.* albo z repozytorium SharedComponents. warunkowych: 10.* i 11.*); projekt testów w tests/. - Do budowania repozytorium używaj .NET SDK 11.0.100 lub nowszego. - Zgodne z trimmingiem i NativeAOT (IsAotCompatible) są: DateTime, Querying, Email, Email.Models, ExceptionHandling, - ExceptionHandling.MinimalApi, WebApi, MediatR, MediatR.Caching, MediatR.Email, MediatR.PagedRequest, + ExceptionHandling.MinimalApi, WebApi, Mediator, Mediator.Caching, Mediator.Email, Mediator.PagedRequest, Payments oraz providerzy Adyen, CashBill, HotPay, PayNow, PayU, Przelewy24, Revolut, Tpay. - NativeAOT w ASP.NET Core to minimal API: kontrolery MVC nie działają natywnie (trasy odpowiadają 404). [Authorize] i JWT działają. - Blazor WebAssembly na net11.0 nie wykonuje metod runtime async (PlatformNotSupportedException): nie wywołuj tam asynchronicznych metod bibliotek z assetu net11.0. W nich ostrzeżenia IL2xxx/IL3xxx są błędami kompilacji: nie używaj refleksji, JsonSerializer bez JsonTypeInfo ani ConfigurationBinder poza generatorem. -- Biblioteki EntityFramework*, Email.Office365, MediatR.ML i Payments.Provider.Stripe nie są zgodne z NativeAOT - +- Biblioteki EntityFramework*, Email.Office365, Mediator.ML i Payments.Provider.Stripe nie są zgodne z NativeAOT - nie proponuj ich w aplikacji publikowanej z PublishAot. -- MediatR w aplikacji z PublishAot: bez skanowania - cfg.AddRequestHandler<,,>() dla handlerów, AddPipelineBehaviors<,>() dla każdego +- Mediator w aplikacji z PublishAot: bez skanowania - cfg.AddRequestHandler<,,>() dla handlerów, AddPipelineBehaviors<,>() dla każdego requestu, AddCachePolicy / AddFallbackHandler / AddRetryPolicy, AddCacheSerialization(context) i własny GetCacheKey. ``` diff --git a/docs/Security/index.md b/docs/Security/index.md index c2978ee4..7e35011c 100644 --- a/docs/Security/index.md +++ b/docs/Security/index.md @@ -3,6 +3,8 @@ Ta strona dokumentuje przegląd bezpieczeństwa bibliotek współdzielonych wykonany 2 września 2026, poprawki, które z nim trafiły do repozytorium, oraz punkty wymagające decyzji człowieka. +Biblioteki występują pod nazwami z dnia przeglądu: `MediatR` i `MediatR.ML` to od wersji 3.0 `Mediator` i `Mediator.ML`. + ## Zakres i metoda - Wszystkie biblioteki w `src/` (25 projektów, ok. 12 000 linii C#), projekty testowe, diff --git a/docs/contributing.md b/docs/contributing.md index 0fc951af..b17f4647 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -169,8 +169,8 @@ Używasz biblioteki TailoredApps.Shared.XXXXX w projekcie .NET. ## Zgodność publicznego API Gałąź `master` to linia **3.0 w fazie testowej** (`3.0.0-preview.N`): zmiany niekompatybilne są dozwolone do wydania `3.0.0`, ale tylko -zamierzone. Gałąź `release/2.1` to linia poprawek 2.1.x, zgodna z `2.0.0`. Biblioteki `TailoredApps.Shared.MediatR*` są na `master` wyłączone -z porównania (przeszły z MediatR na ForkForward.Mediator); pozostałe są nadal porównywane, żeby zmiana łamiąca nie zdarzyła się przypadkiem. +zamierzone. Gałąź `release/2.1` to linia poprawek 2.1.x, zgodna z `2.0.0`. Biblioteki `TailoredApps.Shared.Mediator*` są na `master` wyłączone +z porównania (przeszły z MediatR na ForkForward.Mediator i zmieniły nazwę z `TailoredApps.Shared.MediatR*`); pozostałe są nadal porównywane, żeby zmiana łamiąca nie zdarzyła się przypadkiem. Linia 2.x musi pozostać zgodna z `2.0.0`: kod skompilowany z dowolną wersją 2.x ma działać z każdą nowszą 2.x. Sprawdzenie *Build & Test PR* porównuje publiczne API każdej biblioteki z paczką `2.0.0` z nuget.org i kończy się błędem przy zmianie diff --git a/docs/index.md b/docs/index.md index 961988fc..862e8eec 100644 --- a/docs/index.md +++ b/docs/index.md @@ -3,7 +3,7 @@ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/tailored-apps/SharedComponents/blob/master/LICENSE) [![GitHub](https://img.shields.io/badge/GitHub-SharedComponents-181717?logo=github)](https://github.com/tailored-apps/SharedComponents) -Witaj w dokumentacji **TailoredApps Shared Components** — zestawu wielokrotnego użytku bibliotek .NET, które przyspieszają tworzenie profesjonalnych aplikacji webowych. Każda biblioteka rozwiązuje jeden konkretny problem i jest zaprojektowana pod kątem testowalności, rozszerzalności i integracji z ekosystemem ASP.NET Core + MediatR. +Witaj w dokumentacji **TailoredApps Shared Components** — zestawu wielokrotnego użytku bibliotek .NET, które przyspieszają tworzenie profesjonalnych aplikacji webowych. Każda biblioteka rozwiązuje jeden konkretny problem i jest zaprojektowana pod kątem testowalności, rozszerzalności i integracji z ekosystemem ASP.NET Core + mediator. --- @@ -20,11 +20,11 @@ Witaj w dokumentacji **TailoredApps Shared Components** — zestawu wielokrotneg | [EntityFramework.UnitOfWork.MinimalApi](Libraries/EntityFramework/UnitOfWork.MinimalApi.md) | `TailoredApps.Shared.EntityFramework.UnitOfWork.MinimalApi` | Automatyczne transakcje dla minimal API przez filtr endpointu | | [ExceptionHandling](Libraries/ExceptionHandling/index.md) | `TailoredApps.Shared.ExceptionHandling` | Middleware i filter do obsługi wyjątków w Web API | | [ExceptionHandling.MinimalApi](Libraries/ExceptionHandling/MinimalApi.md) | `TailoredApps.Shared.ExceptionHandling.MinimalApi` | Obsługa wyjątków i walidacja FluentValidation dla minimal API (filtry endpointów), zgodna z NativeAOT | -| [MediatR](Libraries/MediatR/index.md) | `TailoredApps.Shared.MediatR` | Pipeline behaviors: Logging, Validation, Caching, Fallback, Retry | -| [MediatR.Caching](Libraries/MediatR/Caching.md) | `TailoredApps.Shared.MediatR.Caching` | Marker interface `ICachableRequest` dla cachowania requestów | -| [MediatR.Email](Libraries/MediatR/Email.md) | `TailoredApps.Shared.MediatR.Email` | `SendMail` command + handler — email przez pipeline MediatR | -| [MediatR.ML](Libraries/MediatR/ML.md) | `TailoredApps.Shared.MediatR.ML` | Klasyfikacja obrazów przez ML.NET w pipelines MediatR | -| [MediatR.PagedRequest](Libraries/MediatR/PagedRequest.md) | `TailoredApps.Shared.MediatR.PagedRequest` | Bazowy request MediatR z paginacją i sortowaniem | +| [Mediator](Libraries/Mediator/index.md) | `TailoredApps.Shared.Mediator` | Pipeline behaviors: Logging, Validation, Caching, Fallback, Retry | +| [Mediator.Caching](Libraries/Mediator/Caching.md) | `TailoredApps.Shared.Mediator.Caching` | Marker interface `ICachableRequest` dla cachowania requestów | +| [Mediator.Email](Libraries/Mediator/Email.md) | `TailoredApps.Shared.Mediator.Email` | `SendMail` command + handler — email przez pipeline'em mediatora | +| [Mediator.ML](Libraries/Mediator/ML.md) | `TailoredApps.Shared.Mediator.ML` | Klasyfikacja obrazów przez ML.NET w pipeline'ach mediatora | +| [Mediator.PagedRequest](Libraries/Mediator/PagedRequest.md) | `TailoredApps.Shared.Mediator.PagedRequest` | Bazowy request mediatora z paginacją i sortowaniem | | [Payments](Libraries/Payments/index.md) | `TailoredApps.Shared.Payments` | Abstrakcja bramki płatności — IPaymentService + IPaymentProvider | | [Payments.Provider.Adyen](Libraries/Payments/Providers/Adyen.md) | `TailoredApps.Shared.Payments.Provider.Adyen` | Integracja Adyen | | [Payments.Provider.CashBill](Libraries/Payments/Providers/CashBill.md) | `TailoredApps.Shared.Payments.Provider.CashBill` | Integracja CashBill | @@ -52,7 +52,7 @@ go przez HTTP w CI. Przechodzisz z 1.x na 2.0? Zmiany wymagane w kodzie aplikacji — obsługa awarii bramki płatności, wymagane pola `PaymentRequest`, webhooki Tpay i Adyen — zebrano na stronie [Aktualizacja do 2.0](Migration/v2.md). -Linia **3.0** jest w fazie testowej (`3.0.0-preview.N`): biblioteki MediatR przechodzą na ForkForward.Mediator. Co zmienić w aplikacji: [Aktualizacja do 3.0](Migration/v3.md). +Linia **3.0** jest w fazie testowej (`3.0.0-preview.N`): biblioteki mediatora przechodzą na ForkForward.Mediator i zmieniają nazwę z `TailoredApps.Shared.MediatR*` na `TailoredApps.Shared.Mediator*`. Co zmienić w aplikacji: [Aktualizacja do 3.0](Migration/v3.md). --- @@ -66,7 +66,7 @@ Od wersji 2.0 biblioteki są wydawane dla `net10.0` i `net11.0`; starsze platfor ```bash # Zainstaluj wybraną bibliotekę -dotnet add package TailoredApps.Shared.MediatR +dotnet add package TailoredApps.Shared.Mediator dotnet add package TailoredApps.Shared.EntityFramework dotnet add package TailoredApps.Shared.Payments ``` diff --git a/mkdocs-en.yml b/mkdocs-en.yml index e65bbf68..6df91a1e 100644 --- a/mkdocs-en.yml +++ b/mkdocs-en.yml @@ -34,12 +34,12 @@ nav: - ExceptionHandling: - Overview: Libraries/ExceptionHandling/index.md - MinimalApi: Libraries/ExceptionHandling/MinimalApi.md - - MediatR: - - Overview: Libraries/MediatR/index.md - - Caching: Libraries/MediatR/Caching.md - - Email: Libraries/MediatR/Email.md - - ML: Libraries/MediatR/ML.md - - PagedRequest: Libraries/MediatR/PagedRequest.md + - Mediator: + - Overview: Libraries/Mediator/index.md + - Caching: Libraries/Mediator/Caching.md + - Email: Libraries/Mediator/Email.md + - ML: Libraries/Mediator/ML.md + - PagedRequest: Libraries/Mediator/PagedRequest.md - Payments: - Overview: Libraries/Payments/index.md - Providers: diff --git a/mkdocs.yml b/mkdocs.yml index 9d2d020b..3a63aeb9 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -33,12 +33,12 @@ nav: - ExceptionHandling: - Overview: Libraries/ExceptionHandling/index.md - MinimalApi: Libraries/ExceptionHandling/MinimalApi.md - - MediatR: - - Overview: Libraries/MediatR/index.md - - Caching: Libraries/MediatR/Caching.md - - Email: Libraries/MediatR/Email.md - - ML: Libraries/MediatR/ML.md - - PagedRequest: Libraries/MediatR/PagedRequest.md + - Mediator: + - Overview: Libraries/Mediator/index.md + - Caching: Libraries/Mediator/Caching.md + - Email: Libraries/Mediator/Email.md + - ML: Libraries/Mediator/ML.md + - PagedRequest: Libraries/Mediator/PagedRequest.md - Payments: - Overview: Libraries/Payments/index.md - Providers: diff --git a/samples/TailoredApps.Shared.Demo.Client/Pages/Catalog.razor b/samples/TailoredApps.Shared.Demo.Client/Pages/Catalog.razor index d30530da..fabc9450 100644 --- a/samples/TailoredApps.Shared.Demo.Client/Pages/Catalog.razor +++ b/samples/TailoredApps.Shared.Demo.Client/Pages/Catalog.razor @@ -7,7 +7,7 @@ Catalogue -@* Paging, sorting and the filter are done by the service (Querying, MediatR.PagedRequest): the table only asks. *@ +@* Paging, sorting and the filter are done by the service (Querying, Mediator.PagedRequest): the table only asks. *@ Catalogue diff --git a/samples/TailoredApps.Shared.Demo.DataModel/Catalog/Messages/Queries/GetProduct.cs b/samples/TailoredApps.Shared.Demo.DataModel/Catalog/Messages/Queries/GetProduct.cs index 9485c6f9..c343bc06 100644 --- a/samples/TailoredApps.Shared.Demo.DataModel/Catalog/Messages/Queries/GetProduct.cs +++ b/samples/TailoredApps.Shared.Demo.DataModel/Catalog/Messages/Queries/GetProduct.cs @@ -1,9 +1,9 @@ using TailoredApps.Demo.DataModel.Catalog.Responses.Queries; -using TailoredApps.Shared.MediatR.Caching; +using TailoredApps.Shared.Mediator.Caching; namespace TailoredApps.Demo.DataModel.Catalog.Messages.Queries; -/// One product. The request names its own cache key (MediatR.Caching); the cache policy in the Services project uses it. +/// One product. The request names its own cache key (Mediator.Caching); the cache policy in the Services project uses it. public class GetProduct : ICachableRequest { public int Id { get; set; } diff --git a/samples/TailoredApps.Shared.Demo.DataModel/Catalog/Messages/Queries/GetProducts.cs b/samples/TailoredApps.Shared.Demo.DataModel/Catalog/Messages/Queries/GetProducts.cs index 3002d07d..9dfd7683 100644 --- a/samples/TailoredApps.Shared.Demo.DataModel/Catalog/Messages/Queries/GetProducts.cs +++ b/samples/TailoredApps.Shared.Demo.DataModel/Catalog/Messages/Queries/GetProducts.cs @@ -1,11 +1,11 @@ using TailoredApps.Demo.DataModel.Catalog.Model; using TailoredApps.Demo.DataModel.Catalog.Responses.Queries; -using TailoredApps.Shared.MediatR.PagedRequest; +using TailoredApps.Shared.Mediator.PagedRequest; using TailoredApps.Shared.Querying; namespace TailoredApps.Demo.DataModel.Catalog.Messages.Queries; -/// A page of products: Querying + MediatR.PagedRequest. +/// A page of products: Querying + Mediator.PagedRequest. public class GetProducts : PagedAndSortedRequest { /// The only properties a client may sort by. diff --git a/samples/TailoredApps.Shared.Demo.DataModel/TailoredApps.Shared.Demo.DataModel.csproj b/samples/TailoredApps.Shared.Demo.DataModel/TailoredApps.Shared.Demo.DataModel.csproj index 96d86f9f..38e2be36 100644 --- a/samples/TailoredApps.Shared.Demo.DataModel/TailoredApps.Shared.Demo.DataModel.csproj +++ b/samples/TailoredApps.Shared.Demo.DataModel/TailoredApps.Shared.Demo.DataModel.csproj @@ -10,8 +10,8 @@ - - + + diff --git a/samples/TailoredApps.Shared.Demo.Services/Catalog/Policies/GetProductCachePolicy.cs b/samples/TailoredApps.Shared.Demo.Services/Catalog/Policies/GetProductCachePolicy.cs index 28638279..036703c5 100644 --- a/samples/TailoredApps.Shared.Demo.Services/Catalog/Policies/GetProductCachePolicy.cs +++ b/samples/TailoredApps.Shared.Demo.Services/Catalog/Policies/GetProductCachePolicy.cs @@ -1,6 +1,6 @@ using TailoredApps.Demo.DataModel.Catalog.Messages.Queries; using TailoredApps.Demo.DataModel.Catalog.Responses.Queries; -using TailoredApps.Shared.MediatR.Interfaces.Caching; +using TailoredApps.Shared.Mediator.Interfaces.Caching; namespace TailoredApps.Demo.Services.Catalog.Policies; diff --git a/samples/TailoredApps.Shared.Demo.Services/Catalog/Policies/GetRecommendationsFallback.cs b/samples/TailoredApps.Shared.Demo.Services/Catalog/Policies/GetRecommendationsFallback.cs index 8dbada8f..a291f322 100644 --- a/samples/TailoredApps.Shared.Demo.Services/Catalog/Policies/GetRecommendationsFallback.cs +++ b/samples/TailoredApps.Shared.Demo.Services/Catalog/Policies/GetRecommendationsFallback.cs @@ -1,6 +1,6 @@ using TailoredApps.Demo.DataModel.Catalog.Messages.Queries; using TailoredApps.Demo.DataModel.Catalog.Responses.Queries; -using TailoredApps.Shared.MediatR.Interfaces.Handlers; +using TailoredApps.Shared.Mediator.Interfaces.Handlers; namespace TailoredApps.Demo.Services.Catalog.Policies; diff --git a/samples/TailoredApps.Shared.Demo.Services/Catalog/Policies/GetRecommendationsRetry.cs b/samples/TailoredApps.Shared.Demo.Services/Catalog/Policies/GetRecommendationsRetry.cs index 58792f25..3e0be8f4 100644 --- a/samples/TailoredApps.Shared.Demo.Services/Catalog/Policies/GetRecommendationsRetry.cs +++ b/samples/TailoredApps.Shared.Demo.Services/Catalog/Policies/GetRecommendationsRetry.cs @@ -1,6 +1,6 @@ using TailoredApps.Demo.DataModel.Catalog.Messages.Queries; using TailoredApps.Demo.DataModel.Catalog.Responses.Queries; -using TailoredApps.Shared.MediatR.Interfaces.Messages; +using TailoredApps.Shared.Mediator.Interfaces.Messages; namespace TailoredApps.Demo.Services.Catalog.Policies; diff --git a/samples/TailoredApps.Shared.Demo.Services/Orders/Notifications/SendOrderConfirmation.cs b/samples/TailoredApps.Shared.Demo.Services/Orders/Notifications/SendOrderConfirmation.cs index 83c3df6a..5b443958 100644 --- a/samples/TailoredApps.Shared.Demo.Services/Orders/Notifications/SendOrderConfirmation.cs +++ b/samples/TailoredApps.Shared.Demo.Services/Orders/Notifications/SendOrderConfirmation.cs @@ -2,12 +2,12 @@ using ForkForward.Mediator; using Microsoft.Extensions.Logging; using TailoredApps.Demo.DataModel.Orders.Messages.Notifications; -using TailoredApps.Shared.MediatR.Email.Messages.Commands; +using TailoredApps.Shared.Mediator.Email.Messages.Commands; namespace TailoredApps.Demo.Services.Orders.Notifications; /// -/// One of the two handlers of : mails the customer (MediatR.Email). +/// One of the two handlers of : mails the customer (Mediator.Email). /// The default publisher runs the handlers one after another and an exception from one of them reaches the /// code that published - here the handler of the gateway's notification. A mail server that is down must /// not turn a confirmed payment into a failed request, so this handler logs its failure and lets it end here. diff --git a/samples/TailoredApps.Shared.Demo.Services/TailoredApps.Shared.Demo.Services.csproj b/samples/TailoredApps.Shared.Demo.Services/TailoredApps.Shared.Demo.Services.csproj index 41b08d48..7f15bda9 100644 --- a/samples/TailoredApps.Shared.Demo.Services/TailoredApps.Shared.Demo.Services.csproj +++ b/samples/TailoredApps.Shared.Demo.Services/TailoredApps.Shared.Demo.Services.csproj @@ -19,8 +19,8 @@ - - + + diff --git a/samples/TailoredApps.Shared.Demo.WebApi/Controllers/OptionalFeaturesController.cs b/samples/TailoredApps.Shared.Demo.WebApi/Controllers/OptionalFeaturesController.cs index 59bee0fd..64bfefb5 100644 --- a/samples/TailoredApps.Shared.Demo.WebApi/Controllers/OptionalFeaturesController.cs +++ b/samples/TailoredApps.Shared.Demo.WebApi/Controllers/OptionalFeaturesController.cs @@ -2,13 +2,13 @@ using Microsoft.AspNetCore.Mvc; using TailoredApps.Shared.Email.Models; using TailoredApps.Shared.Email.Office365; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Message.Commands; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Message.Commands; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Infrastructure; namespace TailoredApps.Demo.WebApi.Controllers; /// -/// The two libraries that need something outside the service: a trained model (MediatR.ML) and an +/// The two libraries that need something outside the service: a trained model (Mediator.ML) and an /// Office 365 mailbox (Email.Office365). Each is wired only when it is configured; otherwise its endpoint /// says so with 501. /// diff --git a/samples/TailoredApps.Shared.Demo.WebApi/Startup.cs b/samples/TailoredApps.Shared.Demo.WebApi/Startup.cs index 2494ccd6..ad1625ff 100644 --- a/samples/TailoredApps.Shared.Demo.WebApi/Startup.cs +++ b/samples/TailoredApps.Shared.Demo.WebApi/Startup.cs @@ -28,10 +28,10 @@ using TailoredApps.Shared.ExceptionHandling.Interfaces; using TailoredApps.Shared.ExceptionHandling.WebApiCore; using TailoredApps.Shared.ExceptionHandling.WebApiCore.Middleware; -using TailoredApps.Shared.MediatR.DI; -using TailoredApps.Shared.MediatR.Email.Handlers; -using TailoredApps.Shared.MediatR.ImageClassification.Infrastructure; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Domain.Models; +using TailoredApps.Shared.Mediator.DI; +using TailoredApps.Shared.Mediator.Email.Handlers; +using TailoredApps.Shared.Mediator.ImageClassification.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Domain.Models; using TailoredApps.Shared.Payments; using TailoredApps.Shared.Payments.Provider.Adyen; using TailoredApps.Shared.Payments.Provider.CashBill; @@ -117,7 +117,7 @@ public void ConfigureServices(IServiceCollection services) // ── ForkForward.Mapper: the profiles of the Services assembly ─────────────────────────────────────── services.AddAutoMapper(typeof(ShopDataContext).Assembly); - // ── ForkForward.Mediator and the MediatR libraries ────────────────────────────────────────────────── + // ── ForkForward.Mediator and the Mediator libraries ────────────────────────────────────────────────── var imageModel = configuration[ImageClassificationOptions.ModelFilePathConfig]; var imageClassification = !string.IsNullOrWhiteSpace(imageModel) && File.Exists(imageModel); @@ -125,9 +125,9 @@ public void ConfigureServices(IServiceCollection services) { // Scanning finds request, stream and notification handlers, exception handlers and exception actions. cfg.RegisterServicesFromAssembly(typeof(ShopDataContext).Assembly); - cfg.RegisterServicesFromAssembly(typeof(SendMailCommandHandler).Assembly); // MediatR.Email + cfg.RegisterServicesFromAssembly(typeof(SendMailCommandHandler).Assembly); // Mediator.Email if (imageClassification) - cfg.RegisterServicesFromAssembly(typeof(AddPredictionEngineExtension).Assembly); // MediatR.ML + cfg.RegisterServicesFromAssembly(typeof(AddPredictionEngineExtension).Assembly); // Mediator.ML // It does not find pre- and post-processors or stream behaviors: these are named. cfg.AddRequestPreProcessor(); @@ -148,7 +148,7 @@ public void ConfigureServices(IServiceCollection services) // The validators the validation behavior (and the minimal-API validation filter) runs. services.AddValidatorsFromAssemblyContaining(); - // ── MediatR.ML: only with a trained model ─────────────────────────────────────────────────────────── + // ── Mediator.ML: only with a trained model ─────────────────────────────────────────────────────────── if (imageClassification) { services.AddPredictionEngine(engine => diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index 7e3f3311..55cc5cd9 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -45,7 +45,8 @@ - + true diff --git a/src/TailoredApps.Shared.MediatR.Email/Interfaces/Handlers/Commands/ISendMailCommandHandler.cs b/src/TailoredApps.Shared.MediatR.Email/Interfaces/Handlers/Commands/ISendMailCommandHandler.cs deleted file mode 100644 index 5aa12c46..00000000 --- a/src/TailoredApps.Shared.MediatR.Email/Interfaces/Handlers/Commands/ISendMailCommandHandler.cs +++ /dev/null @@ -1,13 +0,0 @@ -using ForkForward.Mediator; -using TailoredApps.Shared.MediatR.Email.Messages.Commands; -using TailoredApps.Shared.MediatR.Email.Responses; - -namespace TailoredApps.Shared.MediatR.Email.Interfaces.Handlers.Commands; - -/// -/// Defines the MediatR request handler contract for the command. -/// Implementations are responsible for building the email body and dispatching the message. -/// -public interface ISendMailCommandHandler : IRequestHandler -{ -} diff --git a/src/TailoredApps.Shared.MediatR.ML/Interfaces/Domain/Handlers/Commands/IClassifyImageCommandHandler.cs b/src/TailoredApps.Shared.MediatR.ML/Interfaces/Domain/Handlers/Commands/IClassifyImageCommandHandler.cs deleted file mode 100644 index bb38cb2b..00000000 --- a/src/TailoredApps.Shared.MediatR.ML/Interfaces/Domain/Handlers/Commands/IClassifyImageCommandHandler.cs +++ /dev/null @@ -1,13 +0,0 @@ -using ForkForward.Mediator; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Message.Commands; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Responses.Commands; - -namespace TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Domain.Handlers.Commands; - -/// -/// MediatR handler contract for the command. -/// Implementations run the ML classification pipeline and return a . -/// -public interface IClassifyImageCommandHandler : IRequestHandler -{ -} diff --git a/src/TailoredApps.Shared.MediatR.ML/Interfaces/Domain/Handlers/Commands/ITrainImageClassificationModelCommandHandler.cs b/src/TailoredApps.Shared.MediatR.ML/Interfaces/Domain/Handlers/Commands/ITrainImageClassificationModelCommandHandler.cs deleted file mode 100644 index 5030de01..00000000 --- a/src/TailoredApps.Shared.MediatR.ML/Interfaces/Domain/Handlers/Commands/ITrainImageClassificationModelCommandHandler.cs +++ /dev/null @@ -1,13 +0,0 @@ -using ForkForward.Mediator; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Message.Commands; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Responses.Commands; - -namespace TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Domain.Handlers.Commands; - -/// -/// MediatR handler contract for the command. -/// Implementations train a new ML.NET image classification model and return a . -/// -public interface ITrainImageClassificationModelCommandHandler : IRequestHandler -{ -} diff --git a/src/TailoredApps.Shared.MediatR.Caching/ICachableRequest.cs b/src/TailoredApps.Shared.Mediator.Caching/ICachableRequest.cs similarity index 61% rename from src/TailoredApps.Shared.MediatR.Caching/ICachableRequest.cs rename to src/TailoredApps.Shared.Mediator.Caching/ICachableRequest.cs index 8233cb16..be033643 100644 --- a/src/TailoredApps.Shared.MediatR.Caching/ICachableRequest.cs +++ b/src/TailoredApps.Shared.Mediator.Caching/ICachableRequest.cs @@ -1,8 +1,8 @@ using ForkForward.Mediator; -namespace TailoredApps.Shared.MediatR.Caching; +namespace TailoredApps.Shared.Mediator.Caching; -/// Marker interfejsu dla żądań MediatR, których wynik może być cachowany. +/// Marker interfejsu dla żądań mediatora, których wynik może być cachowany. /// Typ odpowiedzi. public interface ICachableRequest : IRequest { diff --git a/src/TailoredApps.Shared.MediatR.Caching/README.md b/src/TailoredApps.Shared.Mediator.Caching/README.md similarity index 76% rename from src/TailoredApps.Shared.MediatR.Caching/README.md rename to src/TailoredApps.Shared.Mediator.Caching/README.md index a99f861f..bb639792 100644 --- a/src/TailoredApps.Shared.MediatR.Caching/README.md +++ b/src/TailoredApps.Shared.Mediator.Caching/README.md @@ -1,13 +1,13 @@ -# TailoredApps.Shared.MediatR.Caching +# TailoredApps.Shared.Mediator.Caching -A contracts-only package with one interface, `ICachableRequest`: a MediatR request that names its +A contracts-only package with one interface, `ICachableRequest`: a mediator request that names its own cache key. It lets a request type say how its response is identified in a cache without referencing any caching implementation. ## Installation ```bash -dotnet add package TailoredApps.Shared.MediatR.Caching +dotnet add package TailoredApps.Shared.Mediator.Caching ``` ## Registration @@ -17,7 +17,7 @@ Nothing to register: the package has no dependency-injection extension and no se ## Usage ```csharp -using TailoredApps.Shared.MediatR.Caching; +using TailoredApps.Shared.Mediator.Caching; public class GetUserProfile : ICachableRequest { @@ -29,18 +29,18 @@ public class GetUserProfile : ICachableRequest ``` `ICachableRequest` extends `IRequest`, so the request is sent and handled like any other -MediatR request. +mediator request. ## Good to know -- Built on [ForkForward.Mediator](https://www.nuget.org/packages/ForkForward.Mediator), a fork of MediatR 12.5.0 under the Apache-2.0 licence, not on the MediatR package: requests and handlers use the `ForkForward.Mediator` namespace and the mediator is registered with `AddMediator(...)`. "MediatR" in the name of this library is its history, not its dependency. +- Built on [ForkForward.Mediator](https://www.nuget.org/packages/ForkForward.Mediator), a fork of MediatR 12.5.0 under the Apache-2.0 licence, not on the MediatR package: requests and handlers use the `ForkForward.Mediator` namespace and the mediator is registered with `AddMediator(...)`. In 2.x this package was named `TailoredApps.Shared.MediatR.Caching`. - The interface is a marker with a key; nothing in this package stores or reads a cache. -- `CachingBehavior` in `TailoredApps.Shared.MediatR` does not look at `ICachableRequest`. It caches +- `CachingBehavior` in `TailoredApps.Shared.Mediator` does not look at `ICachableRequest`. It caches a request only when an `ICachePolicy` is registered for it. To cache the request above with that behaviour, add a policy that returns the request's own key: ```csharp - using TailoredApps.Shared.MediatR.Interfaces.Caching; + using TailoredApps.Shared.Mediator.Interfaces.Caching; public class GetUserProfileCachePolicy : ICachePolicy { @@ -54,4 +54,4 @@ MediatR request. ## Documentation -https://shared.tailoredapps.pl/en/Libraries/MediatR/Caching/ +https://shared.tailoredapps.pl/en/Libraries/Mediator/Caching/ diff --git a/src/TailoredApps.Shared.MediatR.Caching/TailoredApps.Shared.MediatR.Caching.csproj b/src/TailoredApps.Shared.Mediator.Caching/TailoredApps.Shared.Mediator.Caching.csproj similarity index 100% rename from src/TailoredApps.Shared.MediatR.Caching/TailoredApps.Shared.MediatR.Caching.csproj rename to src/TailoredApps.Shared.Mediator.Caching/TailoredApps.Shared.Mediator.Caching.csproj diff --git a/src/TailoredApps.Shared.MediatR.Email/Handlers/SendMailCommandHandler.cs b/src/TailoredApps.Shared.Mediator.Email/Handlers/SendMailCommandHandler.cs similarity index 84% rename from src/TailoredApps.Shared.MediatR.Email/Handlers/SendMailCommandHandler.cs rename to src/TailoredApps.Shared.Mediator.Email/Handlers/SendMailCommandHandler.cs index eb9422d4..f641e5f3 100644 --- a/src/TailoredApps.Shared.MediatR.Email/Handlers/SendMailCommandHandler.cs +++ b/src/TailoredApps.Shared.Mediator.Email/Handlers/SendMailCommandHandler.cs @@ -3,14 +3,14 @@ using System.Threading.Tasks; using TailoredApps.Shared.Email; using TailoredApps.Shared.Email.MailMessageBuilder; -using TailoredApps.Shared.MediatR.Email.Interfaces.Handlers.Commands; -using TailoredApps.Shared.MediatR.Email.Messages.Commands; -using TailoredApps.Shared.MediatR.Email.Responses; +using TailoredApps.Shared.Mediator.Email.Interfaces.Handlers.Commands; +using TailoredApps.Shared.Mediator.Email.Messages.Commands; +using TailoredApps.Shared.Mediator.Email.Responses; -namespace TailoredApps.Shared.MediatR.Email.Handlers; +namespace TailoredApps.Shared.Mediator.Email.Handlers; /// -/// MediatR request handler that processes a command by building +/// Mediator request handler that processes a command by building /// the email body from a template and dispatching the message via the configured /// . /// diff --git a/src/TailoredApps.Shared.Mediator.Email/Interfaces/Handlers/Commands/ISendMailCommandHandler.cs b/src/TailoredApps.Shared.Mediator.Email/Interfaces/Handlers/Commands/ISendMailCommandHandler.cs new file mode 100644 index 00000000..a8a8e4f1 --- /dev/null +++ b/src/TailoredApps.Shared.Mediator.Email/Interfaces/Handlers/Commands/ISendMailCommandHandler.cs @@ -0,0 +1,13 @@ +using ForkForward.Mediator; +using TailoredApps.Shared.Mediator.Email.Messages.Commands; +using TailoredApps.Shared.Mediator.Email.Responses; + +namespace TailoredApps.Shared.Mediator.Email.Interfaces.Handlers.Commands; + +/// +/// Defines the mediator request handler contract for the command. +/// Implementations are responsible for building the email body and dispatching the message. +/// +public interface ISendMailCommandHandler : IRequestHandler +{ +} diff --git a/src/TailoredApps.Shared.MediatR.Email/Messages/Commands/SendMail.cs b/src/TailoredApps.Shared.Mediator.Email/Messages/Commands/SendMail.cs similarity index 85% rename from src/TailoredApps.Shared.MediatR.Email/Messages/Commands/SendMail.cs rename to src/TailoredApps.Shared.Mediator.Email/Messages/Commands/SendMail.cs index 0258f0ec..37e87efd 100644 --- a/src/TailoredApps.Shared.MediatR.Email/Messages/Commands/SendMail.cs +++ b/src/TailoredApps.Shared.Mediator.Email/Messages/Commands/SendMail.cs @@ -1,11 +1,11 @@ using System.Collections.Generic; using ForkForward.Mediator; -using TailoredApps.Shared.MediatR.Email.Responses; +using TailoredApps.Shared.Mediator.Email.Responses; -namespace TailoredApps.Shared.MediatR.Email.Messages.Commands; +namespace TailoredApps.Shared.Mediator.Email.Messages.Commands; /// -/// MediatR command that triggers sending an email message. +/// Mediator command that triggers sending an email message. /// Carries all data required by the handler to compose and dispatch the email. /// public class SendMail : IRequest diff --git a/src/TailoredApps.Shared.MediatR.Email/README.md b/src/TailoredApps.Shared.Mediator.Email/README.md similarity index 83% rename from src/TailoredApps.Shared.MediatR.Email/README.md rename to src/TailoredApps.Shared.Mediator.Email/README.md index 827e3c6c..30cbae56 100644 --- a/src/TailoredApps.Shared.MediatR.Email/README.md +++ b/src/TailoredApps.Shared.Mediator.Email/README.md @@ -1,24 +1,24 @@ -# TailoredApps.Shared.MediatR.Email +# TailoredApps.Shared.Mediator.Email -Sending e-mail as a MediatR request. The package contains the `SendMail` command and its handler, which builds +Sending e-mail as a mediator request. The package contains the `SendMail` command and its handler, which builds the message body from a template with `IMailMessageBuilder` and sends it through the `IEmailProvider` from `TailoredApps.Shared.Email`. Application code only needs `IMediator`. ## Installation ```bash -dotnet add package TailoredApps.Shared.MediatR.Email +dotnet add package TailoredApps.Shared.Mediator.Email ``` ## Registration The package has no registration extension of its own. Register a mail provider, a message builder and let -MediatR find the handler in this assembly: +the mediator find the handler in this assembly: ```csharp using TailoredApps.Shared.Email; using TailoredApps.Shared.Email.MailMessageBuilder; -using TailoredApps.Shared.MediatR.Email.Handlers; +using TailoredApps.Shared.Mediator.Email.Handlers; builder.Services.RegisterSmtpProvider(); // or RegisterConsoleProvider() builder.Services.Configure(options => @@ -38,7 +38,7 @@ builder.Services.AddMediator(cfg => ## Usage ```csharp -using TailoredApps.Shared.MediatR.Email.Messages.Commands; +using TailoredApps.Shared.Mediator.Email.Messages.Commands; // EmailTemplates/order-confirmation.html:

Order {{OrderNumber}} is on its way.

var result = await mediator.Send(new SendMail @@ -55,7 +55,7 @@ var result = await mediator.Send(new SendMail ## Good to know -- Built on [ForkForward.Mediator](https://www.nuget.org/packages/ForkForward.Mediator), a fork of MediatR 12.5.0 under the Apache-2.0 licence, not on the MediatR package: requests and handlers use the `ForkForward.Mediator` namespace and the mediator is registered with `AddMediator(...)`. "MediatR" in the name of this library is its history, not its dependency. +- Built on [ForkForward.Mediator](https://www.nuget.org/packages/ForkForward.Mediator), a fork of MediatR 12.5.0 under the Apache-2.0 licence, not on the MediatR package: requests and handlers use the `ForkForward.Mediator` namespace and the mediator is registered with `AddMediator(...)`. In 2.x this package was named `TailoredApps.Shared.MediatR.Email`. - The package reads no configuration itself. The SMTP settings (`Mail:Providers:Smtp`) and the template options belong to `TailoredApps.Shared.Email`. @@ -64,7 +64,7 @@ var result = await mediator.Send(new SendMail - `Template` is the template key handed to `IMailMessageBuilder.Build` together with `TemplateVariables` and `Templates`. With `TokenReplacingMailMessageBuilder` it is the template file name including the extension; an unknown key throws `KeyNotFoundException`. `Templates` passes templates inline (key -> content). -- MediatR resolves the handler as `IRequestHandler`. Registering +- The mediator resolves the handler as `IRequestHandler`. Registering `SendMailCommandHandler` only under `ISendMailCommandHandler` is not enough for `mediator.Send`. - Delivery follows the registered `IEmailProvider`. With the SMTP provider that means one recipient per message and redirection to the `CatchAll` address while `IsProd` is `false`. The Office 365 provider cannot send. @@ -74,4 +74,4 @@ var result = await mediator.Send(new SendMail ## Documentation -https://shared.tailoredapps.pl/en/Libraries/MediatR/Email/ +https://shared.tailoredapps.pl/en/Libraries/Mediator/Email/ diff --git a/src/TailoredApps.Shared.MediatR.Email/Responses/SendMailResponse.cs b/src/TailoredApps.Shared.Mediator.Email/Responses/SendMailResponse.cs similarity index 85% rename from src/TailoredApps.Shared.MediatR.Email/Responses/SendMailResponse.cs rename to src/TailoredApps.Shared.Mediator.Email/Responses/SendMailResponse.cs index 9b647a4e..a3014131 100644 --- a/src/TailoredApps.Shared.MediatR.Email/Responses/SendMailResponse.cs +++ b/src/TailoredApps.Shared.Mediator.Email/Responses/SendMailResponse.cs @@ -1,4 +1,4 @@ -namespace TailoredApps.Shared.MediatR.Email.Responses; +namespace TailoredApps.Shared.Mediator.Email.Responses; /// /// Represents the response returned after a command is handled. diff --git a/src/TailoredApps.Shared.MediatR.Email/TailoredApps.Shared.MediatR.Email.csproj b/src/TailoredApps.Shared.Mediator.Email/TailoredApps.Shared.Mediator.Email.csproj similarity index 100% rename from src/TailoredApps.Shared.MediatR.Email/TailoredApps.Shared.MediatR.Email.csproj rename to src/TailoredApps.Shared.Mediator.Email/TailoredApps.Shared.Mediator.Email.csproj diff --git a/src/TailoredApps.Shared.MediatR.ML/Domain/DataModel/Message/Commands/ClassifyImage.cs b/src/TailoredApps.Shared.Mediator.ML/Domain/DataModel/Message/Commands/ClassifyImage.cs similarity index 66% rename from src/TailoredApps.Shared.MediatR.ML/Domain/DataModel/Message/Commands/ClassifyImage.cs rename to src/TailoredApps.Shared.Mediator.ML/Domain/DataModel/Message/Commands/ClassifyImage.cs index 73f927f1..16214d5d 100644 --- a/src/TailoredApps.Shared.MediatR.ML/Domain/DataModel/Message/Commands/ClassifyImage.cs +++ b/src/TailoredApps.Shared.Mediator.ML/Domain/DataModel/Message/Commands/ClassifyImage.cs @@ -1,10 +1,10 @@ using ForkForward.Mediator; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Responses.Commands; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Responses.Commands; -namespace TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Message.Commands; +namespace TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Message.Commands; /// -/// MediatR command that requests classification of a single image. +/// Mediator command that requests classification of a single image. /// Returns a containing the prediction result. /// public class ClassifyImage : IRequest diff --git a/src/TailoredApps.Shared.MediatR.ML/Domain/DataModel/Message/Commands/TrainImageClassificationModel.cs b/src/TailoredApps.Shared.Mediator.ML/Domain/DataModel/Message/Commands/TrainImageClassificationModel.cs similarity index 69% rename from src/TailoredApps.Shared.MediatR.ML/Domain/DataModel/Message/Commands/TrainImageClassificationModel.cs rename to src/TailoredApps.Shared.Mediator.ML/Domain/DataModel/Message/Commands/TrainImageClassificationModel.cs index ae400271..14ded898 100644 --- a/src/TailoredApps.Shared.MediatR.ML/Domain/DataModel/Message/Commands/TrainImageClassificationModel.cs +++ b/src/TailoredApps.Shared.Mediator.ML/Domain/DataModel/Message/Commands/TrainImageClassificationModel.cs @@ -1,10 +1,10 @@ using ForkForward.Mediator; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Responses.Commands; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Responses.Commands; -namespace TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Message.Commands; +namespace TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Message.Commands; /// -/// MediatR command that requests training of a new image classification model +/// Mediator command that requests training of a new image classification model /// from a labelled image dataset. Returns a /// containing the trained model path, version, and evaluation metadata. /// diff --git a/src/TailoredApps.Shared.MediatR.ML/Domain/DataModel/Models/ImagePrediction.cs b/src/TailoredApps.Shared.Mediator.ML/Domain/DataModel/Models/ImagePrediction.cs similarity index 89% rename from src/TailoredApps.Shared.MediatR.ML/Domain/DataModel/Models/ImagePrediction.cs rename to src/TailoredApps.Shared.Mediator.ML/Domain/DataModel/Models/ImagePrediction.cs index 51c0bca9..8207a28e 100644 --- a/src/TailoredApps.Shared.MediatR.ML/Domain/DataModel/Models/ImagePrediction.cs +++ b/src/TailoredApps.Shared.Mediator.ML/Domain/DataModel/Models/ImagePrediction.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; -namespace TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Models; +namespace TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Models; /// /// Represents the result of an image classification prediction, diff --git a/src/TailoredApps.Shared.MediatR.ML/Domain/DataModel/Models/ModelInfo.cs b/src/TailoredApps.Shared.Mediator.ML/Domain/DataModel/Models/ModelInfo.cs similarity index 91% rename from src/TailoredApps.Shared.MediatR.ML/Domain/DataModel/Models/ModelInfo.cs rename to src/TailoredApps.Shared.Mediator.ML/Domain/DataModel/Models/ModelInfo.cs index 5cdb26b7..8cbb1dbc 100644 --- a/src/TailoredApps.Shared.MediatR.ML/Domain/DataModel/Models/ModelInfo.cs +++ b/src/TailoredApps.Shared.Mediator.ML/Domain/DataModel/Models/ModelInfo.cs @@ -1,4 +1,4 @@ -namespace TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Models; +namespace TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Models; /// /// Represents metadata about a trained ML model, including its name, checksum, version, and class labels. diff --git a/src/TailoredApps.Shared.MediatR.ML/Domain/DataModel/Responses/Commands/ClassifyImageResponse.cs b/src/TailoredApps.Shared.Mediator.ML/Domain/DataModel/Responses/Commands/ClassifyImageResponse.cs similarity index 67% rename from src/TailoredApps.Shared.MediatR.ML/Domain/DataModel/Responses/Commands/ClassifyImageResponse.cs rename to src/TailoredApps.Shared.Mediator.ML/Domain/DataModel/Responses/Commands/ClassifyImageResponse.cs index 2eb7db2d..dbb225bf 100644 --- a/src/TailoredApps.Shared.MediatR.ML/Domain/DataModel/Responses/Commands/ClassifyImageResponse.cs +++ b/src/TailoredApps.Shared.Mediator.ML/Domain/DataModel/Responses/Commands/ClassifyImageResponse.cs @@ -1,6 +1,6 @@ -using TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Models; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Models; -namespace TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Responses.Commands; +namespace TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Responses.Commands; /// /// Represents the response returned after handling a ClassifyImage command, diff --git a/src/TailoredApps.Shared.MediatR.ML/Domain/DataModel/Responses/Commands/TrainImageClassificationModelResponse.cs b/src/TailoredApps.Shared.Mediator.ML/Domain/DataModel/Responses/Commands/TrainImageClassificationModelResponse.cs similarity index 81% rename from src/TailoredApps.Shared.MediatR.ML/Domain/DataModel/Responses/Commands/TrainImageClassificationModelResponse.cs rename to src/TailoredApps.Shared.Mediator.ML/Domain/DataModel/Responses/Commands/TrainImageClassificationModelResponse.cs index db2ee72b..86e7e27c 100644 --- a/src/TailoredApps.Shared.MediatR.ML/Domain/DataModel/Responses/Commands/TrainImageClassificationModelResponse.cs +++ b/src/TailoredApps.Shared.Mediator.ML/Domain/DataModel/Responses/Commands/TrainImageClassificationModelResponse.cs @@ -1,6 +1,6 @@ -using TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Models; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Models; -namespace TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Responses.Commands; +namespace TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Responses.Commands; /// /// Represents the response returned after handling a TrainImageClassificationModel command, diff --git a/src/TailoredApps.Shared.MediatR.ML/Domain/Handlers/Commands/ClassifyImageCommandHandler.cs b/src/TailoredApps.Shared.Mediator.ML/Domain/Handlers/Commands/ClassifyImageCommandHandler.cs similarity index 84% rename from src/TailoredApps.Shared.MediatR.ML/Domain/Handlers/Commands/ClassifyImageCommandHandler.cs rename to src/TailoredApps.Shared.Mediator.ML/Domain/Handlers/Commands/ClassifyImageCommandHandler.cs index 9bddb0f9..e391756f 100644 --- a/src/TailoredApps.Shared.MediatR.ML/Domain/Handlers/Commands/ClassifyImageCommandHandler.cs +++ b/src/TailoredApps.Shared.Mediator.ML/Domain/Handlers/Commands/ClassifyImageCommandHandler.cs @@ -2,17 +2,17 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Options; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Message.Commands; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Responses.Commands; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.Validation; -using TailoredApps.Shared.MediatR.ImageClassification.Infrastructure; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Domain.Handlers.Commands; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Message.Commands; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Responses.Commands; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.Validation; +using TailoredApps.Shared.Mediator.ImageClassification.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Domain.Handlers.Commands; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Infrastructure; -namespace TailoredApps.Shared.MediatR.ImageClassification.Domain.Handlers.Commands; +namespace TailoredApps.Shared.Mediator.ImageClassification.Domain.Handlers.Commands; /// -/// Handles the MediatR command by invoking the image classification service +/// Handles the mediator command by invoking the image classification service /// and returning the prediction result. /// /// diff --git a/src/TailoredApps.Shared.MediatR.ML/Domain/Handlers/Commands/TrainImageClassificationModelCommandHandler.cs b/src/TailoredApps.Shared.Mediator.ML/Domain/Handlers/Commands/TrainImageClassificationModelCommandHandler.cs similarity index 92% rename from src/TailoredApps.Shared.MediatR.ML/Domain/Handlers/Commands/TrainImageClassificationModelCommandHandler.cs rename to src/TailoredApps.Shared.Mediator.ML/Domain/Handlers/Commands/TrainImageClassificationModelCommandHandler.cs index 9b596d37..c435bdd1 100644 --- a/src/TailoredApps.Shared.MediatR.ML/Domain/Handlers/Commands/TrainImageClassificationModelCommandHandler.cs +++ b/src/TailoredApps.Shared.Mediator.ML/Domain/Handlers/Commands/TrainImageClassificationModelCommandHandler.cs @@ -5,17 +5,17 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Options; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Message.Commands; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Responses.Commands; -using TailoredApps.Shared.MediatR.ImageClassification.Infrastructure; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Domain.Handlers.Commands; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Infrastructure; -using TailoredApps.Shared.MediatR.ML.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Message.Commands; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Responses.Commands; +using TailoredApps.Shared.Mediator.ImageClassification.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Domain.Handlers.Commands; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Infrastructure; +using TailoredApps.Shared.Mediator.ML.Infrastructure; -namespace TailoredApps.Shared.MediatR.ImageClassification.Domain.Handlers.Commands; +namespace TailoredApps.Shared.Mediator.ImageClassification.Domain.Handlers.Commands; /// -/// Handles the MediatR command by loading training images, +/// Handles the mediator command by loading training images, /// training a classification model, and persisting the result with version and label metadata. /// /// diff --git a/src/TailoredApps.Shared.MediatR.ML/Domain/Validation/ImageValidationExtension.cs b/src/TailoredApps.Shared.Mediator.ML/Domain/Validation/ImageValidationExtension.cs similarity index 94% rename from src/TailoredApps.Shared.MediatR.ML/Domain/Validation/ImageValidationExtension.cs rename to src/TailoredApps.Shared.Mediator.ML/Domain/Validation/ImageValidationExtension.cs index 1f8bf277..3773551c 100644 --- a/src/TailoredApps.Shared.MediatR.ML/Domain/Validation/ImageValidationExtension.cs +++ b/src/TailoredApps.Shared.Mediator.ML/Domain/Validation/ImageValidationExtension.cs @@ -2,7 +2,7 @@ using System.Linq; using System.Text; -namespace TailoredApps.Shared.MediatR.ImageClassification.Domain.Validation; +namespace TailoredApps.Shared.Mediator.ImageClassification.Domain.Validation; /// /// Provides extension methods for validating image byte arrays. diff --git a/src/TailoredApps.Shared.MediatR.ML/Infrastructure/AddPredictionEngineExtension.cs b/src/TailoredApps.Shared.Mediator.ML/Infrastructure/AddPredictionEngineExtension.cs similarity index 86% rename from src/TailoredApps.Shared.MediatR.ML/Infrastructure/AddPredictionEngineExtension.cs rename to src/TailoredApps.Shared.Mediator.ML/Infrastructure/AddPredictionEngineExtension.cs index edc497f9..61e54a99 100644 --- a/src/TailoredApps.Shared.MediatR.ML/Infrastructure/AddPredictionEngineExtension.cs +++ b/src/TailoredApps.Shared.Mediator.ML/Infrastructure/AddPredictionEngineExtension.cs @@ -1,11 +1,11 @@ using System; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.ML; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Infrastructure; -using TailoredApps.Shared.MediatR.ML.Infrastructure; -using static TailoredApps.Shared.MediatR.ImageClassification.Infrastructure.ImageClassificationOptions; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Infrastructure; +using TailoredApps.Shared.Mediator.ML.Infrastructure; +using static TailoredApps.Shared.Mediator.ImageClassification.Infrastructure.ImageClassificationOptions; -namespace TailoredApps.Shared.MediatR.ImageClassification.Infrastructure; +namespace TailoredApps.Shared.Mediator.ImageClassification.Infrastructure; /// /// Provides extension methods for configuring the prediction engine and image classification services diff --git a/src/TailoredApps.Shared.MediatR.ML/Infrastructure/ClassificationService.cs b/src/TailoredApps.Shared.Mediator.ML/Infrastructure/ClassificationService.cs similarity index 93% rename from src/TailoredApps.Shared.MediatR.ML/Infrastructure/ClassificationService.cs rename to src/TailoredApps.Shared.Mediator.ML/Infrastructure/ClassificationService.cs index 7987546f..9396effe 100644 --- a/src/TailoredApps.Shared.MediatR.ML/Infrastructure/ClassificationService.cs +++ b/src/TailoredApps.Shared.Mediator.ML/Infrastructure/ClassificationService.cs @@ -5,12 +5,12 @@ using System.Text; using Microsoft.ML; using Microsoft.ML.Data; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Models; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.Handlers.Commands; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Domain.Models; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Models; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.Handlers.Commands; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Domain.Models; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Infrastructure; -namespace TailoredApps.Shared.MediatR.ImageClassification.Infrastructure; +namespace TailoredApps.Shared.Mediator.ImageClassification.Infrastructure; /// /// Provides image classification and model training functionality using ML.NET. diff --git a/src/TailoredApps.Shared.MediatR.ML/Infrastructure/FileUtils.cs b/src/TailoredApps.Shared.Mediator.ML/Infrastructure/FileUtils.cs similarity index 95% rename from src/TailoredApps.Shared.MediatR.ML/Infrastructure/FileUtils.cs rename to src/TailoredApps.Shared.Mediator.ML/Infrastructure/FileUtils.cs index 8ded3e1a..6b7c5885 100644 --- a/src/TailoredApps.Shared.MediatR.ML/Infrastructure/FileUtils.cs +++ b/src/TailoredApps.Shared.Mediator.ML/Infrastructure/FileUtils.cs @@ -6,7 +6,7 @@ using System.Text; using System.Threading.Tasks; -namespace TailoredApps.Shared.MediatR.ML.Infrastructure; +namespace TailoredApps.Shared.Mediator.ML.Infrastructure; /// /// Provides utility methods for file and directory operations used in ML pipelines. diff --git a/src/TailoredApps.Shared.MediatR.ML/Infrastructure/ImageClassificationOptions.cs b/src/TailoredApps.Shared.Mediator.ML/Infrastructure/ImageClassificationOptions.cs similarity index 98% rename from src/TailoredApps.Shared.MediatR.ML/Infrastructure/ImageClassificationOptions.cs rename to src/TailoredApps.Shared.Mediator.ML/Infrastructure/ImageClassificationOptions.cs index 37554c6b..f94223a8 100644 --- a/src/TailoredApps.Shared.MediatR.ML/Infrastructure/ImageClassificationOptions.cs +++ b/src/TailoredApps.Shared.Mediator.ML/Infrastructure/ImageClassificationOptions.cs @@ -1,7 +1,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Options; -namespace TailoredApps.Shared.MediatR.ImageClassification.Infrastructure; +namespace TailoredApps.Shared.Mediator.ImageClassification.Infrastructure; /// /// Configuration options for the image classification feature, bound from the application configuration. diff --git a/src/TailoredApps.Shared.MediatR.ML/Infrastructure/ModelHelper.cs b/src/TailoredApps.Shared.Mediator.ML/Infrastructure/ModelHelper.cs similarity index 94% rename from src/TailoredApps.Shared.MediatR.ML/Infrastructure/ModelHelper.cs rename to src/TailoredApps.Shared.Mediator.ML/Infrastructure/ModelHelper.cs index 72aa0525..7508703d 100644 --- a/src/TailoredApps.Shared.MediatR.ML/Infrastructure/ModelHelper.cs +++ b/src/TailoredApps.Shared.Mediator.ML/Infrastructure/ModelHelper.cs @@ -3,9 +3,9 @@ using System.IO.Compression; using System.Linq; using System.Security.Cryptography; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Infrastructure; -namespace TailoredApps.Shared.MediatR.ImageClassification.Infrastructure; +namespace TailoredApps.Shared.Mediator.ImageClassification.Infrastructure; /// /// Provides helper operations for ML model files, including versioning, label management, and checksum computation. diff --git a/src/TailoredApps.Shared.MediatR.ML/Infrastructure/ModelInfoService.cs b/src/TailoredApps.Shared.Mediator.ML/Infrastructure/ModelInfoService.cs similarity index 86% rename from src/TailoredApps.Shared.MediatR.ML/Infrastructure/ModelInfoService.cs rename to src/TailoredApps.Shared.Mediator.ML/Infrastructure/ModelInfoService.cs index 5aae8c1b..8c274f13 100644 --- a/src/TailoredApps.Shared.MediatR.ML/Infrastructure/ModelInfoService.cs +++ b/src/TailoredApps.Shared.Mediator.ML/Infrastructure/ModelInfoService.cs @@ -1,9 +1,9 @@ using System.IO; using Microsoft.Extensions.Options; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Domain.Models; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Domain.Models; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Infrastructure; -namespace TailoredApps.Shared.MediatR.ImageClassification.Infrastructure; +namespace TailoredApps.Shared.Mediator.ImageClassification.Infrastructure; /// /// Provides metadata about the currently configured ML model by reading from the model file and configuration. diff --git a/src/TailoredApps.Shared.MediatR.ML/Infrastructure/PredictionEnginePoolAdapter.cs b/src/TailoredApps.Shared.Mediator.ML/Infrastructure/PredictionEnginePoolAdapter.cs similarity index 91% rename from src/TailoredApps.Shared.MediatR.ML/Infrastructure/PredictionEnginePoolAdapter.cs rename to src/TailoredApps.Shared.Mediator.ML/Infrastructure/PredictionEnginePoolAdapter.cs index 3f8739b3..9efb8827 100644 --- a/src/TailoredApps.Shared.MediatR.ML/Infrastructure/PredictionEnginePoolAdapter.cs +++ b/src/TailoredApps.Shared.Mediator.ML/Infrastructure/PredictionEnginePoolAdapter.cs @@ -2,9 +2,9 @@ using System.Linq; using Microsoft.Extensions.ML; using Microsoft.ML.Data; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Infrastructure; -namespace TailoredApps.Shared.MediatR.ImageClassification.Infrastructure; +namespace TailoredApps.Shared.Mediator.ImageClassification.Infrastructure; /// /// Adapts a to the diff --git a/src/TailoredApps.Shared.MediatR.ML/Infrastructure/PredictionEngineServiceConfiguration.cs b/src/TailoredApps.Shared.Mediator.ML/Infrastructure/PredictionEngineServiceConfiguration.cs similarity index 89% rename from src/TailoredApps.Shared.MediatR.ML/Infrastructure/PredictionEngineServiceConfiguration.cs rename to src/TailoredApps.Shared.Mediator.ML/Infrastructure/PredictionEngineServiceConfiguration.cs index 6babba60..8681ae89 100644 --- a/src/TailoredApps.Shared.MediatR.ML/Infrastructure/PredictionEngineServiceConfiguration.cs +++ b/src/TailoredApps.Shared.Mediator.ML/Infrastructure/PredictionEngineServiceConfiguration.cs @@ -1,9 +1,9 @@ using System; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.ML; -using TailoredApps.Shared.MediatR.ImageClassification.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Infrastructure; -namespace TailoredApps.Shared.MediatR.ML.Infrastructure; +namespace TailoredApps.Shared.Mediator.ML.Infrastructure; /// /// Provides configuration support for registering machine learning prediction engine models diff --git a/src/TailoredApps.Shared.Mediator.ML/Interfaces/Domain/Handlers/Commands/IClassifyImageCommandHandler.cs b/src/TailoredApps.Shared.Mediator.ML/Interfaces/Domain/Handlers/Commands/IClassifyImageCommandHandler.cs new file mode 100644 index 00000000..581945f2 --- /dev/null +++ b/src/TailoredApps.Shared.Mediator.ML/Interfaces/Domain/Handlers/Commands/IClassifyImageCommandHandler.cs @@ -0,0 +1,13 @@ +using ForkForward.Mediator; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Message.Commands; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Responses.Commands; + +namespace TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Domain.Handlers.Commands; + +/// +/// Mediator handler contract for the command. +/// Implementations run the ML classification pipeline and return a . +/// +public interface IClassifyImageCommandHandler : IRequestHandler +{ +} diff --git a/src/TailoredApps.Shared.Mediator.ML/Interfaces/Domain/Handlers/Commands/ITrainImageClassificationModelCommandHandler.cs b/src/TailoredApps.Shared.Mediator.ML/Interfaces/Domain/Handlers/Commands/ITrainImageClassificationModelCommandHandler.cs new file mode 100644 index 00000000..6e5325d3 --- /dev/null +++ b/src/TailoredApps.Shared.Mediator.ML/Interfaces/Domain/Handlers/Commands/ITrainImageClassificationModelCommandHandler.cs @@ -0,0 +1,13 @@ +using ForkForward.Mediator; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Message.Commands; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Responses.Commands; + +namespace TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Domain.Handlers.Commands; + +/// +/// Mediator handler contract for the command. +/// Implementations train a new ML.NET image classification model and return a . +/// +public interface ITrainImageClassificationModelCommandHandler : IRequestHandler +{ +} diff --git a/src/TailoredApps.Shared.MediatR.ML/Interfaces/Domain/Models/ImagePredictionScore.cs b/src/TailoredApps.Shared.Mediator.ML/Interfaces/Domain/Models/ImagePredictionScore.cs similarity index 85% rename from src/TailoredApps.Shared.MediatR.ML/Interfaces/Domain/Models/ImagePredictionScore.cs rename to src/TailoredApps.Shared.Mediator.ML/Interfaces/Domain/Models/ImagePredictionScore.cs index 4eeb28e2..1d45bffb 100644 --- a/src/TailoredApps.Shared.MediatR.ML/Interfaces/Domain/Models/ImagePredictionScore.cs +++ b/src/TailoredApps.Shared.Mediator.ML/Interfaces/Domain/Models/ImagePredictionScore.cs @@ -1,6 +1,6 @@ using Microsoft.ML.Data; -namespace TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Domain.Models; +namespace TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Domain.Models; /// /// Represents the raw output of the ML.NET image classification prediction engine, diff --git a/src/TailoredApps.Shared.MediatR.ML/Interfaces/Domain/Models/InMemoryImageData.cs b/src/TailoredApps.Shared.Mediator.ML/Interfaces/Domain/Models/InMemoryImageData.cs similarity index 90% rename from src/TailoredApps.Shared.MediatR.ML/Interfaces/Domain/Models/InMemoryImageData.cs rename to src/TailoredApps.Shared.Mediator.ML/Interfaces/Domain/Models/InMemoryImageData.cs index 34e5e5d7..0dea9b69 100644 --- a/src/TailoredApps.Shared.MediatR.ML/Interfaces/Domain/Models/InMemoryImageData.cs +++ b/src/TailoredApps.Shared.Mediator.ML/Interfaces/Domain/Models/InMemoryImageData.cs @@ -1,4 +1,4 @@ -namespace TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Domain.Models; +namespace TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Domain.Models; /// /// Represents an in-memory image along with its optional label and file name, diff --git a/src/TailoredApps.Shared.MediatR.ML/Interfaces/Infrastructure/IClassificationService.cs b/src/TailoredApps.Shared.Mediator.ML/Interfaces/Infrastructure/IClassificationService.cs similarity index 84% rename from src/TailoredApps.Shared.MediatR.ML/Interfaces/Infrastructure/IClassificationService.cs rename to src/TailoredApps.Shared.Mediator.ML/Interfaces/Infrastructure/IClassificationService.cs index 8fd22466..f47e34b7 100644 --- a/src/TailoredApps.Shared.MediatR.ML/Interfaces/Infrastructure/IClassificationService.cs +++ b/src/TailoredApps.Shared.Mediator.ML/Interfaces/Infrastructure/IClassificationService.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Models; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.Handlers.Commands; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Models; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.Handlers.Commands; -namespace TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Infrastructure; +namespace TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Infrastructure; /// /// Abstraction for the image classification service that wraps the ML.NET prediction engine. diff --git a/src/TailoredApps.Shared.MediatR.ML/Interfaces/Infrastructure/IModelHelper.cs b/src/TailoredApps.Shared.Mediator.ML/Interfaces/Infrastructure/IModelHelper.cs similarity index 92% rename from src/TailoredApps.Shared.MediatR.ML/Interfaces/Infrastructure/IModelHelper.cs rename to src/TailoredApps.Shared.Mediator.ML/Interfaces/Infrastructure/IModelHelper.cs index 7670137f..22306f39 100644 --- a/src/TailoredApps.Shared.MediatR.ML/Interfaces/Infrastructure/IModelHelper.cs +++ b/src/TailoredApps.Shared.Mediator.ML/Interfaces/Infrastructure/IModelHelper.cs @@ -1,4 +1,4 @@ -namespace TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Infrastructure; +namespace TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Infrastructure; /// /// Provides helpers for reading and writing metadata embedded inside a trained ML.NET model file. diff --git a/src/TailoredApps.Shared.MediatR.ML/Interfaces/Infrastructure/IModelInfoService.cs b/src/TailoredApps.Shared.Mediator.ML/Interfaces/Infrastructure/IModelInfoService.cs similarity index 87% rename from src/TailoredApps.Shared.MediatR.ML/Interfaces/Infrastructure/IModelInfoService.cs rename to src/TailoredApps.Shared.Mediator.ML/Interfaces/Infrastructure/IModelInfoService.cs index fb4960ac..00bd29ba 100644 --- a/src/TailoredApps.Shared.MediatR.ML/Interfaces/Infrastructure/IModelInfoService.cs +++ b/src/TailoredApps.Shared.Mediator.ML/Interfaces/Infrastructure/IModelInfoService.cs @@ -1,4 +1,4 @@ -namespace TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Infrastructure; +namespace TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Infrastructure; /// /// Exposes metadata about the currently loaded image classification model. diff --git a/src/TailoredApps.Shared.MediatR.ML/Interfaces/Infrastructure/IPredictionEnginePoolAdapter.cs b/src/TailoredApps.Shared.Mediator.ML/Interfaces/Infrastructure/IPredictionEnginePoolAdapter.cs similarity index 88% rename from src/TailoredApps.Shared.MediatR.ML/Interfaces/Infrastructure/IPredictionEnginePoolAdapter.cs rename to src/TailoredApps.Shared.Mediator.ML/Interfaces/Infrastructure/IPredictionEnginePoolAdapter.cs index 1cb56a55..fcbe338d 100644 --- a/src/TailoredApps.Shared.MediatR.ML/Interfaces/Infrastructure/IPredictionEnginePoolAdapter.cs +++ b/src/TailoredApps.Shared.Mediator.ML/Interfaces/Infrastructure/IPredictionEnginePoolAdapter.cs @@ -1,4 +1,4 @@ -namespace TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Infrastructure; +namespace TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Infrastructure; /// /// Adapter that wraps an ML.NET PredictionEnginePool and exposes a simplified prediction API. diff --git a/src/TailoredApps.Shared.MediatR.ML/README.md b/src/TailoredApps.Shared.Mediator.ML/README.md similarity index 83% rename from src/TailoredApps.Shared.MediatR.ML/README.md rename to src/TailoredApps.Shared.Mediator.ML/README.md index 1ce488ef..161cda2f 100644 --- a/src/TailoredApps.Shared.MediatR.ML/README.md +++ b/src/TailoredApps.Shared.Mediator.ML/README.md @@ -1,21 +1,21 @@ -# TailoredApps.Shared.MediatR.ML +# TailoredApps.Shared.Mediator.ML -Image classification with ML.NET as MediatR requests. `ClassifyImage` runs a trained model on an uploaded image +Image classification with ML.NET as mediator requests. `ClassifyImage` runs a trained model on an uploaded image and `TrainImageClassificationModel` trains a new model from folders of labelled images. The code lives in the -namespace `TailoredApps.Shared.MediatR.ImageClassification`, not under the package name. +namespace `TailoredApps.Shared.Mediator.ImageClassification`, not under the package name. ## Installation ```bash -dotnet add package TailoredApps.Shared.MediatR.ML +dotnet add package TailoredApps.Shared.Mediator.ML ``` ## Registration ```csharp using Microsoft.Extensions.ML; -using TailoredApps.Shared.MediatR.ImageClassification.Infrastructure; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Domain.Models; +using TailoredApps.Shared.Mediator.ImageClassification.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Domain.Models; // The handlers of both commands are in this package's assembly builder.Services.AddMediator(cfg => @@ -36,7 +36,7 @@ where the model is loaded from is decided by the pool builder you configure (`Fr ## Usage ```csharp -using TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Message.Commands; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Message.Commands; var classified = await mediator.Send(new ClassifyImage { FileByteArray = imageBytes, FileName = "photo.jpg" }); var label = classified.ImagePrediction?.PredictedLabel; @@ -74,7 +74,7 @@ The `ImageClassification` section: ## Good to know -- Built on [ForkForward.Mediator](https://www.nuget.org/packages/ForkForward.Mediator), a fork of MediatR 12.5.0 under the Apache-2.0 licence, not on the MediatR package: requests and handlers use the `ForkForward.Mediator` namespace and the mediator is registered with `AddMediator(...)`. "MediatR" in the name of this library is its history, not its dependency. +- Built on [ForkForward.Mediator](https://www.nuget.org/packages/ForkForward.Mediator), a fork of MediatR 12.5.0 under the Apache-2.0 licence, not on the MediatR package: requests and handlers use the `ForkForward.Mediator` namespace and the mediator is registered with `AddMediator(...)`. In 2.x this package was named `TailoredApps.Shared.MediatR.ML`. - The section is required: without it the options throw `InvalidOperationException` when first used. - `ClassifyImage` throws `ArgumentException` for empty content, for content over `MaxImageBytes` and for content that does not start with a JPEG or PNG signature. Only `FileName`, `PredictedLabel` and @@ -87,8 +87,8 @@ The `ImageClassification` section: timestamp) and `Labels.txt` are added. - Prediction uses the default model of the pool, so register the model without a model name. - `PredictionEngineServiceConfiguration` is the one public type in the namespace - `TailoredApps.Shared.MediatR.ML.Infrastructure`. + `TailoredApps.Shared.Mediator.ML.Infrastructure`. ## Documentation -https://shared.tailoredapps.pl/en/Libraries/MediatR/ML/ +https://shared.tailoredapps.pl/en/Libraries/Mediator/ML/ diff --git a/src/TailoredApps.Shared.MediatR.ML/TailoredApps.Shared.MediatR.ML.csproj b/src/TailoredApps.Shared.Mediator.ML/TailoredApps.Shared.Mediator.ML.csproj similarity index 82% rename from src/TailoredApps.Shared.MediatR.ML/TailoredApps.Shared.MediatR.ML.csproj rename to src/TailoredApps.Shared.Mediator.ML/TailoredApps.Shared.Mediator.ML.csproj index b6c280d1..748b30e4 100644 --- a/src/TailoredApps.Shared.MediatR.ML/TailoredApps.Shared.MediatR.ML.csproj +++ b/src/TailoredApps.Shared.Mediator.ML/TailoredApps.Shared.Mediator.ML.csproj @@ -14,11 +14,11 @@ - + - + diff --git a/src/TailoredApps.Shared.MediatR.PagedRequest/PagedAndSortedRequest.cs b/src/TailoredApps.Shared.Mediator.PagedRequest/PagedAndSortedRequest.cs similarity index 89% rename from src/TailoredApps.Shared.MediatR.PagedRequest/PagedAndSortedRequest.cs rename to src/TailoredApps.Shared.Mediator.PagedRequest/PagedAndSortedRequest.cs index 5c01d156..3be309dc 100644 --- a/src/TailoredApps.Shared.MediatR.PagedRequest/PagedAndSortedRequest.cs +++ b/src/TailoredApps.Shared.Mediator.PagedRequest/PagedAndSortedRequest.cs @@ -2,11 +2,11 @@ using ForkForward.Mediator; using TailoredApps.Shared.Querying; -namespace TailoredApps.Shared.MediatR.PagedRequest; +namespace TailoredApps.Shared.Mediator.PagedRequest; /// -/// Base MediatR request that combines paging and sorting parameters. -/// Implement this to pass paged + sorted queries through the MediatR pipeline. +/// Base mediator request that combines paging and sorting parameters. +/// Implement this to pass paged + sorted queries through the mediator pipeline. /// /// The response type returned by the handler (must implement ). /// The filter/query object type (must derive from ). diff --git a/src/TailoredApps.Shared.MediatR.PagedRequest/README.md b/src/TailoredApps.Shared.Mediator.PagedRequest/README.md similarity index 88% rename from src/TailoredApps.Shared.MediatR.PagedRequest/README.md rename to src/TailoredApps.Shared.Mediator.PagedRequest/README.md index fce1683d..51cc0f2a 100644 --- a/src/TailoredApps.Shared.MediatR.PagedRequest/README.md +++ b/src/TailoredApps.Shared.Mediator.PagedRequest/README.md @@ -1,19 +1,19 @@ -# TailoredApps.Shared.MediatR.PagedRequest +# TailoredApps.Shared.Mediator.PagedRequest -`PagedAndSortedRequest`: a base class for MediatR requests that return one page of a +`PagedAndSortedRequest`: a base class for mediator requests that return one page of a list. It carries the page, the page size, the sort field and direction and a filter object, so every list request in an application has the same shape. The contracts it implements come from `TailoredApps.Shared.Querying`. ## Installation ```bash -dotnet add package TailoredApps.Shared.MediatR.PagedRequest +dotnet add package TailoredApps.Shared.Mediator.PagedRequest ``` ## Registration Nothing to register: the package has no dependency-injection extension. Requests derived from the base class -are ordinary MediatR requests (`IRequest`). +are ordinary mediator requests (`IRequest`). ## Usage @@ -22,7 +22,7 @@ the request directly and validate what the client sent. ```csharp using TailoredApps.Shared.EntityFramework.Querying; -using TailoredApps.Shared.MediatR.PagedRequest; +using TailoredApps.Shared.Mediator.PagedRequest; using TailoredApps.Shared.Querying; public class ProductFilter : QueryBase @@ -66,7 +66,7 @@ public class GetProductsHandler(ShopDbContext db) : IRequestHandler`. - The class only carries the values. `Page`, `Count` and `SortField` usually come straight from the HTTP request and are not checked here: a handler that calls `Skip`/`Take` itself has to limit the page size. @@ -79,4 +79,4 @@ public class GetProductsHandler(ShopDbContext db) : IRequestHandler /// Gives serializers built from the JSON metadata of a , diff --git a/src/TailoredApps.Shared.MediatR/DI/PipelineRegistration.cs b/src/TailoredApps.Shared.Mediator/DI/PipelineRegistration.cs similarity index 93% rename from src/TailoredApps.Shared.MediatR/DI/PipelineRegistration.cs rename to src/TailoredApps.Shared.Mediator/DI/PipelineRegistration.cs index d24b81fb..63c2cf77 100644 --- a/src/TailoredApps.Shared.MediatR/DI/PipelineRegistration.cs +++ b/src/TailoredApps.Shared.Mediator/DI/PipelineRegistration.cs @@ -6,18 +6,18 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Scrutor; -using TailoredApps.Shared.MediatR.Caching; -using TailoredApps.Shared.MediatR.Interfaces.Caching; -using TailoredApps.Shared.MediatR.Interfaces.DI; -using TailoredApps.Shared.MediatR.Interfaces.Handlers; -using TailoredApps.Shared.MediatR.Interfaces.Messages; -using TailoredApps.Shared.MediatR.PipelineBehaviours; +using TailoredApps.Shared.Mediator.Caching; +using TailoredApps.Shared.Mediator.Interfaces.Caching; +using TailoredApps.Shared.Mediator.Interfaces.DI; +using TailoredApps.Shared.Mediator.Interfaces.Handlers; +using TailoredApps.Shared.Mediator.Interfaces.Messages; +using TailoredApps.Shared.Mediator.PipelineBehaviours; -namespace TailoredApps.Shared.MediatR.DI; +namespace TailoredApps.Shared.Mediator.DI; /// /// Default implementation of that registers all standard -/// MediatR pipeline behaviors (Logging, Validation, Caching, Fallback, Retry) into the +/// Mediator pipeline behaviors (Logging, Validation, Caching, Fallback, Retry) into the /// dependency injection container. /// public class PipelineRegistration : IPipelineRegistration @@ -40,7 +40,7 @@ public void RegisterPipelineBehaviors() // registered IDistributedCache. Nothing is replaced if the host has already added one. serviceCollection.AddHybridCache(); - // Register MediatR Pipeline Behaviors + // Register the pipeline behaviors serviceCollection.AddTransient(typeof(IPipelineBehavior<,>), typeof(LoggingBehavior<,>)); serviceCollection.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>)); serviceCollection.AddTransient(typeof(IPipelineBehavior<,>), typeof(CachingBehavior<,>)); diff --git a/src/TailoredApps.Shared.MediatR/Interfaces/Caching/ICachePolicy.cs b/src/TailoredApps.Shared.Mediator/Interfaces/Caching/ICachePolicy.cs similarity index 95% rename from src/TailoredApps.Shared.MediatR/Interfaces/Caching/ICachePolicy.cs rename to src/TailoredApps.Shared.Mediator/Interfaces/Caching/ICachePolicy.cs index 3f9e37be..6502d1ff 100644 --- a/src/TailoredApps.Shared.MediatR/Interfaces/Caching/ICachePolicy.cs +++ b/src/TailoredApps.Shared.Mediator/Interfaces/Caching/ICachePolicy.cs @@ -8,10 +8,10 @@ using System.Text.Json.Serialization.Metadata; using ForkForward.Mediator; -namespace TailoredApps.Shared.MediatR.Interfaces.Caching; +namespace TailoredApps.Shared.Mediator.Interfaces.Caching; /// -/// Defines the caching policy for a MediatR request/response pair. +/// Defines the caching policy for a mediator request/response pair. /// Provides default expiration values via C# 8.0 default interface implementations. /// Implement this interface to customise cache key generation or expiration strategy /// for a specific request type. @@ -24,7 +24,7 @@ namespace TailoredApps.Shared.MediatR.Interfaces.Caching; /// and prefix the key with the caller's identity, or responses will be /// shared between users. /// -/// The type of the MediatR request. +/// The type of the mediator request. /// The type of the response. public interface ICachePolicy where TRequest : IRequest { @@ -58,7 +58,7 @@ public interface ICachePolicy where TRequest : IRequest - /// The MediatR request instance. + /// The mediator request instance. /// A string that uniquely identifies this request's content in the cache. string GetCacheKey(TRequest request) { @@ -67,7 +67,7 @@ string GetCacheKey(TRequest request) } /// -/// Builds content-based cache keys for MediatR requests. +/// Builds content-based cache keys for mediator requests. /// public static class CacheKeyGenerator { diff --git a/src/TailoredApps.Shared.MediatR/Interfaces/DI/IPipelineRegistration.cs b/src/TailoredApps.Shared.Mediator/Interfaces/DI/IPipelineRegistration.cs similarity index 87% rename from src/TailoredApps.Shared.MediatR/Interfaces/DI/IPipelineRegistration.cs rename to src/TailoredApps.Shared.Mediator/Interfaces/DI/IPipelineRegistration.cs index 7e444029..e82a9a27 100644 --- a/src/TailoredApps.Shared.MediatR/Interfaces/DI/IPipelineRegistration.cs +++ b/src/TailoredApps.Shared.Mediator/Interfaces/DI/IPipelineRegistration.cs @@ -1,10 +1,10 @@ using System.Diagnostics.CodeAnalysis; using System.Reflection; -namespace TailoredApps.Shared.MediatR.Interfaces.DI; +namespace TailoredApps.Shared.Mediator.Interfaces.DI; /// -/// Contract for registering MediatR pipeline behaviors into the dependency injection container. +/// Contract for registering mediator pipeline behaviors into the dependency injection container. /// public interface IPipelineRegistration { diff --git a/src/TailoredApps.Shared.MediatR/Interfaces/Handlers/IFallbackHandler.cs b/src/TailoredApps.Shared.Mediator/Interfaces/Handlers/IFallbackHandler.cs similarity index 66% rename from src/TailoredApps.Shared.MediatR/Interfaces/Handlers/IFallbackHandler.cs rename to src/TailoredApps.Shared.Mediator/Interfaces/Handlers/IFallbackHandler.cs index 3cec72c0..ee450cf7 100644 --- a/src/TailoredApps.Shared.MediatR/Interfaces/Handlers/IFallbackHandler.cs +++ b/src/TailoredApps.Shared.Mediator/Interfaces/Handlers/IFallbackHandler.cs @@ -2,14 +2,14 @@ using System.Threading.Tasks; using ForkForward.Mediator; -namespace TailoredApps.Shared.MediatR.Interfaces.Handlers; +namespace TailoredApps.Shared.Mediator.Interfaces.Handlers; /// -/// Fallback handler invoked by -/// when the primary MediatR handler throws an exception. Implement this interface to provide +/// Fallback handler invoked by +/// when the primary mediator handler throws an exception. Implement this interface to provide /// a graceful alternative response instead of propagating the error. /// -/// The type of the MediatR request. +/// The type of the mediator request. /// The type of the response. public interface IFallbackHandler where TRequest : IRequest { @@ -17,7 +17,7 @@ public interface IFallbackHandler where TRequest : IRequest /// Handles the request in fallback mode, providing an alternative response when the /// primary handler has failed. /// - /// The original MediatR request that triggered the fallback. + /// The original mediator request that triggered the fallback. /// A token to cancel the asynchronous operation. /// A fallback response of type . Task HandleFallback(TRequest request, CancellationToken cancellationToken); diff --git a/src/TailoredApps.Shared.MediatR/Interfaces/Messages/IRetryableRequest.cs b/src/TailoredApps.Shared.Mediator/Interfaces/Messages/IRetryableRequest.cs similarity index 80% rename from src/TailoredApps.Shared.MediatR/Interfaces/Messages/IRetryableRequest.cs rename to src/TailoredApps.Shared.Mediator/Interfaces/Messages/IRetryableRequest.cs index 564ef955..4913b121 100644 --- a/src/TailoredApps.Shared.MediatR/Interfaces/Messages/IRetryableRequest.cs +++ b/src/TailoredApps.Shared.Mediator/Interfaces/Messages/IRetryableRequest.cs @@ -1,13 +1,13 @@ using ForkForward.Mediator; -namespace TailoredApps.Shared.MediatR.Interfaces.Messages; +namespace TailoredApps.Shared.Mediator.Interfaces.Messages; /// -/// Marker interface for MediatR requests that support retry and circuit-breaker behaviour. +/// Marker interface for mediator requests that support retry and circuit-breaker behaviour. /// Implement this interface on a request class (or a dedicated policy class) to configure /// retry attempts, delay, exponential backoff, and circuit-breaker thresholds. /// -/// The type of the MediatR request. +/// The type of the mediator request. /// The type of the response. public interface IRetryableRequest where TRequest : IRequest { diff --git a/src/TailoredApps.Shared.MediatR/PipelineBehaviours/CachingBehavior.cs b/src/TailoredApps.Shared.Mediator/PipelineBehaviours/CachingBehavior.cs similarity index 91% rename from src/TailoredApps.Shared.MediatR/PipelineBehaviours/CachingBehavior.cs rename to src/TailoredApps.Shared.Mediator/PipelineBehaviours/CachingBehavior.cs index 9e5628ae..c65eb6bc 100644 --- a/src/TailoredApps.Shared.MediatR/PipelineBehaviours/CachingBehavior.cs +++ b/src/TailoredApps.Shared.Mediator/PipelineBehaviours/CachingBehavior.cs @@ -6,12 +6,12 @@ using ForkForward.Mediator; using Microsoft.Extensions.Caching.Hybrid; using Microsoft.Extensions.Logging; -using TailoredApps.Shared.MediatR.Interfaces.Caching; +using TailoredApps.Shared.Mediator.Interfaces.Caching; -namespace TailoredApps.Shared.MediatR.PipelineBehaviours; +namespace TailoredApps.Shared.Mediator.PipelineBehaviours; /// -/// MediatR pipeline behavior that caches responses in . A request with an +/// Mediator pipeline behavior that caches responses in . A request with an /// is answered from the cache when an entry exists; /// otherwise the handler runs and its response is stored according to the policy. /// @@ -26,7 +26,7 @@ namespace TailoredApps.Shared.MediatR.PipelineBehaviours; /// 0 or false. A handler that throws caches nothing. /// /// -/// The type of the MediatR request. +/// The type of the mediator request. /// The type of the response. public class CachingBehavior : IPipelineBehavior where TRequest : IRequest { @@ -62,7 +62,7 @@ public CachingBehavior( /// pipeline step and caching its response. If no cache policy is registered for the request type, /// the pipeline continues without caching. /// - /// The incoming MediatR request. + /// The incoming mediator request. /// The next handler delegate in the pipeline. /// Token used to cancel the operation. /// The response, either from the cache or from the handler. diff --git a/src/TailoredApps.Shared.MediatR/PipelineBehaviours/CircuitBreakerOpenException.cs b/src/TailoredApps.Shared.Mediator/PipelineBehaviours/CircuitBreakerOpenException.cs similarity index 95% rename from src/TailoredApps.Shared.MediatR/PipelineBehaviours/CircuitBreakerOpenException.cs rename to src/TailoredApps.Shared.Mediator/PipelineBehaviours/CircuitBreakerOpenException.cs index a6f7cbf3..b186b5be 100644 --- a/src/TailoredApps.Shared.MediatR/PipelineBehaviours/CircuitBreakerOpenException.cs +++ b/src/TailoredApps.Shared.Mediator/PipelineBehaviours/CircuitBreakerOpenException.cs @@ -1,6 +1,6 @@ using System; -namespace TailoredApps.Shared.MediatR.PipelineBehaviours; +namespace TailoredApps.Shared.Mediator.PipelineBehaviours; /// /// Thrown by when requests of a type keep failing and diff --git a/src/TailoredApps.Shared.MediatR/PipelineBehaviours/FallbackBehavior.cs b/src/TailoredApps.Shared.Mediator/PipelineBehaviours/FallbackBehavior.cs similarity index 87% rename from src/TailoredApps.Shared.MediatR/PipelineBehaviours/FallbackBehavior.cs rename to src/TailoredApps.Shared.Mediator/PipelineBehaviours/FallbackBehavior.cs index 1919fb30..3e1b60ca 100644 --- a/src/TailoredApps.Shared.MediatR/PipelineBehaviours/FallbackBehavior.cs +++ b/src/TailoredApps.Shared.Mediator/PipelineBehaviours/FallbackBehavior.cs @@ -5,19 +5,19 @@ using System.Threading.Tasks; using ForkForward.Mediator; using Microsoft.Extensions.Logging; -using TailoredApps.Shared.MediatR.Interfaces.Handlers; +using TailoredApps.Shared.Mediator.Interfaces.Handlers; -namespace TailoredApps.Shared.MediatR.PipelineBehaviours; +namespace TailoredApps.Shared.Mediator.PipelineBehaviours; /// -/// MediatR pipeline behavior that answers a request from an +/// Mediator pipeline behavior that answers a request from an /// when the rest of the pipeline throws. /// A request without a registered fallback handler passes through unchanged. /// /// /// A request cancelled by its caller is not sent to the fallback: the cancellation propagates. /// -/// The type of the MediatR request. +/// The type of the mediator request. /// The type of the response. public class FallbackBehavior : IPipelineBehavior where TRequest : IRequest @@ -39,7 +39,7 @@ public FallbackBehavior(IEnumerable> fallb /// /// Executes the next pipeline step and, if it throws, returns the fallback handler's response instead. /// - /// The incoming MediatR request. + /// The incoming mediator request. /// The next handler delegate in the pipeline. /// Token used to cancel the operation. /// The response of the pipeline, or of the fallback handler when the pipeline failed. diff --git a/src/TailoredApps.Shared.MediatR/PipelineBehaviours/LoggingBehavior.cs b/src/TailoredApps.Shared.Mediator/PipelineBehaviours/LoggingBehavior.cs similarity index 94% rename from src/TailoredApps.Shared.MediatR/PipelineBehaviours/LoggingBehavior.cs rename to src/TailoredApps.Shared.Mediator/PipelineBehaviours/LoggingBehavior.cs index 065541a6..5129b299 100644 --- a/src/TailoredApps.Shared.MediatR/PipelineBehaviours/LoggingBehavior.cs +++ b/src/TailoredApps.Shared.Mediator/PipelineBehaviours/LoggingBehavior.cs @@ -6,10 +6,10 @@ using ForkForward.Mediator; using Microsoft.Extensions.Logging; -namespace TailoredApps.Shared.MediatR.PipelineBehaviours; +namespace TailoredApps.Shared.Mediator.PipelineBehaviours; /// -/// MediatR pipeline behavior that logs the execution time of every request and captures any +/// Mediator pipeline behavior that logs the execution time of every request and captures any /// exceptions that occur during handler processing. /// /// @@ -26,7 +26,7 @@ namespace TailoredApps.Shared.MediatR.PipelineBehaviours; /// written while the handler runs. Log payload fields explicitly in the handler when needed. /// /// -/// The type of the MediatR request. +/// The type of the mediator request. /// The type of the response. public class LoggingBehavior : IPipelineBehavior where TRequest : IRequest { diff --git a/src/TailoredApps.Shared.MediatR/PipelineBehaviours/RetryBehavior.cs b/src/TailoredApps.Shared.Mediator/PipelineBehaviours/RetryBehavior.cs similarity index 93% rename from src/TailoredApps.Shared.MediatR/PipelineBehaviours/RetryBehavior.cs rename to src/TailoredApps.Shared.Mediator/PipelineBehaviours/RetryBehavior.cs index a7496bb7..aeb8ae56 100644 --- a/src/TailoredApps.Shared.MediatR/PipelineBehaviours/RetryBehavior.cs +++ b/src/TailoredApps.Shared.Mediator/PipelineBehaviours/RetryBehavior.cs @@ -5,12 +5,12 @@ using System.Threading.Tasks; using ForkForward.Mediator; using Microsoft.Extensions.Logging; -using TailoredApps.Shared.MediatR.Interfaces.Messages; +using TailoredApps.Shared.Mediator.Interfaces.Messages; -namespace TailoredApps.Shared.MediatR.PipelineBehaviours; +namespace TailoredApps.Shared.Mediator.PipelineBehaviours; /// -/// MediatR pipeline behavior that retries a failing request and stops calling a handler that keeps +/// Mediator pipeline behavior that retries a failing request and stops calling a handler that keeps /// failing. It applies to requests with a registered . /// /// @@ -26,7 +26,7 @@ namespace TailoredApps.Shared.MediatR.PipelineBehaviours; /// client cannot open the circuit for everyone else. /// /// -/// The type of the MediatR request. +/// The type of the mediator request. /// The type of the response. public class RetryBehavior : IPipelineBehavior where TRequest : IRequest { @@ -62,7 +62,7 @@ public RetryBehavior( /// /// Executes the next pipeline step with the retry and circuit-breaker rules of the request type. /// - /// The incoming MediatR request. + /// The incoming mediator request. /// The next handler delegate in the pipeline. /// Token used to cancel the operation, including the wait between retries. /// The response of the pipeline. diff --git a/src/TailoredApps.Shared.MediatR/PipelineBehaviours/ValidationBehavior.cs b/src/TailoredApps.Shared.Mediator/PipelineBehaviours/ValidationBehavior.cs similarity index 84% rename from src/TailoredApps.Shared.MediatR/PipelineBehaviours/ValidationBehavior.cs rename to src/TailoredApps.Shared.Mediator/PipelineBehaviours/ValidationBehavior.cs index 4d8cdd13..949c095b 100644 --- a/src/TailoredApps.Shared.MediatR/PipelineBehaviours/ValidationBehavior.cs +++ b/src/TailoredApps.Shared.Mediator/PipelineBehaviours/ValidationBehavior.cs @@ -5,14 +5,14 @@ using FluentValidation; using ForkForward.Mediator; -namespace TailoredApps.Shared.MediatR.PipelineBehaviours; +namespace TailoredApps.Shared.Mediator.PipelineBehaviours; /// -/// MediatR pipeline behavior that executes all registered FluentValidation validators +/// Mediator pipeline behavior that executes all registered FluentValidation validators /// before the request is forwarded to its handler. Throws a /// if any validation failures are found. /// -/// The type of the MediatR request. +/// The type of the mediator request. /// The type of the response. public class ValidationBehavior : IPipelineBehavior where TRequest : IRequest { diff --git a/src/TailoredApps.Shared.MediatR/README.md b/src/TailoredApps.Shared.Mediator/README.md similarity index 91% rename from src/TailoredApps.Shared.MediatR/README.md rename to src/TailoredApps.Shared.Mediator/README.md index f230cd87..b8f0ebaa 100644 --- a/src/TailoredApps.Shared.MediatR/README.md +++ b/src/TailoredApps.Shared.Mediator/README.md @@ -1,19 +1,19 @@ -# TailoredApps.Shared.MediatR +# TailoredApps.Shared.Mediator -Five MediatR pipeline behaviours registered in one place: logging, FluentValidation, response caching +Five mediator pipeline behaviours registered in one place: logging, FluentValidation, response caching (`HybridCache`), fallback and retry with a circuit breaker. A request opts in to caching, fallback or retry by having a small policy class next to it; handlers stay free of that code. ## Installation ```bash -dotnet add package TailoredApps.Shared.MediatR +dotnet add package TailoredApps.Shared.Mediator ``` ## Registration ```csharp -using TailoredApps.Shared.MediatR.DI; +using TailoredApps.Shared.Mediator.DI; builder.Services.AddMediator(cfg => cfg.RegisterServicesFromAssembly(typeof(Program).Assembly)); @@ -31,9 +31,9 @@ policies and fallback handlers, it does not add the behaviours. ## Usage ```csharp -using TailoredApps.Shared.MediatR.Interfaces.Caching; -using TailoredApps.Shared.MediatR.Interfaces.Handlers; -using TailoredApps.Shared.MediatR.Interfaces.Messages; +using TailoredApps.Shared.Mediator.Interfaces.Caching; +using TailoredApps.Shared.Mediator.Interfaces.Handlers; +using TailoredApps.Shared.Mediator.Interfaces.Messages; public record GetProduct(int Id) : IRequest; @@ -60,7 +60,7 @@ public class GetProductFallback : IFallbackHandler ## Good to know -- Built on [ForkForward.Mediator](https://www.nuget.org/packages/ForkForward.Mediator), a fork of MediatR 12.5.0 under the Apache-2.0 licence, not on the MediatR package: requests and handlers use the `ForkForward.Mediator` namespace and the mediator is registered with `AddMediator(...)`. "MediatR" in the name of this library is its history, not its dependency. +- Built on [ForkForward.Mediator](https://www.nuget.org/packages/ForkForward.Mediator), a fork of MediatR 12.5.0 under the Apache-2.0 licence, not on the MediatR package: requests and handlers use the `ForkForward.Mediator` namespace and the mediator is registered with `AddMediator(...)`. In 2.x this package was named `TailoredApps.Shared.MediatR`. - Order: Logging -> Validation -> Caching -> Fallback -> Retry -> handler. A cached response skips fallback, retry and the handler; validation still runs. A response produced by a fallback handler is cached like any other. - Every response is cached as returned, including `null`, `0` and `false`; a handler that throws caches nothing. @@ -107,4 +107,4 @@ new PipelineRegistration(builder.Services) ## Documentation -https://shared.tailoredapps.pl/en/Libraries/MediatR/ +https://shared.tailoredapps.pl/en/Libraries/Mediator/ diff --git a/src/TailoredApps.Shared.MediatR/TailoredApps.Shared.MediatR.csproj b/src/TailoredApps.Shared.Mediator/TailoredApps.Shared.Mediator.csproj similarity index 58% rename from src/TailoredApps.Shared.MediatR/TailoredApps.Shared.MediatR.csproj rename to src/TailoredApps.Shared.Mediator/TailoredApps.Shared.Mediator.csproj index 05d70163..bf816d5d 100644 --- a/src/TailoredApps.Shared.MediatR/TailoredApps.Shared.MediatR.csproj +++ b/src/TailoredApps.Shared.Mediator/TailoredApps.Shared.Mediator.csproj @@ -1,14 +1,14 @@  - TailoredApps.Shared.MediatR - TailoredApps.Shared.MediatR + TailoredApps.Shared.Mediator + TailoredApps.Shared.Mediator - Shared.MediatR - Shared.MediatR is a popular high-performance MediatR framework for .NET - Shared.MediatR is a popular high-performance MediatR framework for .NET - Shared.MediatR - TailoredApps.Shared.MediatR + Shared.Mediator + Pipeline behaviours for ForkForward.Mediator registered in one place: logging, FluentValidation, response caching (HybridCache), fallback and retry with a circuit breaker. + Pipeline behaviours for ForkForward.Mediator registered in one place: logging, FluentValidation, response caching (HybridCache), fallback and retry with a circuit breaker. + Shared.Mediator + TailoredApps.Shared.Mediator Mediator support for .NET @@ -31,7 +31,7 @@ - + diff --git a/src/TailoredApps.Shared.Querying/README.md b/src/TailoredApps.Shared.Querying/README.md index ebcf8d27..59a50308 100644 --- a/src/TailoredApps.Shared.Querying/README.md +++ b/src/TailoredApps.Shared.Querying/README.md @@ -3,7 +3,7 @@ Contracts for list queries: a query with paging, sorting and a filter object, and a result with one page of items plus the total count. The package has no dependencies, so the same types can be used in an API contract, in a service and in the data layer. `TailoredApps.Shared.EntityFramework` and -`TailoredApps.Shared.MediatR.PagedRequest` build on these contracts. +`TailoredApps.Shared.Mediator.PagedRequest` build on these contracts. ## Installation @@ -62,7 +62,7 @@ if (query.IsPagingSpecified) | `IPagedAndSortedQuery`, `IQuery` | The contract of the query and of its filter | | `IPagingParameters`, `ISortingParameters`, `IQueryParameters` | Read-only views of the paging values, the sorting values, and both | | `IPagedResult` | `Results` (the page) and `Count` (the total) | -| `IPagedAndSortedRequest` | Query contract tied to a response type; implemented by `MediatR.PagedRequest` | +| `IPagedAndSortedRequest` | Query contract tied to a response type; implemented by `Mediator.PagedRequest` | | `SortDirection` | `Undefined = 0`, `Asc = 1`, `Desc = 2` | | `QueryMap` | A pair of expressions naming a field of a model and the matching field of an entity | diff --git a/tests/TailoredApps.Shared.AotSmoke.Caching/Program.cs b/tests/TailoredApps.Shared.AotSmoke.Caching/Program.cs index 8f52c720..7eee115f 100644 --- a/tests/TailoredApps.Shared.AotSmoke.Caching/Program.cs +++ b/tests/TailoredApps.Shared.AotSmoke.Caching/Program.cs @@ -2,11 +2,11 @@ using ForkForward.Mediator; using Microsoft.Extensions.DependencyInjection; using TailoredApps.AotSmoke.Caching; -using TailoredApps.Shared.MediatR.Caching; -using TailoredApps.Shared.MediatR.DI; -using TailoredApps.Shared.MediatR.Interfaces.Caching; +using TailoredApps.Shared.Mediator.Caching; +using TailoredApps.Shared.Mediator.DI; +using TailoredApps.Shared.Mediator.Interfaces.Caching; -// The response cache of the MediatR libraries, natively: a cached object and a cached value, serialized with +// The response cache of the Mediator libraries, natively: a cached object and a cached value, serialized with // JSON metadata generated at compile time. See the project file for why this is an application of its own. var failures = 0; diff --git a/tests/TailoredApps.Shared.AotSmoke.Caching/TailoredApps.Shared.AotSmoke.Caching.csproj b/tests/TailoredApps.Shared.AotSmoke.Caching/TailoredApps.Shared.AotSmoke.Caching.csproj index 61366bd8..90cae3fe 100644 --- a/tests/TailoredApps.Shared.AotSmoke.Caching/TailoredApps.Shared.AotSmoke.Caching.csproj +++ b/tests/TailoredApps.Shared.AotSmoke.Caching/TailoredApps.Shared.AotSmoke.Caching.csproj @@ -1,7 +1,7 @@ @@ -40,10 +40,10 @@ - - - - + + + + diff --git a/tests/TailoredApps.Shared.IntegrationTests/ApplicationTests.cs b/tests/TailoredApps.Shared.IntegrationTests/ApplicationTests.cs index 83c17794..1e1c02e7 100644 --- a/tests/TailoredApps.Shared.IntegrationTests/ApplicationTests.cs +++ b/tests/TailoredApps.Shared.IntegrationTests/ApplicationTests.cs @@ -7,7 +7,7 @@ namespace TailoredApps.Demo.IntegrationTests; /// /// What the application offers: the registered payment providers and their channels, and the two optional -/// features (MediatR.ML, Email.Office365), which answer 501 until they are configured. +/// features (Mediator.ML, Email.Office365), which answer 501 until they are configured. /// public class ApplicationTests(DemoApplication app) : IClassFixture { diff --git a/tests/TailoredApps.Shared.IntegrationTests/CatalogTests.cs b/tests/TailoredApps.Shared.IntegrationTests/CatalogTests.cs index 0c115901..c677fb16 100644 --- a/tests/TailoredApps.Shared.IntegrationTests/CatalogTests.cs +++ b/tests/TailoredApps.Shared.IntegrationTests/CatalogTests.cs @@ -12,8 +12,8 @@ namespace TailoredApps.Demo.IntegrationTests; /// -/// The product catalogue: Querying, MediatR.PagedRequest and the EntityFramework paging and sorting for the -/// list; the MediatR pipeline (validation, caching, retry, fallback) and ExceptionHandling for single products. +/// The product catalogue: Querying, Mediator.PagedRequest and the EntityFramework paging and sorting for the +/// list; the mediator pipeline (validation, caching, retry, fallback) and ExceptionHandling for single products. /// public class CatalogTests(DemoApplication app) : IClassFixture { diff --git a/tests/TailoredApps.Shared.IntegrationTests/RuntimeAsyncTests.cs b/tests/TailoredApps.Shared.IntegrationTests/RuntimeAsyncTests.cs index c8777625..34649d6d 100644 --- a/tests/TailoredApps.Shared.IntegrationTests/RuntimeAsyncTests.cs +++ b/tests/TailoredApps.Shared.IntegrationTests/RuntimeAsyncTests.cs @@ -29,7 +29,7 @@ public void When_Assemblies_Are_Inspected_Should_Cover_The_Libraries_And_The_Dem Assert.Contains("TailoredApps.Shared.Demo.Services", assemblies); Assert.Contains("TailoredApps.Shared.Demo.DataModel", assemblies); Assert.Contains("TailoredApps.Shared.Payments", assemblies); - Assert.Contains("TailoredApps.Shared.MediatR", assemblies); + Assert.Contains("TailoredApps.Shared.Mediator", assemblies); Assert.Contains("TailoredApps.Shared.EntityFramework", assemblies); } diff --git a/tests/TailoredApps.Shared.IntegrationTests/WebhookTests.cs b/tests/TailoredApps.Shared.IntegrationTests/WebhookTests.cs index 355872da..88b5dbc4 100644 --- a/tests/TailoredApps.Shared.IntegrationTests/WebhookTests.cs +++ b/tests/TailoredApps.Shared.IntegrationTests/WebhookTests.cs @@ -15,7 +15,7 @@ namespace TailoredApps.Demo.IntegrationTests; /// /// A gateway notification, end to end: the Revolut provider checks the signature, the handler marks the order /// paid inside the unit of work and publishes OrderPaid; one of its handlers sends the confirmation through -/// MediatR.Email and the Email template builder. +/// Mediator.Email and the Email template builder. /// public class WebhookTests(DemoApplication app) : IClassFixture { diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/AddPredictionEngineExtensionTests.cs b/tests/TailoredApps.Shared.Mediator.ML.Tests/AddPredictionEngineExtensionTests.cs similarity index 91% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/AddPredictionEngineExtensionTests.cs rename to tests/TailoredApps.Shared.Mediator.ML.Tests/AddPredictionEngineExtensionTests.cs index 23330ae7..6cc5ab79 100644 --- a/tests/TailoredApps.Shared.MediatR.ML.Tests/AddPredictionEngineExtensionTests.cs +++ b/tests/TailoredApps.Shared.Mediator.ML.Tests/AddPredictionEngineExtensionTests.cs @@ -1,13 +1,13 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.ML; using Microsoft.Extensions.Options; -using TailoredApps.Shared.MediatR.ImageClassification.Infrastructure; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Domain.Models; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Infrastructure; -using TailoredApps.Shared.MediatR.ML.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Domain.Models; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Infrastructure; +using TailoredApps.Shared.Mediator.ML.Infrastructure; using Xunit; -namespace TailoredApps.Shared.MediatR.ML.Tests; +namespace TailoredApps.Shared.Mediator.ML.Tests; public class AddPredictionEngineExtensionTests { diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/ClassifyImageCommandHandlerTests.cs b/tests/TailoredApps.Shared.Mediator.ML.Tests/ClassifyImageCommandHandlerTests.cs similarity index 92% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/ClassifyImageCommandHandlerTests.cs rename to tests/TailoredApps.Shared.Mediator.ML.Tests/ClassifyImageCommandHandlerTests.cs index 724c2af5..3458cd4c 100644 --- a/tests/TailoredApps.Shared.MediatR.ML.Tests/ClassifyImageCommandHandlerTests.cs +++ b/tests/TailoredApps.Shared.Mediator.ML.Tests/ClassifyImageCommandHandlerTests.cs @@ -2,13 +2,13 @@ using System.Threading; using System.Threading.Tasks; using Moq; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Message.Commands; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Models; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.Handlers.Commands; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Message.Commands; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Models; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.Handlers.Commands; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Infrastructure; using Xunit; -namespace TailoredApps.Shared.MediatR.ML.Tests; +namespace TailoredApps.Shared.Mediator.ML.Tests; public class ClassifyImageCommandHandlerTests { @@ -130,7 +130,7 @@ public async Task When_Image_Exceeds_Configured_Limit_Should_Reject_Before_Calli // arrange var limited = new ClassifyImageCommandHandler( classificationServiceMock.Object, - Microsoft.Extensions.Options.Options.Create(new TailoredApps.Shared.MediatR.ImageClassification.Infrastructure.ImageClassificationOptions { MaxImageBytes = 8 })); + Microsoft.Extensions.Options.Options.Create(new TailoredApps.Shared.Mediator.ImageClassification.Infrastructure.ImageClassificationOptions { MaxImageBytes = 8 })); var request = new ClassifyImage { FileByteArray = new byte[] { 137, 80, 78, 71, 1, 2, 3, 4, 5, 6 }, FileName = "big.png" }; // act & assert diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/ConstructorCompatibilityTests.cs b/tests/TailoredApps.Shared.Mediator.ML.Tests/ConstructorCompatibilityTests.cs similarity index 85% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/ConstructorCompatibilityTests.cs rename to tests/TailoredApps.Shared.Mediator.ML.Tests/ConstructorCompatibilityTests.cs index 87e61d9b..4975b7e7 100644 --- a/tests/TailoredApps.Shared.MediatR.ML.Tests/ConstructorCompatibilityTests.cs +++ b/tests/TailoredApps.Shared.Mediator.ML.Tests/ConstructorCompatibilityTests.cs @@ -2,12 +2,12 @@ using System.Threading; using System.Threading.Tasks; using Moq; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Message.Commands; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.Handlers.Commands; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Message.Commands; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.Handlers.Commands; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Infrastructure; using Xunit; -namespace TailoredApps.Shared.MediatR.ML.Tests; +namespace TailoredApps.Shared.Mediator.ML.Tests; /// /// The constructors that shipped before the security hardening must keep working for code that diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/DataModelTests.cs b/tests/TailoredApps.Shared.Mediator.ML.Tests/DataModelTests.cs similarity index 89% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/DataModelTests.cs rename to tests/TailoredApps.Shared.Mediator.ML.Tests/DataModelTests.cs index 4c00fae2..99022e61 100644 --- a/tests/TailoredApps.Shared.MediatR.ML.Tests/DataModelTests.cs +++ b/tests/TailoredApps.Shared.Mediator.ML.Tests/DataModelTests.cs @@ -2,14 +2,14 @@ using System.Linq; using ForkForward.Mediator; using Microsoft.ML.Data; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Message.Commands; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Models; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Responses.Commands; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.Handlers.Commands; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Domain.Models; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Message.Commands; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Models; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Responses.Commands; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.Handlers.Commands; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Domain.Models; using Xunit; -namespace TailoredApps.Shared.MediatR.ML.Tests; +namespace TailoredApps.Shared.Mediator.ML.Tests; public class ClassifyImageTests { @@ -28,7 +28,7 @@ public void Should_Round_Trip_Properties() } [Fact] - public void Should_Be_A_MediatR_Request_For_ClassifyImageResponse() + public void Should_Be_A_Mediator_Request_For_ClassifyImageResponse() { // arrange & act var command = new ClassifyImage(); @@ -56,7 +56,7 @@ public void Should_Round_Trip_Properties() } [Fact] - public void Should_Be_A_MediatR_Request_For_TrainImageClassificationModelResponse() + public void Should_Be_A_Mediator_Request_For_TrainImageClassificationModelResponse() { // arrange & act var command = new TrainImageClassificationModel(); diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/FileUtilsTests.cs b/tests/TailoredApps.Shared.Mediator.ML.Tests/FileUtilsTests.cs similarity index 96% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/FileUtilsTests.cs rename to tests/TailoredApps.Shared.Mediator.ML.Tests/FileUtilsTests.cs index 4bf1a740..ea8695ba 100644 --- a/tests/TailoredApps.Shared.MediatR.ML.Tests/FileUtilsTests.cs +++ b/tests/TailoredApps.Shared.Mediator.ML.Tests/FileUtilsTests.cs @@ -3,10 +3,10 @@ using System.IO; using System.Linq; using System.Reflection; -using TailoredApps.Shared.MediatR.ML.Infrastructure; +using TailoredApps.Shared.Mediator.ML.Infrastructure; using Xunit; -namespace TailoredApps.Shared.MediatR.ML.Tests; +namespace TailoredApps.Shared.Mediator.ML.Tests; /// /// Tests for the internal FileUtils class. The source assembly declares no @@ -15,7 +15,7 @@ namespace TailoredApps.Shared.MediatR.ML.Tests; public class FileUtilsTests : IDisposable { private static readonly Type FileUtilsType = typeof(PredictionEngineServiceConfiguration).Assembly - .GetType("TailoredApps.Shared.MediatR.ML.Infrastructure.FileUtils", throwOnError: true); + .GetType("TailoredApps.Shared.Mediator.ML.Infrastructure.FileUtils", throwOnError: true); private readonly string rootFolder; diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/ImageClassificationEvaluationTests.cs b/tests/TailoredApps.Shared.Mediator.ML.Tests/ImageClassificationEvaluationTests.cs similarity index 93% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/ImageClassificationEvaluationTests.cs rename to tests/TailoredApps.Shared.Mediator.ML.Tests/ImageClassificationEvaluationTests.cs index 8de9c80d..4aeed189 100644 --- a/tests/TailoredApps.Shared.MediatR.ML.Tests/ImageClassificationEvaluationTests.cs +++ b/tests/TailoredApps.Shared.Mediator.ML.Tests/ImageClassificationEvaluationTests.cs @@ -4,12 +4,12 @@ using Microsoft.ML; using Microsoft.ML.Data; using Moq; -using TailoredApps.Shared.MediatR.ImageClassification.Infrastructure; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Domain.Models; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Domain.Models; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Infrastructure; using Xunit; -namespace TailoredApps.Shared.MediatR.ML.Tests; +namespace TailoredApps.Shared.Mediator.ML.Tests; /// /// The evaluation half of training. Training itself needs the TensorFlow runtime and a downloaded diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/ImageClassificationOptionsTests.cs b/tests/TailoredApps.Shared.Mediator.ML.Tests/ImageClassificationOptionsTests.cs similarity index 95% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/ImageClassificationOptionsTests.cs rename to tests/TailoredApps.Shared.Mediator.ML.Tests/ImageClassificationOptionsTests.cs index 78befc06..e25ac123 100644 --- a/tests/TailoredApps.Shared.MediatR.ML.Tests/ImageClassificationOptionsTests.cs +++ b/tests/TailoredApps.Shared.Mediator.ML.Tests/ImageClassificationOptionsTests.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Generic; using Microsoft.Extensions.Configuration; -using TailoredApps.Shared.MediatR.ImageClassification.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Infrastructure; using Xunit; -namespace TailoredApps.Shared.MediatR.ML.Tests; +namespace TailoredApps.Shared.Mediator.ML.Tests; public class ImageClassificationOptionsTests { diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/ImageClassificationServiceTests.cs b/tests/TailoredApps.Shared.Mediator.ML.Tests/ImageClassificationServiceTests.cs similarity index 92% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/ImageClassificationServiceTests.cs rename to tests/TailoredApps.Shared.Mediator.ML.Tests/ImageClassificationServiceTests.cs index fd05f2e0..10d7012e 100644 --- a/tests/TailoredApps.Shared.MediatR.ML.Tests/ImageClassificationServiceTests.cs +++ b/tests/TailoredApps.Shared.Mediator.ML.Tests/ImageClassificationServiceTests.cs @@ -1,11 +1,11 @@ using System; using Moq; -using TailoredApps.Shared.MediatR.ImageClassification.Infrastructure; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Domain.Models; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Domain.Models; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Infrastructure; using Xunit; -namespace TailoredApps.Shared.MediatR.ML.Tests; +namespace TailoredApps.Shared.Mediator.ML.Tests; public class ImageClassificationServiceTests { diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/ImageValidationExtensionTests.cs b/tests/TailoredApps.Shared.Mediator.ML.Tests/ImageValidationExtensionTests.cs similarity index 95% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/ImageValidationExtensionTests.cs rename to tests/TailoredApps.Shared.Mediator.ML.Tests/ImageValidationExtensionTests.cs index 2fe846d4..04332e0e 100644 --- a/tests/TailoredApps.Shared.MediatR.ML.Tests/ImageValidationExtensionTests.cs +++ b/tests/TailoredApps.Shared.Mediator.ML.Tests/ImageValidationExtensionTests.cs @@ -1,9 +1,9 @@ using System; using System.IO; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.Validation; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.Validation; using Xunit; -namespace TailoredApps.Shared.MediatR.ML.Tests; +namespace TailoredApps.Shared.Mediator.ML.Tests; public class ImageValidationExtensionTests { diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/MLEngineTests.cs b/tests/TailoredApps.Shared.Mediator.ML.Tests/MLEngineTests.cs similarity index 81% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/MLEngineTests.cs rename to tests/TailoredApps.Shared.Mediator.ML.Tests/MLEngineTests.cs index 7ad5d296..abdd81ea 100644 --- a/tests/TailoredApps.Shared.MediatR.ML.Tests/MLEngineTests.cs +++ b/tests/TailoredApps.Shared.Mediator.ML.Tests/MLEngineTests.cs @@ -7,13 +7,13 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.ML; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Message.Commands; -using TailoredApps.Shared.MediatR.ImageClassification.Infrastructure; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Domain.Models; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Message.Commands; +using TailoredApps.Shared.Mediator.ImageClassification.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Domain.Models; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Infrastructure; using Xunit; -namespace TailoredApps.Shared.MediatR.ML.Tests; +namespace TailoredApps.Shared.Mediator.ML.Tests; public class MLEngineTests { @@ -43,7 +43,7 @@ public async Task CanLearnAndVerifyModel() var mediatoR = hostCreateModel.Services.GetService(); Assert.NotNull(mediatoR); - var response = await mediatoR.Send(new TrainImageClassificationModel { Source = "D:\\WORK\\SharedComponents\\tests\\TailoredApps.Shared.MediatR.ML.Tests\\TestData\\ImageClassification\\LearningSets", ModelDestFolderPath = modelName }); + var response = await mediatoR.Send(new TrainImageClassificationModel { Source = "D:\\WORK\\SharedComponents\\tests\\TailoredApps.Shared.Mediator.ML.Tests\\TestData\\ImageClassification\\LearningSets", ModelDestFolderPath = modelName }); Assert.NotNull(response); var hostVerify = Host.CreateDefaultBuilder() @@ -66,7 +66,7 @@ public async Task CanLearnAndVerifyModel() var mediatorVerify = hostVerify.Services.GetService(); Assert.NotNull(mediatorVerify); - var testFileRed = File.OpenRead("D:\\WORK\\SharedComponents\\tests\\TailoredApps.Shared.MediatR.ML.Tests\\TestData\\ImageClassification\\TestImages\\testred.png"); + var testFileRed = File.OpenRead("D:\\WORK\\SharedComponents\\tests\\TailoredApps.Shared.Mediator.ML.Tests\\TestData\\ImageClassification\\TestImages\\testred.png"); var responseClassification = await mediatorVerify.Send(new ClassifyImage { FileByteArray = ReadFully(testFileRed), FileName = "testred.png" }); Assert.NotNull(responseClassification); diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/ModelHelperTests.cs b/tests/TailoredApps.Shared.Mediator.ML.Tests/ModelHelperTests.cs similarity index 97% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/ModelHelperTests.cs rename to tests/TailoredApps.Shared.Mediator.ML.Tests/ModelHelperTests.cs index 566c7e47..eeeebb33 100644 --- a/tests/TailoredApps.Shared.MediatR.ML.Tests/ModelHelperTests.cs +++ b/tests/TailoredApps.Shared.Mediator.ML.Tests/ModelHelperTests.cs @@ -2,10 +2,10 @@ using System.IO; using System.IO.Compression; using System.Text.RegularExpressions; -using TailoredApps.Shared.MediatR.ImageClassification.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Infrastructure; using Xunit; -namespace TailoredApps.Shared.MediatR.ML.Tests; +namespace TailoredApps.Shared.Mediator.ML.Tests; public class ModelHelperTests : IDisposable { diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/ModelInfoServiceTests.cs b/tests/TailoredApps.Shared.Mediator.ML.Tests/ModelInfoServiceTests.cs similarity index 92% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/ModelInfoServiceTests.cs rename to tests/TailoredApps.Shared.Mediator.ML.Tests/ModelInfoServiceTests.cs index 8155a68a..f88da1e3 100644 --- a/tests/TailoredApps.Shared.MediatR.ML.Tests/ModelInfoServiceTests.cs +++ b/tests/TailoredApps.Shared.Mediator.ML.Tests/ModelInfoServiceTests.cs @@ -1,11 +1,11 @@ using System.IO; using Microsoft.Extensions.Options; using Moq; -using TailoredApps.Shared.MediatR.ImageClassification.Infrastructure; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Infrastructure; using Xunit; -namespace TailoredApps.Shared.MediatR.ML.Tests; +namespace TailoredApps.Shared.Mediator.ML.Tests; public class ModelInfoServiceTests { diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/PredictionEngineServiceConfigurationTests.cs b/tests/TailoredApps.Shared.Mediator.ML.Tests/PredictionEngineServiceConfigurationTests.cs similarity index 88% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/PredictionEngineServiceConfigurationTests.cs rename to tests/TailoredApps.Shared.Mediator.ML.Tests/PredictionEngineServiceConfigurationTests.cs index 578eafd3..b16f27eb 100644 --- a/tests/TailoredApps.Shared.MediatR.ML.Tests/PredictionEngineServiceConfigurationTests.cs +++ b/tests/TailoredApps.Shared.Mediator.ML.Tests/PredictionEngineServiceConfigurationTests.cs @@ -1,10 +1,10 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.ML; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Domain.Models; -using TailoredApps.Shared.MediatR.ML.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Domain.Models; +using TailoredApps.Shared.Mediator.ML.Infrastructure; using Xunit; -namespace TailoredApps.Shared.MediatR.ML.Tests; +namespace TailoredApps.Shared.Mediator.ML.Tests; public class PredictionEngineServiceConfigurationTests { diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/TailoredApps.Shared.MediatR.ML.Tests.csproj b/tests/TailoredApps.Shared.Mediator.ML.Tests/TailoredApps.Shared.Mediator.ML.Tests.csproj similarity index 98% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/TailoredApps.Shared.MediatR.ML.Tests.csproj rename to tests/TailoredApps.Shared.Mediator.ML.Tests/TailoredApps.Shared.Mediator.ML.Tests.csproj index 4da9a4af..abc510ea 100644 --- a/tests/TailoredApps.Shared.MediatR.ML.Tests/TailoredApps.Shared.MediatR.ML.Tests.csproj +++ b/tests/TailoredApps.Shared.Mediator.ML.Tests/TailoredApps.Shared.Mediator.ML.Tests.csproj @@ -16,7 +16,7 @@ - + diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/blue/1.png b/tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/blue/1.png similarity index 100% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/blue/1.png rename to tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/blue/1.png diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/blue/2.png b/tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/blue/2.png similarity index 100% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/blue/2.png rename to tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/blue/2.png diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/blue/3.png b/tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/blue/3.png similarity index 100% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/blue/3.png rename to tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/blue/3.png diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/blue/4.png b/tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/blue/4.png similarity index 100% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/blue/4.png rename to tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/blue/4.png diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/blue/5.png b/tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/blue/5.png similarity index 100% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/blue/5.png rename to tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/blue/5.png diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/green/1.png b/tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/green/1.png similarity index 100% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/green/1.png rename to tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/green/1.png diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/green/2.png b/tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/green/2.png similarity index 100% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/green/2.png rename to tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/green/2.png diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/green/3.png b/tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/green/3.png similarity index 100% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/green/3.png rename to tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/green/3.png diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/green/4.png b/tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/green/4.png similarity index 100% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/green/4.png rename to tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/green/4.png diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/green/5.png b/tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/green/5.png similarity index 100% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/green/5.png rename to tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/green/5.png diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/red/1.png b/tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/red/1.png similarity index 100% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/red/1.png rename to tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/red/1.png diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/red/2.png b/tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/red/2.png similarity index 100% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/red/2.png rename to tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/red/2.png diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/red/3.png b/tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/red/3.png similarity index 100% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/red/3.png rename to tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/red/3.png diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/red/4.png b/tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/red/4.png similarity index 100% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/red/4.png rename to tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/red/4.png diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/red/5.png b/tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/red/5.png similarity index 100% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/LearningSets/red/5.png rename to tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/LearningSets/red/5.png diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/TestImages/testblue.png b/tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/TestImages/testblue.png similarity index 100% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/TestImages/testblue.png rename to tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/TestImages/testblue.png diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/TestImages/testgreen.png b/tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/TestImages/testgreen.png similarity index 100% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/TestImages/testgreen.png rename to tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/TestImages/testgreen.png diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/TestImages/testred.png b/tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/TestImages/testred.png similarity index 100% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/TestData/ImageClassification/TestImages/testred.png rename to tests/TailoredApps.Shared.Mediator.ML.Tests/TestData/ImageClassification/TestImages/testred.png diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/TrainImageClassificationModelCommandHandlerTests.cs b/tests/TailoredApps.Shared.Mediator.ML.Tests/TrainImageClassificationModelCommandHandlerTests.cs similarity index 95% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/TrainImageClassificationModelCommandHandlerTests.cs rename to tests/TailoredApps.Shared.Mediator.ML.Tests/TrainImageClassificationModelCommandHandlerTests.cs index 9ff482f1..7bb2ae3f 100644 --- a/tests/TailoredApps.Shared.MediatR.ML.Tests/TrainImageClassificationModelCommandHandlerTests.cs +++ b/tests/TailoredApps.Shared.Mediator.ML.Tests/TrainImageClassificationModelCommandHandlerTests.cs @@ -6,13 +6,13 @@ using System.Threading.Tasks; using Microsoft.Extensions.Options; using Moq; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.DataModel.Message.Commands; -using TailoredApps.Shared.MediatR.ImageClassification.Domain.Handlers.Commands; -using TailoredApps.Shared.MediatR.ImageClassification.Infrastructure; -using TailoredApps.Shared.MediatR.ImageClassification.Interfaces.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.DataModel.Message.Commands; +using TailoredApps.Shared.Mediator.ImageClassification.Domain.Handlers.Commands; +using TailoredApps.Shared.Mediator.ImageClassification.Infrastructure; +using TailoredApps.Shared.Mediator.ImageClassification.Interfaces.Infrastructure; using Xunit; -namespace TailoredApps.Shared.MediatR.ML.Tests; +namespace TailoredApps.Shared.Mediator.ML.Tests; public class TrainImageClassificationModelCommandHandlerTests : IDisposable { diff --git a/tests/TailoredApps.Shared.MediatR.ML.Tests/appsettings.json b/tests/TailoredApps.Shared.Mediator.ML.Tests/appsettings.json similarity index 100% rename from tests/TailoredApps.Shared.MediatR.ML.Tests/appsettings.json rename to tests/TailoredApps.Shared.Mediator.ML.Tests/appsettings.json diff --git a/tests/TailoredApps.Shared.MediatR.Tests/Email/SendMailCommandHandlerTests.cs b/tests/TailoredApps.Shared.Mediator.Tests/Email/SendMailCommandHandlerTests.cs similarity index 96% rename from tests/TailoredApps.Shared.MediatR.Tests/Email/SendMailCommandHandlerTests.cs rename to tests/TailoredApps.Shared.Mediator.Tests/Email/SendMailCommandHandlerTests.cs index ab931e88..3f9fe742 100644 --- a/tests/TailoredApps.Shared.MediatR.Tests/Email/SendMailCommandHandlerTests.cs +++ b/tests/TailoredApps.Shared.Mediator.Tests/Email/SendMailCommandHandlerTests.cs @@ -5,11 +5,11 @@ using Moq; using TailoredApps.Shared.Email; using TailoredApps.Shared.Email.MailMessageBuilder; -using TailoredApps.Shared.MediatR.Email.Handlers; -using TailoredApps.Shared.MediatR.Email.Messages.Commands; +using TailoredApps.Shared.Mediator.Email.Handlers; +using TailoredApps.Shared.Mediator.Email.Messages.Commands; using Xunit; -namespace TailoredApps.Shared.MediatR.Tests; +namespace TailoredApps.Shared.Mediator.Tests; public class SendMailCommandHandlerTests { diff --git a/tests/TailoredApps.Shared.MediatR.Tests/MediatR/CachingBehaviorDistributedTests.cs b/tests/TailoredApps.Shared.Mediator.Tests/Mediator/CachingBehaviorDistributedTests.cs similarity index 98% rename from tests/TailoredApps.Shared.MediatR.Tests/MediatR/CachingBehaviorDistributedTests.cs rename to tests/TailoredApps.Shared.Mediator.Tests/Mediator/CachingBehaviorDistributedTests.cs index 54a57c9b..3a0eb1f2 100644 --- a/tests/TailoredApps.Shared.MediatR.Tests/MediatR/CachingBehaviorDistributedTests.cs +++ b/tests/TailoredApps.Shared.Mediator.Tests/Mediator/CachingBehaviorDistributedTests.cs @@ -11,11 +11,11 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; -using TailoredApps.Shared.MediatR.Interfaces.Caching; -using TailoredApps.Shared.MediatR.PipelineBehaviours; +using TailoredApps.Shared.Mediator.Interfaces.Caching; +using TailoredApps.Shared.Mediator.PipelineBehaviours; using Xunit; -namespace TailoredApps.Shared.MediatR.Tests; +namespace TailoredApps.Shared.Mediator.Tests; /// /// with a distributed cache behind HybridCache. Each diff --git a/tests/TailoredApps.Shared.MediatR.Tests/MediatR/CachingBehaviorTests.cs b/tests/TailoredApps.Shared.Mediator.Tests/Mediator/CachingBehaviorTests.cs similarity index 98% rename from tests/TailoredApps.Shared.MediatR.Tests/MediatR/CachingBehaviorTests.cs rename to tests/TailoredApps.Shared.Mediator.Tests/Mediator/CachingBehaviorTests.cs index 216daac5..d6bf47e4 100644 --- a/tests/TailoredApps.Shared.MediatR.Tests/MediatR/CachingBehaviorTests.cs +++ b/tests/TailoredApps.Shared.Mediator.Tests/Mediator/CachingBehaviorTests.cs @@ -8,11 +8,11 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; using Moq; -using TailoredApps.Shared.MediatR.Interfaces.Caching; -using TailoredApps.Shared.MediatR.PipelineBehaviours; +using TailoredApps.Shared.Mediator.Interfaces.Caching; +using TailoredApps.Shared.Mediator.PipelineBehaviours; using Xunit; -namespace TailoredApps.Shared.MediatR.Tests; +namespace TailoredApps.Shared.Mediator.Tests; public class CachingBehaviorTests { diff --git a/tests/TailoredApps.Shared.MediatR.Tests/MediatR/ExplicitRegistrationTests.cs b/tests/TailoredApps.Shared.Mediator.Tests/Mediator/ExplicitRegistrationTests.cs similarity index 96% rename from tests/TailoredApps.Shared.MediatR.Tests/MediatR/ExplicitRegistrationTests.cs rename to tests/TailoredApps.Shared.Mediator.Tests/Mediator/ExplicitRegistrationTests.cs index 14baae93..de39af63 100644 --- a/tests/TailoredApps.Shared.MediatR.Tests/MediatR/ExplicitRegistrationTests.cs +++ b/tests/TailoredApps.Shared.Mediator.Tests/Mediator/ExplicitRegistrationTests.cs @@ -11,16 +11,16 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; -using TailoredApps.Shared.MediatR.Caching; -using TailoredApps.Shared.MediatR.DI; -using TailoredApps.Shared.MediatR.Interfaces.Caching; -using TailoredApps.Shared.MediatR.Interfaces.DI; -using TailoredApps.Shared.MediatR.Interfaces.Handlers; -using TailoredApps.Shared.MediatR.Interfaces.Messages; -using TailoredApps.Shared.MediatR.PipelineBehaviours; +using TailoredApps.Shared.Mediator.Caching; +using TailoredApps.Shared.Mediator.DI; +using TailoredApps.Shared.Mediator.Interfaces.Caching; +using TailoredApps.Shared.Mediator.Interfaces.DI; +using TailoredApps.Shared.Mediator.Interfaces.Handlers; +using TailoredApps.Shared.Mediator.Interfaces.Messages; +using TailoredApps.Shared.Mediator.PipelineBehaviours; using Xunit; -namespace TailoredApps.Shared.MediatR.Tests; +namespace TailoredApps.Shared.Mediator.Tests; /// /// Registration by name, without scanning: what a trimmed or NativeAOT application uses instead of diff --git a/tests/TailoredApps.Shared.MediatR.Tests/MediatR/FallbackBehaviorTests.cs b/tests/TailoredApps.Shared.Mediator.Tests/Mediator/FallbackBehaviorTests.cs similarity index 95% rename from tests/TailoredApps.Shared.MediatR.Tests/MediatR/FallbackBehaviorTests.cs rename to tests/TailoredApps.Shared.Mediator.Tests/Mediator/FallbackBehaviorTests.cs index cca1e90e..86426662 100644 --- a/tests/TailoredApps.Shared.MediatR.Tests/MediatR/FallbackBehaviorTests.cs +++ b/tests/TailoredApps.Shared.Mediator.Tests/Mediator/FallbackBehaviorTests.cs @@ -4,11 +4,11 @@ using ForkForward.Mediator; using Microsoft.Extensions.Logging.Abstractions; using Moq; -using TailoredApps.Shared.MediatR.Interfaces.Handlers; -using TailoredApps.Shared.MediatR.PipelineBehaviours; +using TailoredApps.Shared.Mediator.Interfaces.Handlers; +using TailoredApps.Shared.Mediator.PipelineBehaviours; using Xunit; -namespace TailoredApps.Shared.MediatR.Tests; +namespace TailoredApps.Shared.Mediator.Tests; public class FallbackBehaviorTests { diff --git a/tests/TailoredApps.Shared.MediatR.Tests/MediatR/ICachePolicyTests.cs b/tests/TailoredApps.Shared.Mediator.Tests/Mediator/ICachePolicyTests.cs similarity index 96% rename from tests/TailoredApps.Shared.MediatR.Tests/MediatR/ICachePolicyTests.cs rename to tests/TailoredApps.Shared.Mediator.Tests/Mediator/ICachePolicyTests.cs index 6b5054d4..da36333a 100644 --- a/tests/TailoredApps.Shared.MediatR.Tests/MediatR/ICachePolicyTests.cs +++ b/tests/TailoredApps.Shared.Mediator.Tests/Mediator/ICachePolicyTests.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Generic; using ForkForward.Mediator; -using TailoredApps.Shared.MediatR.Interfaces.Caching; +using TailoredApps.Shared.Mediator.Interfaces.Caching; using Xunit; -namespace TailoredApps.Shared.MediatR.Tests; +namespace TailoredApps.Shared.Mediator.Tests; /// /// Tests the C# default interface implementations of . diff --git a/tests/TailoredApps.Shared.MediatR.Tests/MediatR/IRetryableRequestTests.cs b/tests/TailoredApps.Shared.Mediator.Tests/Mediator/IRetryableRequestTests.cs similarity index 92% rename from tests/TailoredApps.Shared.MediatR.Tests/MediatR/IRetryableRequestTests.cs rename to tests/TailoredApps.Shared.Mediator.Tests/Mediator/IRetryableRequestTests.cs index 81a7cd8a..9ac228e7 100644 --- a/tests/TailoredApps.Shared.MediatR.Tests/MediatR/IRetryableRequestTests.cs +++ b/tests/TailoredApps.Shared.Mediator.Tests/Mediator/IRetryableRequestTests.cs @@ -1,7 +1,7 @@ -using TailoredApps.Shared.MediatR.Interfaces.Messages; +using TailoredApps.Shared.Mediator.Interfaces.Messages; using Xunit; -namespace TailoredApps.Shared.MediatR.Tests; +namespace TailoredApps.Shared.Mediator.Tests; /// /// Tests the C# default interface implementations of . diff --git a/tests/TailoredApps.Shared.MediatR.Tests/MediatR/LoggingBehaviorTests.cs b/tests/TailoredApps.Shared.Mediator.Tests/Mediator/LoggingBehaviorTests.cs similarity index 98% rename from tests/TailoredApps.Shared.MediatR.Tests/MediatR/LoggingBehaviorTests.cs rename to tests/TailoredApps.Shared.Mediator.Tests/Mediator/LoggingBehaviorTests.cs index 46e7d8e5..fd46c824 100644 --- a/tests/TailoredApps.Shared.MediatR.Tests/MediatR/LoggingBehaviorTests.cs +++ b/tests/TailoredApps.Shared.Mediator.Tests/Mediator/LoggingBehaviorTests.cs @@ -8,10 +8,10 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Moq; -using TailoredApps.Shared.MediatR.PipelineBehaviours; +using TailoredApps.Shared.Mediator.PipelineBehaviours; using Xunit; -namespace TailoredApps.Shared.MediatR.Tests; +namespace TailoredApps.Shared.Mediator.Tests; public class LoggingBehaviorTests { diff --git a/tests/TailoredApps.Shared.MediatR.Tests/MediatR/PipelineRegistrationTests.cs b/tests/TailoredApps.Shared.Mediator.Tests/Mediator/PipelineRegistrationTests.cs similarity index 93% rename from tests/TailoredApps.Shared.MediatR.Tests/MediatR/PipelineRegistrationTests.cs rename to tests/TailoredApps.Shared.Mediator.Tests/Mediator/PipelineRegistrationTests.cs index c1e01247..e75d2eb7 100644 --- a/tests/TailoredApps.Shared.MediatR.Tests/MediatR/PipelineRegistrationTests.cs +++ b/tests/TailoredApps.Shared.Mediator.Tests/Mediator/PipelineRegistrationTests.cs @@ -6,14 +6,14 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Moq; -using TailoredApps.Shared.MediatR.DI; -using TailoredApps.Shared.MediatR.Interfaces.Caching; -using TailoredApps.Shared.MediatR.Interfaces.Handlers; -using TailoredApps.Shared.MediatR.Interfaces.Messages; -using TailoredApps.Shared.MediatR.PipelineBehaviours; +using TailoredApps.Shared.Mediator.DI; +using TailoredApps.Shared.Mediator.Interfaces.Caching; +using TailoredApps.Shared.Mediator.Interfaces.Handlers; +using TailoredApps.Shared.Mediator.Interfaces.Messages; +using TailoredApps.Shared.Mediator.PipelineBehaviours; using Xunit; -namespace TailoredApps.Shared.MediatR.Tests; +namespace TailoredApps.Shared.Mediator.Tests; public class PipelineRegistrationTests { diff --git a/tests/TailoredApps.Shared.MediatR.Tests/MediatR/RetryBehaviorTests.cs b/tests/TailoredApps.Shared.Mediator.Tests/Mediator/RetryBehaviorTests.cs similarity index 98% rename from tests/TailoredApps.Shared.MediatR.Tests/MediatR/RetryBehaviorTests.cs rename to tests/TailoredApps.Shared.Mediator.Tests/Mediator/RetryBehaviorTests.cs index dd9d2fd5..88060b23 100644 --- a/tests/TailoredApps.Shared.MediatR.Tests/MediatR/RetryBehaviorTests.cs +++ b/tests/TailoredApps.Shared.Mediator.Tests/Mediator/RetryBehaviorTests.cs @@ -3,11 +3,11 @@ using System.Threading.Tasks; using ForkForward.Mediator; using Microsoft.Extensions.Logging.Abstractions; -using TailoredApps.Shared.MediatR.Interfaces.Messages; -using TailoredApps.Shared.MediatR.PipelineBehaviours; +using TailoredApps.Shared.Mediator.Interfaces.Messages; +using TailoredApps.Shared.Mediator.PipelineBehaviours; using Xunit; -namespace TailoredApps.Shared.MediatR.Tests; +namespace TailoredApps.Shared.Mediator.Tests; public class RetryBehaviorTests { diff --git a/tests/TailoredApps.Shared.MediatR.Tests/MediatR/ValidationBehaviorTests.cs b/tests/TailoredApps.Shared.Mediator.Tests/Mediator/ValidationBehaviorTests.cs similarity index 97% rename from tests/TailoredApps.Shared.MediatR.Tests/MediatR/ValidationBehaviorTests.cs rename to tests/TailoredApps.Shared.Mediator.Tests/Mediator/ValidationBehaviorTests.cs index 8f393949..d5a25ad0 100644 --- a/tests/TailoredApps.Shared.MediatR.Tests/MediatR/ValidationBehaviorTests.cs +++ b/tests/TailoredApps.Shared.Mediator.Tests/Mediator/ValidationBehaviorTests.cs @@ -3,10 +3,10 @@ using System.Threading.Tasks; using FluentValidation; using ForkForward.Mediator; -using TailoredApps.Shared.MediatR.PipelineBehaviours; +using TailoredApps.Shared.Mediator.PipelineBehaviours; using Xunit; -namespace TailoredApps.Shared.MediatR.Tests; +namespace TailoredApps.Shared.Mediator.Tests; public class ValidationBehaviorTests { diff --git a/tests/TailoredApps.Shared.MediatR.Tests/PagedRequest/PagedAndSortedRequestTests.cs b/tests/TailoredApps.Shared.Mediator.Tests/PagedRequest/PagedAndSortedRequestTests.cs similarity index 96% rename from tests/TailoredApps.Shared.MediatR.Tests/PagedRequest/PagedAndSortedRequestTests.cs rename to tests/TailoredApps.Shared.Mediator.Tests/PagedRequest/PagedAndSortedRequestTests.cs index c0e99bdc..85bcc4c0 100644 --- a/tests/TailoredApps.Shared.MediatR.Tests/PagedRequest/PagedAndSortedRequestTests.cs +++ b/tests/TailoredApps.Shared.Mediator.Tests/PagedRequest/PagedAndSortedRequestTests.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; -using TailoredApps.Shared.MediatR.PagedRequest; +using TailoredApps.Shared.Mediator.PagedRequest; using TailoredApps.Shared.Querying; using Xunit; -namespace TailoredApps.Shared.MediatR.Tests; +namespace TailoredApps.Shared.Mediator.Tests; public class PagedAndSortedRequestTests { diff --git a/tests/TailoredApps.Shared.MediatR.Tests/TailoredApps.Shared.MediatR.Tests.csproj b/tests/TailoredApps.Shared.Mediator.Tests/TailoredApps.Shared.Mediator.Tests.csproj similarity index 85% rename from tests/TailoredApps.Shared.MediatR.Tests/TailoredApps.Shared.MediatR.Tests.csproj rename to tests/TailoredApps.Shared.Mediator.Tests/TailoredApps.Shared.Mediator.Tests.csproj index 9a40882e..fa680f46 100644 --- a/tests/TailoredApps.Shared.MediatR.Tests/TailoredApps.Shared.MediatR.Tests.csproj +++ b/tests/TailoredApps.Shared.Mediator.Tests/TailoredApps.Shared.Mediator.Tests.csproj @@ -18,9 +18,9 @@ - - - + + + diff --git a/tests/TailoredApps.Shared.MediatR.Tests/TestDoubles.cs b/tests/TailoredApps.Shared.Mediator.Tests/TestDoubles.cs similarity index 76% rename from tests/TailoredApps.Shared.MediatR.Tests/TestDoubles.cs rename to tests/TailoredApps.Shared.Mediator.Tests/TestDoubles.cs index c337edbd..a87c0b53 100644 --- a/tests/TailoredApps.Shared.MediatR.Tests/TestDoubles.cs +++ b/tests/TailoredApps.Shared.Mediator.Tests/TestDoubles.cs @@ -1,35 +1,35 @@ using System.Threading; using System.Threading.Tasks; using ForkForward.Mediator; -using TailoredApps.Shared.MediatR.Interfaces.Caching; -using TailoredApps.Shared.MediatR.Interfaces.Handlers; -using TailoredApps.Shared.MediatR.Interfaces.Messages; +using TailoredApps.Shared.Mediator.Interfaces.Caching; +using TailoredApps.Shared.Mediator.Interfaces.Handlers; +using TailoredApps.Shared.Mediator.Interfaces.Messages; -namespace TailoredApps.Shared.MediatR.Tests; +namespace TailoredApps.Shared.Mediator.Tests; -/// Shared MediatR request used by caching pipeline tests. +/// Shared mediator request used by caching pipeline tests. public class CachedRequest : IRequest { public int Id { get; set; } } -/// Shared MediatR request used by retry pipeline tests. +/// Shared mediator request used by retry pipeline tests. public class RetryRequest : IRequest { } -/// Shared MediatR request used by fallback pipeline tests. +/// Shared mediator request used by fallback pipeline tests. public class FallbackRequest : IRequest { } -/// Shared MediatR request used by logging pipeline tests. +/// Shared mediator request used by logging pipeline tests. public class LoggingRequest : IRequest { public string Payload { get; set; } } -/// Shared MediatR request used by validation pipeline tests. +/// Shared mediator request used by validation pipeline tests. public class ValidatedRequest : IRequest { public string Name { get; set; }