feat(mediator): add Azure Functions binding dispatch - #821
Conversation
Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds an Azure Functions (isolated worker + ASP.NET Core integration) dispatch runtime for mediator contracts and updates the generator to emit typed invocations for commands/queries/requests.
Changes:
- Add
ArkAzureFunctionsInvocationruntime with JSON/route/query binding + Simple Injector scoping and typed dispatch (command/query/request). - Update Azure Functions endpoint generator to detect Solid contract kind and emit
InvokeCommandAsync/InvokeQueryAsync/InvokeRequestAsync. - Update packaging (new project/package refs + lock files) and generator snapshot coverage.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Ark.Tools.MediatorFramework.Tests/packages.lock.json | Test project lockfile updated for new runtime deps. |
| tests/Ark.Tools.MediatorFramework.Tests/GeneratorSnapshotTests.cs | Snapshot assertion updated for typed query invocation emission. |
| src/mediator-framework/Ark.Tools.MediatorFramework.AzureFunctions/packages.lock.json | Runtime lockfile updated for SimpleInjector + transitive deps. |
| src/mediator-framework/Ark.Tools.MediatorFramework.AzureFunctions/ArkAzureFunctionsServiceCollectionExtensions.cs | Adds Functions service registration + Ark JSON defaults wiring. |
| src/mediator-framework/Ark.Tools.MediatorFramework.AzureFunctions/ArkAzureFunctionsInvocation.cs | Implements binding + Simple Injector scoped invocation for commands/queries/requests. |
| src/mediator-framework/Ark.Tools.MediatorFramework.AzureFunctions/Ark.Tools.MediatorFramework.AzureFunctions.csproj | Adds SimpleInjector + Ark.Tools.Solid/SystemTextJson references. |
| src/mediator-framework/Ark.Tools.MediatorFramework.AzureFunctions.Generators/AzureFunctionsEndpointGenerator.cs | Emits typed dispatch methods based on Solid interface kind. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public static IServiceCollection AddArkAzureFunctions(this IServiceCollection services) | ||
| { | ||
| ArgumentNullException.ThrowIfNull(services); | ||
| services.AddMvc().AddJsonOptions(options => options.JsonSerializerOptions.ConfigureArkDefaults()); |
| catch (FormatException) | ||
| { | ||
| value = null; | ||
| return false; | ||
| } | ||
| catch (NotSupportedException) | ||
| { | ||
| value = null; | ||
| return false; | ||
| } |
| if (HasAttribute(property, "Ark.MediatorFramework.ServerSetAttribute")) | ||
| { | ||
| if (property.CanWrite) | ||
| property.SetValue(value, null); | ||
| continue; | ||
| } |
- Add ArkTypeConverter.TryConvert<T> with static generic TypeConverter cache to Ark.Tools.Core - Update AzureFunctions generator to emit per-property binding code using ArkTypeConverter.TryConvert<ConcreteType> (no runtime reflection per request) - Update ArkAzureFunctionsInvocation runtime fallback to use static PropertyCache<T> (reflection once per T) with detailed binding error messages and safe ServerSet reset for value types - Fix ArkAzureFunctionsServiceCollectionExtensions to use ConfigureHttpJsonOptions (fixes ReadFromJsonAsync options) and accept optional source-generated STJ JsonSerializerContext instances - Align AzureFunctions generator project with MinimalApi generator settings (disable runtime analyzers) - Update generator snapshot tests for new inline dispatch pattern Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
|
@copilot Fix the code for all comments in this review thread. Do not make changes beyond what is described in the linked review thread. Review each comment for correctness, they may be false positives. Reply to each comment. |
All three issues were already addressed in commit
Build passes with no changes needed. |
…onfig, and regex Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
…generator skips converter for string bindings Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
AZF-03 required Azure Functions triggers to bind HTTP input and dispatch through the existing mediator graph with request-scoped dependencies.