diff --git a/docs/getting-started/core-concepts.md b/docs/getting-started/core-concepts.md index 522efddc..807c621b 100644 --- a/docs/getting-started/core-concepts.md +++ b/docs/getting-started/core-concepts.md @@ -129,11 +129,11 @@ graph LR - Transients behave the same as ASP.NET Core—be mindful of repeated expensive setup. - Never store scoped services on singletons; resolve them per invocation or pass data explicitly. -### Working with `ILambdaHostContext` +### Working with `ILambdaInvocationContext` -Every middleware component and handler can ask for `ILambdaHostContext`. Think of it as `HttpContext` for Lambda. +Every middleware component and handler can ask for `ILambdaInvocationContext`. Think of it as `HttpContext` for Lambda. -`ILambdaHostContext` exposes: +`ILambdaInvocationContext` exposes: - `ServiceProvider` – the scoped provider for the current invocation. - `CancellationToken` – fires `InvocationCancellationBuffer` before the hard Lambda timeout. @@ -144,7 +144,7 @@ Every middleware component and handler can ask for `ILambdaHostContext`. Think o ```csharp title="Program.cs" linenums="1" lambda.MapHandler(async ( [FromEvent] OrderRequest request, - ILambdaHostContext context, + ILambdaInvocationContext context, IOrderService service, CancellationToken ct ) => @@ -164,7 +164,7 @@ Handlers and lifecycle hooks can request multiple parameter types simultaneously - `[FromEvent] T event` – Optional marker for the deserialized payload. Include it only when your Lambda expects input; the generator enforces that at most one parameter carries `[FromEvent]`. - Services – Any registered service, keyed service (`[FromKeyedServices("key")]`), or options type. -- Context – `ILambdaHostContext` or the raw `ILambdaContext` from the AWS SDK. +- Context – `ILambdaInvocationContext` or the raw `ILambdaContext` from the AWS SDK. - `CancellationToken` – Linked to end-to-end timeouts; pass it downstream. ## Middleware Pipeline @@ -198,7 +198,7 @@ lambda.MapHandler(([FromEvent] OrderRequest order) => new OrderResponse(order.Id ## Feature System -Features provide decoupled access to invocation data—mirroring ASP.NET Core’s `HttpContext.Features` and Azure Functions’ binding features. Instead of injecting every dependency everywhere, middleware and handlers trade typed capabilities through the `ILambdaHostContext.Features` collection. +Features provide decoupled access to invocation data—mirroring ASP.NET Core’s `HttpContext.Features` and Azure Functions’ binding features. Instead of injecting every dependency everywhere, middleware and handlers trade typed capabilities through the `ILambdaInvocationContext.Features` collection. Built-in feature types include: diff --git a/docs/guides/dependency-injection.md b/docs/guides/dependency-injection.md index c8b5bfe8..f064572b 100644 --- a/docs/guides/dependency-injection.md +++ b/docs/guides/dependency-injection.md @@ -39,16 +39,16 @@ Lambda containers live across multiple invocations. Map the standard lifetimes t - Transients work the same as in ASP.NET Core, but prefer Scoped unless you truly need a new instance every time a constructor runs. -## Invocation Scope and `ILambdaHostContext` +## Invocation Scope and `ILambdaInvocationContext` -Every invocation gets its own scope. You can access it via the `ILambdaHostContext` and it is shared +Every invocation gets its own scope. You can access it via the `ILambdaInvocationContext` and it is shared across middleware and handlers: ```csharp title="Handlers" lambda.MapHandler(async ( [FromEvent] OrderRequest request, IOrderService orders, // scoped service - ILambdaHostContext context, // framework context + ILambdaInvocationContext context, // framework context CancellationToken cancellation // host-managed token ) => { @@ -57,7 +57,7 @@ lambda.MapHandler(async ( }); ``` -`ILambdaHostContext` exposes: +`ILambdaInvocationContext` exposes: - `ServiceProvider` – the scoped service provider for the invocation - `CancellationToken` – automatically linked to Lambda remaining time @@ -76,7 +76,7 @@ If your handler doesn't need the Lambda payload, omit the `[FromEvent]` paramete ## Middleware and Lifecycle Hooks: Source-Generated DI -- Middleware receives the invocation scope via the `ILambdaHostContext` argument. Resolve services with +- Middleware receives the invocation scope via the `ILambdaInvocationContext` argument. Resolve services with `context.ServiceProvider` or create reusable middleware classes with constructor injection. - `OnInit` and `OnShutdown` handlers now use the same source-generated dependency injection as your main handlers. Each executes inside its own scoped service provider so you can warm caches, seed connections, diff --git a/docs/guides/error-handling.md b/docs/guides/error-handling.md index 9832e25a..5b6b6038 100644 --- a/docs/guides/error-handling.md +++ b/docs/guides/error-handling.md @@ -53,7 +53,7 @@ lambda.UseMiddleware(async (context, next) => - Register error-handling middleware first so it wraps every other component. - Use the helper extensions (`context.GetResponse()`, `context.GetEvent()`, etc.) from - `FeatureLambdaHostContextExtensions` (they wrap `ILambdaHostContext.Features`) when you need to read + `FeatureLambdaInvocationContextExtensions` (they wrap `ILambdaInvocationContext.Features`) when you need to read or replace the outgoing payload instead of throwing. - Still rethrow fatal errors so the runtime produces accurate CloudWatch metrics and DLQ/SQS retries. diff --git a/docs/guides/handler-registration.md b/docs/guides/handler-registration.md index b0b84a1c..04ab5267 100644 --- a/docs/guides/handler-registration.md +++ b/docs/guides/handler-registration.md @@ -107,7 +107,7 @@ Handlers can mix lambda events with services, context objects, and cancellation | `[FromEvent] T event` | Deserialized from the Lambda payload (or envelope). Optional—only include when the handler expects an input. | | `IServiceType service` | Resolved from the DI container using the invocation scope. | | `[FromKeyedServices("key")] IServiceType keyed` | Resolves a keyed service registered with `AddKeyed*`. Keys must be constants supported by the BCL. | -| `ILambdaHostContext context` | Framework context that extends `ILambdaContext`, exposes scoped `ServiceProvider`, `Items`, `Features`, `Properties`, and the invocation `CancellationToken`. | +| `ILambdaInvocationContext context` | Framework context that extends `ILambdaContext`, exposes scoped `ServiceProvider`, `Items`, `Features`, `Properties`, and the invocation `CancellationToken`. | | `ILambdaContext lambdaContext` | Raw AWS Lambda context for folks that prefer the SDK contract. | | `CancellationToken cancellationToken` | Cancels when `InvocationCancellationBuffer` elapses before the Lambda timeout. | @@ -115,7 +115,7 @@ Handlers can mix lambda events with services, context objects, and cancellation lambda.MapHandler(async ( [FromEvent] OrderRequest request, [FromKeyedServices("primary")] IOrderProcessor orderProcessor, - ILambdaHostContext context, + ILambdaInvocationContext context, CancellationToken ct ) => { @@ -128,7 +128,7 @@ lambda.MapHandler(async ( }); ``` -`ILambdaHostContext.ServiceProvider` is lazily created for each invocation. Prefer constructor- or parameter-injected services because they participate in disposal automatically, but the scoped provider is available for advanced scenarios. +`ILambdaInvocationContext.ServiceProvider` is lazily created for each invocation. Prefer constructor- or parameter-injected services because they participate in disposal automatically, but the scoped provider is available for advanced scenarios. ## Return Values and Serialization @@ -138,16 +138,16 @@ The generator also emits serialization code for the delegate's return value. Sup - `Task` and `ValueTask` for asynchronous responses. - `Task` or `ValueTask` when no result should be written (Lambda receives `null`). -By default responses are serialized through the configured `ILambdaSerializer` (System.Text.Json unless you swap it). Envelope packages often provide specialized features that capture the response inside an `IResponseFeature`, so the `ILambdaHostContext` can retrieve or mutate it later. +By default responses are serialized through the configured `ILambdaSerializer` (System.Text.Json unless you swap it). Envelope packages often provide specialized features that capture the response inside an `IResponseFeature`, so the `ILambdaInvocationContext` can retrieve or mutate it later. ## Invocation Scope and Context -Each invocation receives its own dependency injection scope and `ILambdaHostContext`. Use it to share data across middleware and handlers without introducing service-locator patterns. +Each invocation receives its own dependency injection scope and `ILambdaInvocationContext`. Use it to share data across middleware and handlers without introducing service-locator patterns. ```csharp title="Program.cs" linenums="1" lambda.MapHandler(async ( [FromEvent] ApiGatewayRequestEnvelope request, - ILambdaHostContext context, + ILambdaInvocationContext context, ILogger logger, CancellationToken ct ) => @@ -193,7 +193,7 @@ At runtime: - Keep handlers thin. Delegate business logic to services so you can test them outside Lambda and reuse them across handlers. - Respect the provided `CancellationToken`; `MinimalLambda` fires it `InvocationCancellationBuffer` before the hard Lambda timeout. - Prefer strongly typed responses or envelopes instead of anonymous objects—serialization contracts stay predictable and versionable. -- Use `ILambdaHostContext.Features` (e.g., `context.GetEvent()`) to decouple middleware from handlers when you need shared metadata. +- Use `ILambdaInvocationContext.Features` (e.g., `context.GetEvent()`) to decouple middleware from handlers when you need shared metadata. - Avoid resolving services manually from `IServiceProvider` unless absolutely necessary. Let the generator inject what you need, or expose a dedicated facade service. - Prefer referencing a static method on a static class when you want to exercise the handler logic outside of the Lambda host. Mapping a method group (`lambda.MapHandler(MyHandler.HandleAsync);`) makes it trivial to unit test the handler by invoking it directly. diff --git a/docs/guides/hosting.md b/docs/guides/hosting.md index 81ebb574..2825e10d 100644 --- a/docs/guides/hosting.md +++ b/docs/guides/hosting.md @@ -54,7 +54,7 @@ Other customization hooks: - `LambdaApplicationOptions.Args` – Flow command-line arguments into configuration. - `builder.Services.ConfigureLambdaHostOptions(...)` – Override runtime behavior (Init/Shutdown timeouts, invocation cancellation buffer, output formatting). - `builder.Services.AddLambdaSerializerWithContext()` – Swap the default serializer with a source-generated one (or register any `ILambdaSerializer` manually). -- Register an `ILambdaHostContextAccessor` if you need to resolve `ILambdaHostContext` outside handlers/middleware. +- Register an `ILambdaInvocationContextAccessor` if you need to resolve `ILambdaInvocationContext` outside handlers/middleware. ## Build Phase diff --git a/docs/guides/lifecycle-management.md b/docs/guides/lifecycle-management.md index 5ddb808b..5d2cb3b6 100644 --- a/docs/guides/lifecycle-management.md +++ b/docs/guides/lifecycle-management.md @@ -204,7 +204,7 @@ lambda.OnInit(async (ILambdaLifecycleContext context, ILogger logger) = }); ``` -The `Properties` dictionary is backed by a thread-safe `ConcurrentDictionary` and is shared across all OnInit handlers. Properties set during OnInit are also available to invocation handlers via `ILambdaHostContext.Properties`. +The `Properties` dictionary is backed by a thread-safe `ConcurrentDictionary` and is shared across all OnInit handlers. Properties set during OnInit are also available to invocation handlers via `ILambdaInvocationContext.Properties`. ### Available Context Properties diff --git a/docs/guides/middleware.md b/docs/guides/middleware.md index 8cad67d6..5297eeb2 100644 --- a/docs/guides/middleware.md +++ b/docs/guides/middleware.md @@ -42,9 +42,9 @@ Output: [Logging] After handler ``` -## `ILambdaHostContext` +## `ILambdaInvocationContext` -Every middleware receives the same `ILambdaHostContext`, which is scoped to the invocation. +Every middleware receives the same `ILambdaInvocationContext`, which is scoped to the invocation. ```csharp title="Program.cs" lambda.UseMiddleware(async (context, next) => @@ -84,7 +84,7 @@ Treat the delegate as the orchestration glue and push heavy lifting into service ## Working with Features -Features are type-keyed adapters stored inside `ILambdaHostContext.Features` (an +Features are type-keyed adapters stored inside `ILambdaInvocationContext.Features` (an `IFeatureCollection`). They decouple middleware from handlers: a handler (or the framework) populates a feature, middleware reads or mutates it, and nobody needs to inject each other through DI. The collection lazily creates features by asking every registered `IFeatureProvider` to build them when @@ -123,7 +123,7 @@ Common features: ### Type-Safe Feature Access -The framework provides convenient extension methods on `ILambdaHostContext` for type-safe event and response access, simplifying the feature access pattern shown above: +The framework provides convenient extension methods on `ILambdaInvocationContext` for type-safe event and response access, simplifying the feature access pattern shown above: ```csharp title="Program.cs" lambda.UseMiddleware(async (context, next) => diff --git a/examples/MinimalLambda.Example.Events/Program.cs b/examples/MinimalLambda.Example.Events/Program.cs index e93caced..e0cb6c00 100644 --- a/examples/MinimalLambda.Example.Events/Program.cs +++ b/examples/MinimalLambda.Example.Events/Program.cs @@ -4,6 +4,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; +using MinimalLambda; using MinimalLambda.Builder; using MinimalLambda.Envelopes; using MinimalLambda.Envelopes.ApiGateway; @@ -26,7 +27,11 @@ var lambda = builder.Build(); lambda.MapHandler( - ([FromEvent] ApiGatewayRequestEnvelope request, ILogger logger) => + ( + [FromEvent] ApiGatewayRequestEnvelope request, + ILogger logger, + ILambdaInvocationContext context + ) => { logger.LogInformation("In Handler. Payload: {Payload}", request.Body); diff --git a/src/MinimalLambda.Abstractions/Core/ILambdaHostContext.cs b/src/MinimalLambda.Abstractions/Core/ILambdaInvocationContext.cs similarity index 96% rename from src/MinimalLambda.Abstractions/Core/ILambdaHostContext.cs rename to src/MinimalLambda.Abstractions/Core/ILambdaInvocationContext.cs index 3a7a2484..c6279ac1 100644 --- a/src/MinimalLambda.Abstractions/Core/ILambdaHostContext.cs +++ b/src/MinimalLambda.Abstractions/Core/ILambdaInvocationContext.cs @@ -6,7 +6,7 @@ namespace MinimalLambda; /// Encapsulates the information about a Lambda invocation. It extends /// with additional properties. /// -public interface ILambdaHostContext : ILambdaContext +public interface ILambdaInvocationContext : ILambdaContext { /// /// Gets the that signals a Lambda invocation is being diff --git a/src/MinimalLambda.Abstractions/Core/ILambdaHostContextAccessor.cs b/src/MinimalLambda.Abstractions/Core/ILambdaInvocationContextAccessor.cs similarity index 50% rename from src/MinimalLambda.Abstractions/Core/ILambdaHostContextAccessor.cs rename to src/MinimalLambda.Abstractions/Core/ILambdaInvocationContextAccessor.cs index a1e02320..df0b7e86 100644 --- a/src/MinimalLambda.Abstractions/Core/ILambdaHostContextAccessor.cs +++ b/src/MinimalLambda.Abstractions/Core/ILambdaInvocationContextAccessor.cs @@ -1,7 +1,7 @@ namespace MinimalLambda; /// -/// Provides access to the for the current Lambda +/// Provides access to the for the current Lambda /// invocation. /// /// @@ -9,12 +9,12 @@ namespace MinimalLambda; /// injection containers. It allows components to access the current Lambda context without /// requiring it to be passed directly through method parameters. /// -public interface ILambdaHostContextAccessor +public interface ILambdaInvocationContextAccessor { - /// Gets or sets the for the current Lambda invocation. + /// Gets or sets the for the current Lambda invocation. /// - /// The for the current invocation, or null if no + /// The for the current invocation, or null if no /// invocation context is available. /// - ILambdaHostContext? LambdaHostContext { get; set; } + ILambdaInvocationContext? LambdaInvocationContext { get; set; } } diff --git a/src/MinimalLambda.Abstractions/Delegates/LambdaInvocationDelegate.cs b/src/MinimalLambda.Abstractions/Delegates/LambdaInvocationDelegate.cs index 95baad43..d7e09141 100644 --- a/src/MinimalLambda.Abstractions/Delegates/LambdaInvocationDelegate.cs +++ b/src/MinimalLambda.Abstractions/Delegates/LambdaInvocationDelegate.cs @@ -4,7 +4,7 @@ namespace MinimalLambda; /// /// /// The is the core handler for processing Lambda -/// invocations. It receives an that contains the +/// invocations. It receives an that contains the /// deserialized event, response storage, service provider, and other invocation-specific /// information. /// @@ -20,7 +20,7 @@ namespace MinimalLambda; /// /// /// -/// The containing invocation information, +/// The containing invocation information, /// services, event data, and a location to store the response. /// /// A representing the asynchronous operation. @@ -28,4 +28,4 @@ namespace MinimalLambda; /// /// /// -public delegate Task LambdaInvocationDelegate(ILambdaHostContext context); +public delegate Task LambdaInvocationDelegate(ILambdaInvocationContext context); diff --git a/src/MinimalLambda.Abstractions/Features/IEventFeature.cs b/src/MinimalLambda.Abstractions/Features/IEventFeature.cs index a29fa75d..af674858 100644 --- a/src/MinimalLambda.Abstractions/Features/IEventFeature.cs +++ b/src/MinimalLambda.Abstractions/Features/IEventFeature.cs @@ -11,7 +11,7 @@ namespace MinimalLambda; public interface IEventFeature { /// Gets the deserialized Lambda invocation event. - /// The for the current invocation. + /// The for the current invocation. /// The deserialized event object, or null if the event cannot be deserialized. - object? GetEvent(ILambdaHostContext context); + object? GetEvent(ILambdaInvocationContext context); } diff --git a/src/MinimalLambda.Abstractions/Features/IEventFeatureT.cs b/src/MinimalLambda.Abstractions/Features/IEventFeatureT.cs index 82963dcd..e48474b8 100644 --- a/src/MinimalLambda.Abstractions/Features/IEventFeatureT.cs +++ b/src/MinimalLambda.Abstractions/Features/IEventFeatureT.cs @@ -12,7 +12,7 @@ namespace MinimalLambda; public interface IEventFeature : IEventFeature { /// Gets the deserialized Lambda invocation event of type . - /// The for the current invocation. + /// The for the current invocation. /// The deserialized event object of type . - new T GetEvent(ILambdaHostContext context); + new T GetEvent(ILambdaInvocationContext context); } diff --git a/src/MinimalLambda.Abstractions/Features/IResponseFeature.cs b/src/MinimalLambda.Abstractions/Features/IResponseFeature.cs index c441ee14..6a9b41fd 100644 --- a/src/MinimalLambda.Abstractions/Features/IResponseFeature.cs +++ b/src/MinimalLambda.Abstractions/Features/IResponseFeature.cs @@ -15,6 +15,6 @@ public interface IResponseFeature object? GetResponse(); /// Serializes the response object to the Lambda response stream. - /// The for the current invocation. - void SerializeToStream(ILambdaHostContext context); + /// The for the current invocation. + void SerializeToStream(ILambdaInvocationContext context); } diff --git a/src/MinimalLambda.Abstractions/README.md b/src/MinimalLambda.Abstractions/README.md index b0cd0bc7..d057ff7c 100644 --- a/src/MinimalLambda.Abstractions/README.md +++ b/src/MinimalLambda.Abstractions/README.md @@ -112,7 +112,7 @@ This design separates concerns between request/response handling, initialization cleanup. See [MinimalLambda](../MinimalLambda/README.md) for detailed usage examples and the complete builder API. -### ILambdaHostContext +### ILambdaInvocationContext Encapsulates a single Lambda invocation and provides access to contextual information and services: @@ -172,7 +172,7 @@ implementations. **LambdaInvocationDelegate** ```csharp -Task LambdaInvocationDelegate(ILambdaHostContext context) +Task LambdaInvocationDelegate(ILambdaInvocationContext context) ``` Processes a Lambda invocation. diff --git a/src/MinimalLambda.SourceGenerators/GeneratorConstants.cs b/src/MinimalLambda.SourceGenerators/GeneratorConstants.cs index 92219875..e148405e 100644 --- a/src/MinimalLambda.SourceGenerators/GeneratorConstants.cs +++ b/src/MinimalLambda.SourceGenerators/GeneratorConstants.cs @@ -5,7 +5,8 @@ internal static class TypeConstants { internal const string ILambdaContext = "global::Amazon.Lambda.Core.ILambdaContext"; - internal const string ILambdaHostContext = "global::MinimalLambda.ILambdaHostContext"; + internal const string ILambdaInvocationContext = + "global::MinimalLambda.ILambdaInvocationContext"; internal const string ILambdaLifecycleContext = "global::MinimalLambda.ILambdaLifecycleContext"; diff --git a/src/MinimalLambda.SourceGenerators/Models/ParameterInfo.cs b/src/MinimalLambda.SourceGenerators/Models/ParameterInfo.cs index f2290859..dba5f091 100644 --- a/src/MinimalLambda.SourceGenerators/Models/ParameterInfo.cs +++ b/src/MinimalLambda.SourceGenerators/Models/ParameterInfo.cs @@ -70,7 +70,7 @@ private static ( { TypeConstants.CancellationToken => (ParameterSource.CancellationToken, null), TypeConstants.ILambdaContext => (ParameterSource.HostContext, null), - TypeConstants.ILambdaHostContext => (ParameterSource.HostContext, null), + TypeConstants.ILambdaInvocationContext => (ParameterSource.HostContext, null), TypeConstants.ILambdaLifecycleContext => (ParameterSource.LifecycleContext, null), _ => (ParameterSource.Service, null), }; diff --git a/src/MinimalLambda.SourceGenerators/OutputGenerators/MapHandlerSources.cs b/src/MinimalLambda.SourceGenerators/OutputGenerators/MapHandlerSources.cs index 5a0cf96e..8acd93e8 100644 --- a/src/MinimalLambda.SourceGenerators/OutputGenerators/MapHandlerSources.cs +++ b/src/MinimalLambda.SourceGenerators/OutputGenerators/MapHandlerSources.cs @@ -90,7 +90,7 @@ private static HandlerArg[] BuildHandlerParameterAssignment(this DelegateInfo de ParameterSource.Event => $"context.GetRequiredEvent<{param.TypeInfo.FullyQualifiedType}>()", - // ILambdaContext OR ILambdaHostContext -> use context directly + // ILambdaContext OR ILambdaInvocationContext -> use context directly ParameterSource.HostContext => "context", // CancellationToken -> get from context diff --git a/src/MinimalLambda.SourceGenerators/Templates/MapHandler.scriban b/src/MinimalLambda.SourceGenerators/Templates/MapHandler.scriban index 3861e045..064166ed 100644 --- a/src/MinimalLambda.SourceGenerators/Templates/MapHandler.scriban +++ b/src/MinimalLambda.SourceGenerators/Templates/MapHandler.scriban @@ -41,7 +41,7 @@ namespace MinimalLambda.Generated return application; - {{ if call.should_await ~}} async {{ end ~}}Task InvocationDelegate(ILambdaHostContext context) + {{ if call.should_await ~}} async {{ end ~}}Task InvocationDelegate(ILambdaInvocationContext context) { {{~ if call.has_any_keyed_service_parameter ~}} if (context.ServiceProvider.GetService() is not IServiceProviderIsKeyedService) diff --git a/src/MinimalLambda/Builder/Extensions/MiddlewareLambdaApplicationExtensions.cs b/src/MinimalLambda/Builder/Extensions/MiddlewareLambdaApplicationExtensions.cs index c9a35cd2..e03233a6 100644 --- a/src/MinimalLambda/Builder/Extensions/MiddlewareLambdaApplicationExtensions.cs +++ b/src/MinimalLambda/Builder/Extensions/MiddlewareLambdaApplicationExtensions.cs @@ -15,7 +15,7 @@ public static class MiddlewareLambdaApplicationExtensions /// /// /// - /// A function that receives the and the + /// A function that receives the and the /// next in the pipeline, and returns a /// representing the asynchronous operation. /// @@ -26,7 +26,7 @@ public static class MiddlewareLambdaApplicationExtensions /// /// public ILambdaInvocationBuilder UseMiddleware( - Func middleware + Func middleware ) { ArgumentNullException.ThrowIfNull(application); diff --git a/src/MinimalLambda/Builder/Extensions/ServiceCollectionExtensions.cs b/src/MinimalLambda/Builder/Extensions/ServiceCollectionExtensions.cs index 3d555b2b..e7beaa35 100644 --- a/src/MinimalLambda/Builder/Extensions/ServiceCollectionExtensions.cs +++ b/src/MinimalLambda/Builder/Extensions/ServiceCollectionExtensions.cs @@ -28,7 +28,10 @@ public IServiceCollection AddLambdaHostCoreServices() DefaultLambdaOnShutdownBuilderFactory >(); services.AddSingleton(); - services.AddSingleton(); + services.AddSingleton< + ILambdaInvocationContextFactory, + LambdaInvocationContextFactory + >(); services.AddSingleton(); services.AddSingleton(); @@ -78,21 +81,24 @@ public IServiceCollection TryAddLambdaHostDefaultServices() } /// - /// Registers the service into the dependency + /// Registers the service into the dependency /// injection container. /// /// /// This service allows components throughout the application to access the current - /// via dependency injection without requiring it to be passed as + /// via dependency injection without requiring it to be passed as /// a parameter. The accessor is registered as a singleton and stores the context per invocation /// for convenient access throughout the dependency injection container. /// /// The service collection for chaining. - public IServiceCollection AddLambdaHostContextAccessor() + public IServiceCollection AddLambdaInvocationContextAccessor() { ArgumentNullException.ThrowIfNull(services); - services.AddSingleton(); + services.AddSingleton< + ILambdaInvocationContextAccessor, + LambdaInvocationContextAccessor + >(); return services; } diff --git a/src/MinimalLambda/Core/Context/ILambdaHostContextFactory.cs b/src/MinimalLambda/Core/Context/ILambdaInvocationContextFactory.cs similarity index 68% rename from src/MinimalLambda/Core/Context/ILambdaHostContextFactory.cs rename to src/MinimalLambda/Core/Context/ILambdaInvocationContextFactory.cs index 69b39e03..4f353de1 100644 --- a/src/MinimalLambda/Core/Context/ILambdaHostContextFactory.cs +++ b/src/MinimalLambda/Core/Context/ILambdaInvocationContextFactory.cs @@ -2,9 +2,9 @@ namespace MinimalLambda; -internal interface ILambdaHostContextFactory +internal interface ILambdaInvocationContextFactory { - ILambdaHostContext Create( + ILambdaInvocationContext Create( ILambdaContext lambdaContext, IDictionary properties, CancellationToken cancellationToken diff --git a/src/MinimalLambda/Core/Context/DefaultLambdaHostContext.cs b/src/MinimalLambda/Core/Context/LambdaInvocationContext.cs similarity index 94% rename from src/MinimalLambda/Core/Context/DefaultLambdaHostContext.cs rename to src/MinimalLambda/Core/Context/LambdaInvocationContext.cs index df2ca1e4..84face58 100644 --- a/src/MinimalLambda/Core/Context/DefaultLambdaHostContext.cs +++ b/src/MinimalLambda/Core/Context/LambdaInvocationContext.cs @@ -3,14 +3,14 @@ namespace MinimalLambda; -internal sealed class DefaultLambdaHostContext : ILambdaHostContext, IAsyncDisposable +internal sealed class LambdaInvocationContext : ILambdaInvocationContext, IAsyncDisposable { private readonly ILambdaContext _lambdaContext; private readonly IServiceScopeFactory _serviceScopeFactory; private IServiceScope? _instanceServicesScope; - public DefaultLambdaHostContext( + public LambdaInvocationContext( ILambdaContext lambdaContext, IServiceScopeFactory serviceScopeFactory, IDictionary properties, @@ -74,7 +74,7 @@ public async ValueTask DisposeAsync() public string TraceId => _lambdaContext.TraceId; // ┌──────────────────────────────────────────────────────────┐ - // │ ILambdaHostContext │ + // │ ILambdaInvocationContext │ // └──────────────────────────────────────────────────────────┘ public IServiceProvider ServiceProvider diff --git a/src/MinimalLambda/Core/Context/LambdaHostContextAccessor.cs b/src/MinimalLambda/Core/Context/LambdaInvocationContextAccessor.cs similarity index 56% rename from src/MinimalLambda/Core/Context/LambdaHostContextAccessor.cs rename to src/MinimalLambda/Core/Context/LambdaInvocationContextAccessor.cs index 70c5ef82..8dac9aa9 100644 --- a/src/MinimalLambda/Core/Context/LambdaHostContextAccessor.cs +++ b/src/MinimalLambda/Core/Context/LambdaInvocationContextAccessor.cs @@ -8,23 +8,23 @@ namespace MinimalLambda; -internal class LambdaHostContextAccessor : ILambdaHostContextAccessor +internal class LambdaInvocationContextAccessor : ILambdaInvocationContextAccessor { - private static readonly AsyncLocal ContextHolder = new(); + private static readonly AsyncLocal ContextHolder = new(); - public ILambdaHostContext? LambdaHostContext + public ILambdaInvocationContext? LambdaInvocationContext { get => ContextHolder.Value?.Context; set { ContextHolder.Value?.Context = null; if (value is not null) - ContextHolder.Value = new LambdaHostContextHolder { Context = value }; + ContextHolder.Value = new LambdaInvocationContextFactoryHolder { Context = value }; } } - private sealed class LambdaHostContextHolder + private sealed class LambdaInvocationContextFactoryHolder { - internal ILambdaHostContext? Context; + internal ILambdaInvocationContext? Context; } } diff --git a/src/MinimalLambda/Core/Context/LambdaHostContextFactory.cs b/src/MinimalLambda/Core/Context/LambdaInvocationContextFactory.cs similarity index 81% rename from src/MinimalLambda/Core/Context/LambdaHostContextFactory.cs rename to src/MinimalLambda/Core/Context/LambdaInvocationContextFactory.cs index e16f560a..3598bb7a 100644 --- a/src/MinimalLambda/Core/Context/LambdaHostContextFactory.cs +++ b/src/MinimalLambda/Core/Context/LambdaInvocationContextFactory.cs @@ -3,17 +3,17 @@ namespace MinimalLambda; -internal class LambdaHostContextFactory : ILambdaHostContextFactory +internal class LambdaInvocationContextFactory : ILambdaInvocationContextFactory { - private readonly ILambdaHostContextAccessor? _contextAccessor; + private readonly ILambdaInvocationContextAccessor? _contextAccessor; private readonly IFeatureCollectionFactory _featureCollectionFactory; private readonly IServiceScopeFactory _serviceScopeFactory; private IFeatureProvider[]? _featureProviders; - public LambdaHostContextFactory( + public LambdaInvocationContextFactory( IServiceScopeFactory serviceScopeFactory, IFeatureCollectionFactory featureCollectionFactory, - ILambdaHostContextAccessor? contextAccessor = null + ILambdaInvocationContextAccessor? contextAccessor = null ) { ArgumentNullException.ThrowIfNull(serviceScopeFactory); @@ -24,7 +24,7 @@ public LambdaHostContextFactory( _featureCollectionFactory = featureCollectionFactory; } - public ILambdaHostContext Create( + public ILambdaInvocationContext Create( ILambdaContext lambdaContext, IDictionary properties, CancellationToken cancellationToken @@ -32,7 +32,7 @@ CancellationToken cancellationToken { _featureProviders ??= CreateFeatureProviders(properties); - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, _serviceScopeFactory, properties, @@ -40,7 +40,7 @@ CancellationToken cancellationToken cancellationToken ); - _contextAccessor?.LambdaHostContext = context; + _contextAccessor?.LambdaInvocationContext = context; return context; } diff --git a/src/MinimalLambda/Core/Features/DefaultEventFeature.cs b/src/MinimalLambda/Core/Features/DefaultEventFeature.cs index d6b7db24..48c11930 100644 --- a/src/MinimalLambda/Core/Features/DefaultEventFeature.cs +++ b/src/MinimalLambda/Core/Features/DefaultEventFeature.cs @@ -20,7 +20,7 @@ public DefaultEventFeature(ILambdaSerializer lambdaSerializer) _lambdaSerializer = lambdaSerializer; } - public T GetEvent(ILambdaHostContext context) + public T GetEvent(ILambdaInvocationContext context) { if (!_isDeserialized) { @@ -32,5 +32,5 @@ public T GetEvent(ILambdaHostContext context) return _data; } - object? IEventFeature.GetEvent(ILambdaHostContext context) => GetEvent(context); + object? IEventFeature.GetEvent(ILambdaInvocationContext context) => GetEvent(context); } diff --git a/src/MinimalLambda/Core/Features/DefaultResponseFeature.cs b/src/MinimalLambda/Core/Features/DefaultResponseFeature.cs index fdb6bd8c..2a2f21b6 100644 --- a/src/MinimalLambda/Core/Features/DefaultResponseFeature.cs +++ b/src/MinimalLambda/Core/Features/DefaultResponseFeature.cs @@ -30,7 +30,7 @@ public void SetResponse(T response) public T? GetResponse() => _isSet ? _response : default; - public void SerializeToStream(ILambdaHostContext context) + public void SerializeToStream(ILambdaInvocationContext context) { if (!_isSet) return; diff --git a/src/MinimalLambda/Core/Features/FeatureLambdaHostContextExtensions.cs b/src/MinimalLambda/Core/Features/FeatureLambdaInvocationContextExtensions.cs similarity index 95% rename from src/MinimalLambda/Core/Features/FeatureLambdaHostContextExtensions.cs rename to src/MinimalLambda/Core/Features/FeatureLambdaInvocationContextExtensions.cs index 53cdef8d..3e139987 100644 --- a/src/MinimalLambda/Core/Features/FeatureLambdaHostContextExtensions.cs +++ b/src/MinimalLambda/Core/Features/FeatureLambdaInvocationContextExtensions.cs @@ -4,11 +4,11 @@ namespace MinimalLambda; /// /// Provides extension methods for safely accessing typed event and response data from the -/// on . +/// on . /// -public static class FeatureLambdaHostContextExtensions +public static class FeatureLambdaInvocationContextExtensions { - extension(ILambdaHostContext context) + extension(ILambdaInvocationContext context) { /// Gets the typed event data from the in the Lambda context. /// The type of event data to retrieve. diff --git a/src/MinimalLambda/README.md b/src/MinimalLambda/README.md index 8b816d35..fdf46cf7 100644 --- a/src/MinimalLambda/README.md +++ b/src/MinimalLambda/README.md @@ -196,7 +196,7 @@ builder.Services.AddScoped(); // New per invocation Each invocation receives its own scope—scoped services are isolated per request. `OnInit()` and `OnShutdown()` handlers receive their own scopes as well. You can also request the -`ILambdaHostContext` or `CancellationToken` in any handler, and they're automatically injected. +`ILambdaInvocationContext` or `CancellationToken` in any handler, and they're automatically injected. ### Source Generation & Interceptors diff --git a/src/MinimalLambda/Runtime/LambdaHandlerComposer.cs b/src/MinimalLambda/Runtime/LambdaHandlerComposer.cs index 5b2d8807..5f2be620 100644 --- a/src/MinimalLambda/Runtime/LambdaHandlerComposer.cs +++ b/src/MinimalLambda/Runtime/LambdaHandlerComposer.cs @@ -7,7 +7,7 @@ namespace MinimalLambda.Runtime; internal sealed class LambdaHandlerComposer : ILambdaHandlerFactory { private readonly ILambdaCancellationFactory _cancellationFactory; - private readonly ILambdaHostContextFactory _contextFactory; + private readonly ILambdaInvocationContextFactory _contextFactory; private readonly IInvocationDataFeatureFactory _invocationDataFeatureFactory; private readonly ILambdaInvocationBuilderFactory _lambdaInvocationBuilderFactory; private readonly LambdaHostedServiceOptions _options; @@ -16,7 +16,7 @@ public LambdaHandlerComposer( ILambdaInvocationBuilderFactory lambdaInvocationBuilderFactory, ILambdaCancellationFactory cancellationFactory, IOptions options, - ILambdaHostContextFactory contextFactory, + ILambdaInvocationContextFactory contextFactory, IInvocationDataFeatureFactory invocationDataFeatureFactory ) { @@ -63,22 +63,26 @@ async Task CreateRequestHandler(Stream inputStream, ILambdaContext lambd // Create a new lambda host context. This will also create a new service scope // the first time that the service container is accessed. - var lambdaHostContext = _contextFactory.Create( + var LambdaInvocationContext = _contextFactory.Create( lambdaContext, builder.Properties, linkedTokenSource.Token ); - await using (lambdaHostContext as IAsyncDisposable) + await using (LambdaInvocationContext as IAsyncDisposable) { using var invocationDataFeature = _invocationDataFeatureFactory.Create(inputStream); - lambdaHostContext.Features.Set(invocationDataFeature); + LambdaInvocationContext.Features.Set(invocationDataFeature); // Invoke the handler wrapped in the middleware pipeline. - await handler.Invoke(lambdaHostContext).ConfigureAwait(false); + await handler.Invoke(LambdaInvocationContext).ConfigureAwait(false); - if (lambdaHostContext.Features.TryGet(out var responseFeature)) - responseFeature.SerializeToStream(lambdaHostContext); + if ( + LambdaInvocationContext.Features.TryGet( + out var responseFeature + ) + ) + responseFeature.SerializeToStream(LambdaInvocationContext); // If no serializer is provided, return an empty stream. return invocationDataFeature.ResponseStream; diff --git a/tests/MinimalLambda.OpenTelemetry.UnitTests/MiddlewareOpenTelemetryExtensionsTest.cs b/tests/MinimalLambda.OpenTelemetry.UnitTests/MiddlewareOpenTelemetryExtensionsTest.cs index 301d7564..f9d7bc79 100644 --- a/tests/MinimalLambda.OpenTelemetry.UnitTests/MiddlewareOpenTelemetryExtensionsTest.cs +++ b/tests/MinimalLambda.OpenTelemetry.UnitTests/MiddlewareOpenTelemetryExtensionsTest.cs @@ -72,7 +72,7 @@ public async Task UseOpenTelemetryTracing_Middleware_CallsNextDelegate( [Frozen] IServiceProvider serviceProvider, [Frozen] ILambdaInvocationBuilder builder, TracerProvider tracerProvider, - ILambdaHostContext context, + ILambdaInvocationContext context, IFeatureCollection features ) { diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/GeneratorTestHelpers.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/GeneratorTestHelpers.cs index 6ec047af..2d4d108f 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/GeneratorTestHelpers.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/GeneratorTestHelpers.cs @@ -85,7 +85,7 @@ .. Net90.References.All.ToList(), MetadataReference.CreateFromFile(typeof(DefaultLambdaJsonSerializer).Assembly.Location), MetadataReference.CreateFromFile(typeof(LambdaBootstrapBuilder).Assembly.Location), MetadataReference.CreateFromFile(typeof(IOptions<>).Assembly.Location), - MetadataReference.CreateFromFile(typeof(ILambdaHostContext).Assembly.Location), + MetadataReference.CreateFromFile(typeof(ILambdaInvocationContext).Assembly.Location), MetadataReference.CreateFromFile(typeof(APIGatewayProxyResponse).Assembly.Location), ]; diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_AllInputSources#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_AllInputSources#LambdaHandler.g.verified.cs index 8865e8ab..d9547b17 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_AllInputSources#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_AllInputSources#LambdaHandler.g.verified.cs @@ -59,7 +59,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { if (context.ServiceProvider.GetService() is not IServiceProviderIsKeyedService) { diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_Async_ReturnTaskString_TypeCast#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_Async_ReturnTaskString_TypeCast#LambdaHandler.g.verified.cs index 1d67804f..7708b2c4 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_Async_ReturnTaskString_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_Async_ReturnTaskString_TypeCast#LambdaHandler.g.verified.cs @@ -59,7 +59,7 @@ Delegate handler return application; - async Task InvocationDelegate(ILambdaHostContext context) + async Task InvocationDelegate(ILambdaInvocationContext context) { var response = await castHandler.Invoke(); if (context.Features.Get() is not IResponseFeature responseFeature) diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoReturn_TypeCast#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoReturn_TypeCast#LambdaHandler.g.verified.cs index 0e826285..5d15ec81 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoReturn_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoReturn_TypeCast#LambdaHandler.g.verified.cs @@ -59,7 +59,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { // ParameterInfo { Type = string, Name = input, Source = Event, IsNullable = False, IsOptional = False} var arg0 = context.GetRequiredEvent(); diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoTypeInfo_TypeCast#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoTypeInfo_TypeCast#LambdaHandler.g.verified.cs index 179c0121..45b13bf9 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoTypeInfo_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoTypeInfo_TypeCast#LambdaHandler.g.verified.cs @@ -59,7 +59,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { // ParameterInfo { Type = global::IService, Name = service, Source = Service, IsNullable = False, IsOptional = False} var arg0 = context.ServiceProvider.GetRequiredService(); diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnExplicitType#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnExplicitType#LambdaHandler.g.verified.cs index acfd56a5..70c6ad3d 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnExplicitType#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnExplicitType#LambdaHandler.g.verified.cs @@ -64,7 +64,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { // ParameterInfo { Type = string, Name = input, Source = Event, IsNullable = False, IsOptional = False} var arg0 = context.GetRequiredEvent(); diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnImplicitNullable#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnImplicitNullable#LambdaHandler.g.verified.cs index a993341e..7b3af26b 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnImplicitNullable#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnImplicitNullable#LambdaHandler.g.verified.cs @@ -64,7 +64,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { // ParameterInfo { Type = string, Name = input, Source = Event, IsNullable = False, IsOptional = False} var arg0 = context.GetRequiredEvent(); diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnString#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnString#LambdaHandler.g.verified.cs index 250a9a86..787c54f4 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnString#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnString#LambdaHandler.g.verified.cs @@ -64,7 +64,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { // ParameterInfo { Type = string, Name = input, Source = Event, IsNullable = False, IsOptional = False} var arg0 = context.GetRequiredEvent(); diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnTaskString#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnTaskString#LambdaHandler.g.verified.cs index bbe64432..85ef2be6 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnTaskString#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnTaskString#LambdaHandler.g.verified.cs @@ -59,7 +59,7 @@ Delegate handler return application; - async Task InvocationDelegate(ILambdaHostContext context) + async Task InvocationDelegate(ILambdaInvocationContext context) { var response = await castHandler.Invoke(); if (context.Features.Get() is not IResponseFeature responseFeature) diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnsTask_TypeCast#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnsTask_TypeCast#LambdaHandler.g.verified.cs index 0150e0e3..f4c1f850 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnsTask_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnsTask_TypeCast#LambdaHandler.g.verified.cs @@ -54,7 +54,7 @@ Delegate handler return application; - async Task InvocationDelegate(ILambdaHostContext context) + async Task InvocationDelegate(ILambdaInvocationContext context) { await castHandler.Invoke(); } diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_StreamResponse#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_StreamResponse#LambdaHandler.g.verified.cs index 2c471368..a3e4f07f 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_StreamResponse#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_StreamResponse#LambdaHandler.g.verified.cs @@ -54,7 +54,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { var response = castHandler.Invoke(); context.Features.GetRequired().ResponseStream = response; diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast#LambdaHandler.g.verified.cs index bdd18c50..68af78be 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast#LambdaHandler.g.verified.cs @@ -59,7 +59,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { // ParameterInfo { Type = global::IService, Name = service, Source = Service, IsNullable = False, IsOptional = False} var arg0 = context.ServiceProvider.GetRequiredService(); diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast_InputFromKeyedServices#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast_InputFromKeyedServices#LambdaHandler.g.verified.cs index 73239331..5fa24d89 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast_InputFromKeyedServices#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast_InputFromKeyedServices#LambdaHandler.g.verified.cs @@ -59,7 +59,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { if (context.ServiceProvider.GetService() is not IServiceProviderIsKeyedService) { diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationToken#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationToken#LambdaHandler.g.verified.cs index c3cd6db9..e2e074a1 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationToken#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationToken#LambdaHandler.g.verified.cs @@ -59,7 +59,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { // ParameterInfo { Type = global::System.Threading.CancellationToken, Name = cancellationToken, Source = CancellationToken, IsNullable = False, IsOptional = False} var arg0 = context.CancellationToken; diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaContext#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaContext#LambdaHandler.g.verified.cs index 9441ab08..7eb07d44 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaContext#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaContext#LambdaHandler.g.verified.cs @@ -59,7 +59,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { // ParameterInfo { Type = global::System.Threading.CancellationToken, Name = ct, Source = CancellationToken, IsNullable = False, IsOptional = False} var arg0 = context.CancellationToken; diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaHostContext#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaHostContext#LambdaHandler.g.verified.cs index d8b5ec2f..a85a4c2d 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaHostContext#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaHostContext#LambdaHandler.g.verified.cs @@ -48,7 +48,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func)handler; + var castHandler = (global::System.Func)handler; application.Handle(InvocationDelegate); @@ -59,11 +59,11 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { // ParameterInfo { Type = global::System.Threading.CancellationToken, Name = ct, Source = CancellationToken, IsNullable = False, IsOptional = False} var arg0 = context.CancellationToken; - // ParameterInfo { Type = global::MinimalLambda.ILambdaHostContext, Name = ctx, Source = HostContext, IsNullable = False, IsOptional = False} + // ParameterInfo { Type = global::MinimalLambda.ILambdaInvocationContext, Name = ctx, Source = HostContext, IsNullable = False, IsOptional = False} var arg1 = context; var response = castHandler.Invoke(arg0, arg1); if (context.Features.Get() is not IResponseFeature responseFeature) diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaInvocationContext#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaInvocationContext#LambdaHandler.g.verified.cs new file mode 100644 index 00000000..90b43b41 --- /dev/null +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaInvocationContext#LambdaHandler.g.verified.cs @@ -0,0 +1,78 @@ +//HintName: LambdaHandler.g.cs +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously + +#nullable enable + +namespace System.Runtime.CompilerServices +{ + using System.CodeDom.Compiler; + + [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] + [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] + file sealed class InterceptsLocationAttribute : Attribute + { + public InterceptsLocationAttribute(int version, string data) + { + } + } +} + +namespace MinimalLambda.Generated +{ + using System; + using System.CodeDom.Compiler; + using System.Runtime.CompilerServices; + using System.Threading.Tasks; + using MinimalLambda.Builder; + using MinimalLambda; + using Microsoft.Extensions.DependencyInjection; + + [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] + file static class GeneratedLambdaInvocationBuilderExtensions + { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + + [InterceptsLocation(1, "MM9ytQ7zZDW9+yc/+rcLl+AAAABJbnB1dEZpbGUuY3M=")] + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( + this ILambdaInvocationBuilder application, + Delegate handler + ) + { + var castHandler = (global::System.Func)handler; + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create(); + + return application; + + Task InvocationDelegate(ILambdaInvocationContext context) + { + // ParameterInfo { Type = global::System.Threading.CancellationToken, Name = ct, Source = CancellationToken, IsNullable = False, IsOptional = False} + var arg0 = context.CancellationToken; + // ParameterInfo { Type = global::MinimalLambda.ILambdaInvocationContext, Name = ctx, Source = HostContext, IsNullable = False, IsOptional = False} + var arg1 = context; + var response = castHandler.Invoke(arg0, arg1); + if (context.Features.Get() is not IResponseFeature responseFeature) + { + throw new InvalidOperationException($"Response feature for type 'string' is not available in the collection."); + } + responseFeature.SetResponse(response); + return Task.CompletedTask; + } + } + } +} diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_Async_ReturnExplicitTask#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_Async_ReturnExplicitTask#LambdaHandler.g.verified.cs index 14919bb0..c1cb4fa4 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_Async_ReturnExplicitTask#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_Async_ReturnExplicitTask#LambdaHandler.g.verified.cs @@ -54,7 +54,7 @@ Delegate handler return application; - async Task InvocationDelegate(ILambdaHostContext context) + async Task InvocationDelegate(ILambdaInvocationContext context) { await castHandler.Invoke(); } diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ComplexInput_ComplexOutput#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ComplexInput_ComplexOutput#LambdaHandler.g.verified.cs index 707a0438..cdee1880 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ComplexInput_ComplexOutput#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ComplexInput_ComplexOutput#LambdaHandler.g.verified.cs @@ -64,7 +64,7 @@ Delegate handler return application; - async Task InvocationDelegate(ILambdaHostContext context) + async Task InvocationDelegate(ILambdaInvocationContext context) { // ParameterInfo { Type = global::CustomRequest, Name = request, Source = Event, IsNullable = False, IsOptional = False} var arg0 = context.GetRequiredEvent(); diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ExplicitVoid#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ExplicitVoid#LambdaHandler.g.verified.cs index 268fc544..d8cc1abf 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ExplicitVoid#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ExplicitVoid#LambdaHandler.g.verified.cs @@ -54,7 +54,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { castHandler.Invoke(); return Task.CompletedTask; diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_Async#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_Async#LambdaHandler.g.verified.cs index 904e85dc..f00b01f7 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_Async#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_Async#LambdaHandler.g.verified.cs @@ -64,7 +64,7 @@ Delegate handler return application; - async Task InvocationDelegate(ILambdaHostContext context) + async Task InvocationDelegate(ILambdaInvocationContext context) { // ParameterInfo { Type = string, Name = input, Source = Event, IsNullable = False, IsOptional = False} var arg0 = context.GetRequiredEvent(); diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait#LambdaHandler.g.verified.cs index d24fe6b0..a2395ad0 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait#LambdaHandler.g.verified.cs @@ -64,7 +64,7 @@ Delegate handler return application; - async Task InvocationDelegate(ILambdaHostContext context) + async Task InvocationDelegate(ILambdaInvocationContext context) { // ParameterInfo { Type = string, Name = input, Source = Event, IsNullable = False, IsOptional = False} var arg0 = context.GetRequiredEvent(); diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait_EventAndResponseDifferentNamespace#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait_EventAndResponseDifferentNamespace#LambdaHandler.g.verified.cs index 0d0e02e5..3581561d 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait_EventAndResponseDifferentNamespace#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait_EventAndResponseDifferentNamespace#LambdaHandler.g.verified.cs @@ -64,7 +64,7 @@ Delegate handler return application; - async Task InvocationDelegate(ILambdaHostContext context) + async Task InvocationDelegate(ILambdaInvocationContext context) { // ParameterInfo { Type = global::MyNamespace.Event, Name = input, Source = Event, IsNullable = False, IsOptional = False} var arg0 = context.GetRequiredEvent(); diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputStream#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputStream#LambdaHandler.g.verified.cs index 65008b0d..1aaada7d 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputStream#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputStream#LambdaHandler.g.verified.cs @@ -54,7 +54,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { // ParameterInfo { Type = global::System.IO.Stream, Name = input, Source = Event, IsNullable = False, IsOptional = False} var arg0 = context.Features.GetRequired().EventStream; diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_NoOutput#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_NoOutput#LambdaHandler.g.verified.cs index 89a04736..c470cab5 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_NoOutput#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_NoOutput#LambdaHandler.g.verified.cs @@ -54,7 +54,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { castHandler.Invoke(); return Task.CompletedTask; diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnGenericObject#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnGenericObject#LambdaHandler.g.verified.cs index 83e02a44..650e7f57 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnGenericObject#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnGenericObject#LambdaHandler.g.verified.cs @@ -59,7 +59,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { var response = castHandler.Invoke(); if (context.Features.Get() is not IResponseFeature> responseFeature) diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnNullablePrimitive#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnNullablePrimitive#LambdaHandler.g.verified.cs index 97726f06..ac7589f6 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnNullablePrimitive#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnNullablePrimitive#LambdaHandler.g.verified.cs @@ -59,7 +59,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { var response = castHandler.Invoke(); if (context.Features.Get() is not IResponseFeature responseFeature) diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnString#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnString#LambdaHandler.g.verified.cs index aed9f2fd..9637f4e8 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnString#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnString#LambdaHandler.g.verified.cs @@ -59,7 +59,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { var response = castHandler.Invoke(); if (context.Features.Get() is not IResponseFeature responseFeature) diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnExplicitNullable#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnExplicitNullable#LambdaHandler.g.verified.cs index 17b19dd9..333f4a3c 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnExplicitNullable#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnExplicitNullable#LambdaHandler.g.verified.cs @@ -64,7 +64,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { // ParameterInfo { Type = int?, Name = input, Source = Event, IsNullable = True, IsOptional = False} var arg0 = context.GetRequiredEvent(); diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnImplicitNullable#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnImplicitNullable#LambdaHandler.g.verified.cs index d13f96a0..eca587c8 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnImplicitNullable#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnImplicitNullable#LambdaHandler.g.verified.cs @@ -64,7 +64,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { // ParameterInfo { Type = string?, Name = input, Source = Event, IsNullable = True, IsOptional = False} var arg0 = context.GetRequiredEvent(); diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitTask#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitTask#LambdaHandler.g.verified.cs index 8472525b..a1202122 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitTask#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitTask#LambdaHandler.g.verified.cs @@ -54,7 +54,7 @@ Delegate handler return application; - async Task InvocationDelegate(ILambdaHostContext context) + async Task InvocationDelegate(ILambdaInvocationContext context) { await castHandler.Invoke(); } diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitType#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitType#LambdaHandler.g.verified.cs index 3104180d..8f84dfd7 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitType#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitType#LambdaHandler.g.verified.cs @@ -64,7 +64,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { // ParameterInfo { Type = string, Name = input, Source = Event, IsNullable = False, IsOptional = False} var arg0 = context.GetRequiredEvent(); diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_FloatingPointTypes#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_FloatingPointTypes#LambdaHandler.g.verified.cs index 1d366b09..338267ac 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_FloatingPointTypes#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_FloatingPointTypes#LambdaHandler.g.verified.cs @@ -54,7 +54,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { if (context.ServiceProvider.GetService() is not IServiceProviderIsKeyedService) { diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_IntAndLongKeys#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_IntAndLongKeys#LambdaHandler.g.verified.cs index 46164809..a7f082ac 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_IntAndLongKeys#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_IntAndLongKeys#LambdaHandler.g.verified.cs @@ -54,7 +54,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { if (context.ServiceProvider.GetService() is not IServiceProviderIsKeyedService) { diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_OtherTypes#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_OtherTypes#LambdaHandler.g.verified.cs index 7c3a39d8..e8c9e8dd 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_OtherTypes#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_OtherTypes#LambdaHandler.g.verified.cs @@ -54,7 +54,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { if (context.ServiceProvider.GetService() is not IServiceProviderIsKeyedService) { diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_SmallIntegerTypes#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_SmallIntegerTypes#LambdaHandler.g.verified.cs index 9deaac58..3afbd2d3 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_SmallIntegerTypes#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_SmallIntegerTypes#LambdaHandler.g.verified.cs @@ -54,7 +54,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { if (context.ServiceProvider.GetService() is not IServiceProviderIsKeyedService) { diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_StringAndEnumKeys#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_StringAndEnumKeys#LambdaHandler.g.verified.cs index c02e79a2..29562dd2 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_StringAndEnumKeys#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_StringAndEnumKeys#LambdaHandler.g.verified.cs @@ -54,7 +54,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { if (context.ServiceProvider.GetService() is not IServiceProviderIsKeyedService) { diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_UnsignedIntegerTypes#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_UnsignedIntegerTypes#LambdaHandler.g.verified.cs index 2004666c..ab31a1b0 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_UnsignedIntegerTypes#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_UnsignedIntegerTypes#LambdaHandler.g.verified.cs @@ -54,7 +54,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { if (context.ServiceProvider.GetService() is not IServiceProviderIsKeyedService) { diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_AsyncVoid#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_AsyncVoid#LambdaHandler.g.verified.cs index c1ce7060..1b268c2b 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_AsyncVoid#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_AsyncVoid#LambdaHandler.g.verified.cs @@ -54,7 +54,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { castHandler.Invoke(); return Task.CompletedTask; diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_Async_ReturnTaskString#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_Async_ReturnTaskString#LambdaHandler.g.verified.cs index 513a1e18..607c88dd 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_Async_ReturnTaskString#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_Async_ReturnTaskString#LambdaHandler.g.verified.cs @@ -59,7 +59,7 @@ Delegate handler return application; - async Task InvocationDelegate(ILambdaHostContext context) + async Task InvocationDelegate(ILambdaInvocationContext context) { var response = await castHandler.Invoke(); if (context.Features.Get() is not IResponseFeature responseFeature) diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_InputDiKeyedServices#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_InputDiKeyedServices#LambdaHandler.g.verified.cs index 1ff128c3..fc7d06fe 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_InputDiKeyedServices#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_InputDiKeyedServices#LambdaHandler.g.verified.cs @@ -64,7 +64,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { if (context.ServiceProvider.GetService() is not IServiceProviderIsKeyedService) { diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast#LambdaHandler.g.verified.cs index c5be4fbf..8f0f5d1d 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast#LambdaHandler.g.verified.cs @@ -59,7 +59,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { var response = castHandler.Invoke(); if (context.Features.Get() is not IResponseFeature responseFeature) diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast_Static#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast_Static#LambdaHandler.g.verified.cs index dd8a90b8..b09c941a 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast_Static#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast_Static#LambdaHandler.g.verified.cs @@ -59,7 +59,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { var response = castHandler.Invoke(); if (context.Features.Get() is not IResponseFeature responseFeature) diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_NoInput_NoOutput#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_NoInput_NoOutput#LambdaHandler.g.verified.cs index 444d7326..539c0454 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_NoInput_NoOutput#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_NoInput_NoOutput#LambdaHandler.g.verified.cs @@ -54,7 +54,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { castHandler.Invoke(); return Task.CompletedTask; diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTask#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTask#LambdaHandler.g.verified.cs index 531f67fb..3d471640 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTask#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTask#LambdaHandler.g.verified.cs @@ -54,7 +54,7 @@ Delegate handler return application; - async Task InvocationDelegate(ILambdaHostContext context) + async Task InvocationDelegate(ILambdaInvocationContext context) { await castHandler.Invoke(); } diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTaskString#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTaskString#LambdaHandler.g.verified.cs index bb083dac..18d5e82a 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTaskString#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTaskString#LambdaHandler.g.verified.cs @@ -59,7 +59,7 @@ Delegate handler return application; - async Task InvocationDelegate(ILambdaHostContext context) + async Task InvocationDelegate(ILambdaInvocationContext context) { var response = await castHandler.Invoke(); if (context.Features.Get() is not IResponseFeature responseFeature) diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_TypeCast_ExtraParentheses#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_TypeCast_ExtraParentheses#LambdaHandler.g.verified.cs index 6cc62825..1cd2ae85 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_TypeCast_ExtraParentheses#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_TypeCast_ExtraParentheses#LambdaHandler.g.verified.cs @@ -59,7 +59,7 @@ Delegate handler return application; - Task InvocationDelegate(ILambdaHostContext context) + Task InvocationDelegate(ILambdaInvocationContext context) { var response = castHandler.Invoke(); if (context.Features.Get() is not IResponseFeature responseFeature) diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/VerifyTests/ExpressionLambdaVerifyTests.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/VerifyTests/ExpressionLambdaVerifyTests.cs index 9206fe1e..18a94741 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/VerifyTests/ExpressionLambdaVerifyTests.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/VerifyTests/ExpressionLambdaVerifyTests.cs @@ -15,7 +15,7 @@ await GeneratorTestHelpers.Verify( var lambda = builder.Build(); - lambda.Handle(Task (ILambdaHostContext context) => Task.CompletedTask); + lambda.Handle(Task (ILambdaInvocationContext context) => Task.CompletedTask); await lambda.RunAsync(); """ @@ -36,7 +36,7 @@ await GeneratorTestHelpers.Verify( var lambda = builder.Build(); - lambda.Handle(Task (ILambdaHostContext context) => Task.CompletedTask); + lambda.Handle(Task (ILambdaInvocationContext context) => Task.CompletedTask); await lambda.RunAsync(); """ @@ -400,7 +400,7 @@ await GeneratorTestHelpers.Verify( ); [Fact] - public async Task Test_ExpressionLambda_AsksForCancellationTokenAndLambdaHostContext() => + public async Task Test_ExpressionLambda_AsksForCancellationTokenAndLambdaInvocationContext() => await GeneratorTestHelpers.Verify( """ using System.Threading; @@ -412,7 +412,7 @@ await GeneratorTestHelpers.Verify( var builder = LambdaApplication.CreateBuilder(); var lambda = builder.Build(); - lambda.MapHandler((CancellationToken ct, ILambdaHostContext ctx) => "hello world"); + lambda.MapHandler((CancellationToken ct, ILambdaInvocationContext ctx) => "hello world"); await lambda.RunAsync(); """ diff --git a/tests/MinimalLambda.UnitTests/Builder/Extensions/MiddlewareLambdaApplicationExtensionsTests.cs b/tests/MinimalLambda.UnitTests/Builder/Extensions/MiddlewareLambdaApplicationExtensionsTests.cs index 7bfcec70..b2d57843 100644 --- a/tests/MinimalLambda.UnitTests/Builder/Extensions/MiddlewareLambdaApplicationExtensionsTests.cs +++ b/tests/MinimalLambda.UnitTests/Builder/Extensions/MiddlewareLambdaApplicationExtensionsTests.cs @@ -13,7 +13,7 @@ public void UseMiddleware_WithNullApplication_ThrowsArgumentNullException() { // Arrange ILambdaInvocationBuilder? application = null; - Func middleware = async (_, _) => + Func middleware = async (_, _) => await Task.CompletedTask; // Act @@ -29,7 +29,7 @@ public void UseMiddleware_WithValidMiddleware_ReturnsBuilder() // Arrange var host = CreateHostWithServices(); var app = new LambdaApplication(host); - Func middleware = async (_, _) => + Func middleware = async (_, _) => await Task.CompletedTask; // Act @@ -45,7 +45,7 @@ public void UseMiddleware_WithValidMiddleware_AddsMiddlewareToApplication() // Arrange var host = CreateHostWithServices(); var app = new LambdaApplication(host); - Func middleware = async (_, _) => + Func middleware = async (_, _) => await Task.CompletedTask; // Act @@ -61,7 +61,7 @@ public void UseMiddleware_EnablesMethodChaining() // Arrange var host = CreateHostWithServices(); var app = new LambdaApplication(host); - Func middleware = async (_, _) => + Func middleware = async (_, _) => await Task.CompletedTask; // Act @@ -79,10 +79,10 @@ public async Task UseMiddleware_CallsMiddlewareWithContextAndNext() var host = CreateHostWithServices(); var app = new LambdaApplication(host); var middlewareWasCalled = false; - ILambdaHostContext? capturedContext = null; + ILambdaInvocationContext? capturedContext = null; LambdaInvocationDelegate? capturedNext = null; - Func middleware = async ( + Func middleware = async ( context, next ) => @@ -100,7 +100,7 @@ public async Task UseMiddleware_CallsMiddlewareWithContextAndNext() var builtPipeline = app.Build(); // Act - var mockContext = Substitute.For(); + var mockContext = Substitute.For(); await builtPipeline(mockContext); // Assert diff --git a/tests/MinimalLambda.UnitTests/Builder/Extensions/ServiceCollectionExtensionsTests.cs b/tests/MinimalLambda.UnitTests/Builder/Extensions/ServiceCollectionExtensionsTests.cs index a8760cbe..b2e130ef 100644 --- a/tests/MinimalLambda.UnitTests/Builder/Extensions/ServiceCollectionExtensionsTests.cs +++ b/tests/MinimalLambda.UnitTests/Builder/Extensions/ServiceCollectionExtensionsTests.cs @@ -306,56 +306,56 @@ public void TryAddLambdaHostDefaultServices_EnablesMethodChaining() } [Fact] - public void AddLambdaHostContextAccessor_WithNullServiceCollection_ThrowsArgumentNullException() + public void AddLambdaInvocationContextAccessor_WithNullServiceCollection_ThrowsArgumentNullException() { // Act - var act = () => ((IServiceCollection)null!).AddLambdaHostContextAccessor(); + var act = () => ((IServiceCollection)null!).AddLambdaInvocationContextAccessor(); // Assert act.Should().ThrowExactly(); } [Fact] - public void AddLambdaHostContextAccessor_WithValidServiceCollection_ReturnsServiceCollection() + public void AddLambdaInvocationContextAccessor_WithValidServiceCollection_ReturnsServiceCollection() { // Arrange var serviceCollection = new ServiceCollection(); // Act - var result = serviceCollection.AddLambdaHostContextAccessor(); + var result = serviceCollection.AddLambdaInvocationContextAccessor(); // Assert result.Should().BeSameAs(serviceCollection); } [Fact] - public void AddLambdaHostContextAccessor_RegistersILambdaHostContextAccessor() + public void AddLambdaInvocationContextAccessor_RegistersILambdaInvocationContextAccessor() { // Arrange var serviceCollection = new ServiceCollection(); // Act - serviceCollection.AddLambdaHostContextAccessor(); + serviceCollection.AddLambdaInvocationContextAccessor(); // Assert var descriptor = serviceCollection.FirstOrDefault(d => - d.ServiceType == typeof(ILambdaHostContextAccessor) + d.ServiceType == typeof(ILambdaInvocationContextAccessor) ); descriptor.Should().NotBeNull(); - descriptor!.ImplementationType.Should().Be(); + descriptor!.ImplementationType.Should().Be(); descriptor.Lifetime.Should().Be(ServiceLifetime.Singleton); } [Fact] - public void AddLambdaHostContextAccessor_EnablesMethodChaining() + public void AddLambdaInvocationContextAccessor_EnablesMethodChaining() { // Arrange var serviceCollection = new ServiceCollection(); // Act var result = serviceCollection - .AddLambdaHostContextAccessor() - .AddLambdaHostContextAccessor(); + .AddLambdaInvocationContextAccessor() + .AddLambdaInvocationContextAccessor(); // Assert result.Should().BeSameAs(serviceCollection); diff --git a/tests/MinimalLambda.UnitTests/Core/Context/LambdaHostContextAccessorTests.cs b/tests/MinimalLambda.UnitTests/Core/Context/LambdaHostContextAccessorTests.cs deleted file mode 100644 index c0849b4c..00000000 --- a/tests/MinimalLambda.UnitTests/Core/Context/LambdaHostContextAccessorTests.cs +++ /dev/null @@ -1,93 +0,0 @@ -namespace MinimalLambda.UnitTests.Core.Context; - -[TestSubject(typeof(LambdaHostContextAccessor))] -public class LambdaHostContextAccessorTests -{ - [Fact] - public void LambdaHostContext_WhenNotSet_ReturnsNull() - { - // Arrange - var accessor = new LambdaHostContextAccessor(); - - // Act - var result = accessor.LambdaHostContext; - - // Assert - result.Should().BeNull(); - } - - [Theory] - [AutoNSubstituteData] - internal void LambdaHostContext_WhenSet_ReturnsSetValue(ILambdaHostContext context) - { - // Arrange - var accessor = new LambdaHostContextAccessor(); - - // Act - accessor.LambdaHostContext = context; - var result = accessor.LambdaHostContext; - - // Assert - result.Should().BeSameAs(context); - } - - [Theory] - [AutoNSubstituteData] - internal void LambdaHostContext_WhenSetToNewValue_ReturnsNewValue( - ILambdaHostContext context1, - ILambdaHostContext context2 - ) - { - // Arrange - var accessor = new LambdaHostContextAccessor(); - accessor.LambdaHostContext = context1; - - // Act - accessor.LambdaHostContext = context2; - var result = accessor.LambdaHostContext; - - // Assert - result.Should().BeSameAs(context2); - result.Should().NotBeSameAs(context1); - } - - [Theory] - [AutoNSubstituteData] - internal void LambdaHostContext_WhenSetToNull_BecomesNull(ILambdaHostContext context) - { - // Arrange - var accessor = new LambdaHostContextAccessor(); - accessor.LambdaHostContext = context; - - // Act - accessor.LambdaHostContext = null; - var result = accessor.LambdaHostContext; - - // Assert - result.Should().BeNull(); - } - - [Theory] - [AutoNSubstituteData] - internal void LambdaHostContext_MultipleInstances_ShareAsyncLocalState( - ILambdaHostContext context1, - ILambdaHostContext context2 - ) - { - // Arrange - var accessor1 = new LambdaHostContextAccessor(); - var accessor2 = new LambdaHostContextAccessor(); - - // Act - accessor1.LambdaHostContext = context1; - var result1 = accessor2.LambdaHostContext; - - accessor2.LambdaHostContext = context2; - var result2 = accessor1.LambdaHostContext; - - // Assert - // Both accessors share the same AsyncLocal storage, so they see the latest value - result1.Should().BeSameAs(context1); - result2.Should().BeSameAs(context2); - } -} diff --git a/tests/MinimalLambda.UnitTests/Core/Context/LambdaInvocationContextAccessorTests.cs b/tests/MinimalLambda.UnitTests/Core/Context/LambdaInvocationContextAccessorTests.cs new file mode 100644 index 00000000..be865e95 --- /dev/null +++ b/tests/MinimalLambda.UnitTests/Core/Context/LambdaInvocationContextAccessorTests.cs @@ -0,0 +1,95 @@ +namespace MinimalLambda.UnitTests.Core.Context; + +[TestSubject(typeof(LambdaInvocationContextAccessor))] +public class LambdaInvocationContextAccessorTests +{ + [Fact] + public void LambdaInvocationContext_WhenNotSet_ReturnsNull() + { + // Arrange + var accessor = new LambdaInvocationContextAccessor(); + + // Act + var result = accessor.LambdaInvocationContext; + + // Assert + result.Should().BeNull(); + } + + [Theory] + [AutoNSubstituteData] + internal void LambdaInvocationContext_WhenSet_ReturnsSetValue(ILambdaInvocationContext context) + { + // Arrange + var accessor = new LambdaInvocationContextAccessor(); + + // Act + accessor.LambdaInvocationContext = context; + var result = accessor.LambdaInvocationContext; + + // Assert + result.Should().BeSameAs(context); + } + + [Theory] + [AutoNSubstituteData] + internal void LambdaInvocationContext_WhenSetToNewValue_ReturnsNewValue( + ILambdaInvocationContext context1, + ILambdaInvocationContext context2 + ) + { + // Arrange + var accessor = new LambdaInvocationContextAccessor(); + accessor.LambdaInvocationContext = context1; + + // Act + accessor.LambdaInvocationContext = context2; + var result = accessor.LambdaInvocationContext; + + // Assert + result.Should().BeSameAs(context2); + result.Should().NotBeSameAs(context1); + } + + [Theory] + [AutoNSubstituteData] + internal void LambdaInvocationContext_WhenSetToNull_BecomesNull( + ILambdaInvocationContext context + ) + { + // Arrange + var accessor = new LambdaInvocationContextAccessor(); + accessor.LambdaInvocationContext = context; + + // Act + accessor.LambdaInvocationContext = null; + var result = accessor.LambdaInvocationContext; + + // Assert + result.Should().BeNull(); + } + + [Theory] + [AutoNSubstituteData] + internal void LambdaInvocationContext_MultipleInstances_ShareAsyncLocalState( + ILambdaInvocationContext context1, + ILambdaInvocationContext context2 + ) + { + // Arrange + var accessor1 = new LambdaInvocationContextAccessor(); + var accessor2 = new LambdaInvocationContextAccessor(); + + // Act + accessor1.LambdaInvocationContext = context1; + var result1 = accessor2.LambdaInvocationContext; + + accessor2.LambdaInvocationContext = context2; + var result2 = accessor1.LambdaInvocationContext; + + // Assert + // Both accessors share the same AsyncLocal storage, so they see the latest value + result1.Should().BeSameAs(context1); + result2.Should().BeSameAs(context2); + } +} diff --git a/tests/MinimalLambda.UnitTests/Core/Context/LambdaHostContextFactoryTests.cs b/tests/MinimalLambda.UnitTests/Core/Context/LambdaInvocationContextFactory.cs similarity index 77% rename from tests/MinimalLambda.UnitTests/Core/Context/LambdaHostContextFactoryTests.cs rename to tests/MinimalLambda.UnitTests/Core/Context/LambdaInvocationContextFactory.cs index 70c65d37..0aac4edc 100644 --- a/tests/MinimalLambda.UnitTests/Core/Context/LambdaHostContextFactoryTests.cs +++ b/tests/MinimalLambda.UnitTests/Core/Context/LambdaInvocationContextFactory.cs @@ -2,8 +2,8 @@ namespace MinimalLambda.UnitTests.Core.Context; -[TestSubject(typeof(LambdaHostContextFactory))] -public class LambdaHostContextFactoryTests +[TestSubject(typeof(LambdaInvocationContextFactory))] +public class LambdaInvocationContextFactoryTests { [Fact] public void Constructor_WithNullServiceScopeFactory_ThrowsArgumentNullException() @@ -11,7 +11,10 @@ public void Constructor_WithNullServiceScopeFactory_ThrowsArgumentNullException( // Arrange & Act & Assert var act = () => { - _ = new LambdaHostContextFactory(null!, Substitute.For()); + _ = new LambdaInvocationContextFactory( + null!, + Substitute.For() + ); }; act.Should().Throw(); } @@ -22,7 +25,7 @@ public void Constructor_WithNullFeatureCollectionFactory_ThrowsArgumentNullExcep // Arrange & Act & Assert var act = () => { - _ = new LambdaHostContextFactory(Substitute.For(), null!); + _ = new LambdaInvocationContextFactory(Substitute.For(), null!); }; act.Should().Throw(); } @@ -35,7 +38,10 @@ IFeatureCollectionFactory featureCollectionFactory ) { // Act - var factory = new LambdaHostContextFactory(serviceScopeFactory, featureCollectionFactory); + var factory = new LambdaInvocationContextFactory( + serviceScopeFactory, + featureCollectionFactory + ); // Assert factory.Should().NotBeNull(); @@ -45,7 +51,7 @@ IFeatureCollectionFactory featureCollectionFactory public void Constructor_WithNullContextAccessor_SuccessfullyConstructs() { // Act - var factory = new LambdaHostContextFactory( + var factory = new LambdaInvocationContextFactory( Substitute.For(), Substitute.For() ); @@ -64,7 +70,10 @@ internal void Create_CallsFeatureCollectionFactoryCreate( ) { // Arrange - var factory = new LambdaHostContextFactory(serviceScopeFactory, featureCollectionFactory); + var factory = new LambdaInvocationContextFactory( + serviceScopeFactory, + featureCollectionFactory + ); // Act _ = factory.Create(lambdaContext, properties, CancellationToken.None); @@ -76,7 +85,7 @@ internal void Create_CallsFeatureCollectionFactoryCreate( [Theory] [AutoNSubstituteData] internal void Create_WithContextAccessor_SetsContextOnAccessor( - [Frozen] ILambdaHostContextAccessor? contextAccessor, + [Frozen] ILambdaInvocationContextAccessor? contextAccessor, IServiceScopeFactory serviceScopeFactory, IFeatureCollectionFactory featureCollectionFactory, ILambdaContext lambdaContext, @@ -84,7 +93,7 @@ internal void Create_WithContextAccessor_SetsContextOnAccessor( ) { // Arrange - var factory = new LambdaHostContextFactory( + var factory = new LambdaInvocationContextFactory( serviceScopeFactory, featureCollectionFactory, contextAccessor @@ -94,7 +103,7 @@ internal void Create_WithContextAccessor_SetsContextOnAccessor( _ = factory.Create(lambdaContext, properties, CancellationToken.None); // Assert - contextAccessor!.LambdaHostContext.Should().NotBeNull(); + contextAccessor!.LambdaInvocationContext.Should().NotBeNull(); } [Theory] @@ -103,8 +112,8 @@ internal void Create_GetsFeaturesFromProperties( [Frozen] IFeatureCollectionFactory featureCollectionFactory, IFeatureProvider eventFeatureProvider, IFeatureProvider responseFeatureProvider, - ILambdaHostContext lambdaContext, - LambdaHostContextFactory factory + ILambdaInvocationContext lambdaContext, + LambdaInvocationContextFactory factory ) { // Arrange diff --git a/tests/MinimalLambda.UnitTests/Core/Context/DefaultLambdaHostContextTests.cs b/tests/MinimalLambda.UnitTests/Core/Context/LambdaInvocationContextTests.cs similarity index 92% rename from tests/MinimalLambda.UnitTests/Core/Context/DefaultLambdaHostContextTests.cs rename to tests/MinimalLambda.UnitTests/Core/Context/LambdaInvocationContextTests.cs index b3e5ae3f..597d9d76 100644 --- a/tests/MinimalLambda.UnitTests/Core/Context/DefaultLambdaHostContextTests.cs +++ b/tests/MinimalLambda.UnitTests/Core/Context/LambdaInvocationContextTests.cs @@ -2,8 +2,8 @@ namespace MinimalLambda.UnitTests.Core.Context; -[TestSubject(typeof(DefaultLambdaHostContext))] -public class DefaultLambdaHostContextTests +[TestSubject(typeof(LambdaInvocationContext))] +public class LambdaInvocationContextTests { [Theory] [AutoNSubstituteData] @@ -16,7 +16,7 @@ CancellationToken cancellationToken { // Act & Assert var act = () => - new DefaultLambdaHostContext( + new LambdaInvocationContext( null!, serviceScopeFactory, properties, @@ -37,7 +37,7 @@ CancellationToken cancellationToken { // Act & Assert var act = () => - new DefaultLambdaHostContext( + new LambdaInvocationContext( lambdaContext, null!, properties, @@ -58,7 +58,7 @@ CancellationToken cancellationToken { // Act & Assert var act = () => - new DefaultLambdaHostContext( + new LambdaInvocationContext( lambdaContext, serviceScopeFactory, null!, @@ -79,7 +79,7 @@ CancellationToken cancellationToken { // Act & Assert var act = () => - new DefaultLambdaHostContext( + new LambdaInvocationContext( lambdaContext, serviceScopeFactory, properties, @@ -100,7 +100,7 @@ CancellationToken cancellationToken ) { // Act - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, properties, @@ -123,7 +123,7 @@ IFeatureCollection featuresCollection { // Arrange lambdaContext.AwsRequestId.Returns(expectedValue); - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, new Dictionary(), @@ -149,7 +149,7 @@ IFeatureCollection featuresCollection { // Arrange lambdaContext.ClientContext.Returns(expectedValue); - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, new Dictionary(), @@ -175,7 +175,7 @@ IFeatureCollection featuresCollection { // Arrange lambdaContext.FunctionName.Returns(expectedValue); - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, new Dictionary(), @@ -201,7 +201,7 @@ IFeatureCollection featuresCollection { // Arrange lambdaContext.FunctionVersion.Returns(expectedValue); - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, new Dictionary(), @@ -227,7 +227,7 @@ IFeatureCollection featuresCollection { // Arrange lambdaContext.Identity.Returns(expectedValue); - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, new Dictionary(), @@ -253,7 +253,7 @@ IFeatureCollection featuresCollection { // Arrange lambdaContext.InvokedFunctionArn.Returns(expectedValue); - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, new Dictionary(), @@ -279,7 +279,7 @@ IFeatureCollection featuresCollection { // Arrange lambdaContext.Logger.Returns(expectedValue); - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, new Dictionary(), @@ -305,7 +305,7 @@ IFeatureCollection featuresCollection { // Arrange lambdaContext.LogGroupName.Returns(expectedValue); - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, new Dictionary(), @@ -331,7 +331,7 @@ IFeatureCollection featuresCollection { // Arrange lambdaContext.LogStreamName.Returns(expectedValue); - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, new Dictionary(), @@ -357,7 +357,7 @@ IFeatureCollection featuresCollection { // Arrange lambdaContext.MemoryLimitInMB.Returns(expectedValue); - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, new Dictionary(), @@ -383,7 +383,7 @@ IFeatureCollection featuresCollection { // Arrange lambdaContext.RemainingTime.Returns(expectedValue); - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, new Dictionary(), @@ -412,7 +412,7 @@ IFeatureCollection featuresCollection { "key1", "value1" }, { "key2", 42 }, }; - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, propertiesDict, @@ -437,7 +437,7 @@ IFeatureCollection featuresCollection ) { // Arrange & Act - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, new Dictionary(), @@ -459,7 +459,7 @@ IFeatureCollection featuresCollection ) { // Arrange - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, new Dictionary(), @@ -486,7 +486,7 @@ IFeatureCollection featuresCollection ) { // Arrange - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, new Dictionary(), @@ -513,7 +513,7 @@ IFeatureCollection featuresCollection { // Arrange var expectedToken = new CancellationToken(); - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, new Dictionary(), @@ -537,7 +537,7 @@ IFeatureCollection featuresCollection ) { // Arrange - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, new Dictionary(), @@ -567,7 +567,7 @@ IFeatureCollection featuresCollection var serviceScopeFactory = Substitute.For(); serviceScopeFactory.CreateScope().Returns(mockScope); - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, new Dictionary(), @@ -599,7 +599,7 @@ IFeatureCollection featuresCollection var serviceScopeFactory = Substitute.For(); serviceScopeFactory.CreateScope().Returns(mockScope); - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, new Dictionary(), @@ -630,7 +630,7 @@ IFeatureCollection featuresCollection var mockScope = Substitute.For(); serviceScopeFactory.CreateScope().Returns(mockScope); - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, new Dictionary(), @@ -657,7 +657,7 @@ IFeatureCollection featuresCollection var serviceScopeFactory = Substitute.For(); serviceScopeFactory.CreateScope().Returns(asyncDisposableScope); - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, new Dictionary(), @@ -685,7 +685,7 @@ IFeatureCollection featuresCollection var serviceScopeFactory = Substitute.For(); serviceScopeFactory.CreateScope().Returns(mockScope); - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, new Dictionary(), @@ -710,7 +710,7 @@ IFeatureCollection featuresCollection ) { // Arrange - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, new Dictionary(), @@ -742,7 +742,7 @@ IFeatureCollection featuresCollection var serviceScopeFactory = Substitute.For(); serviceScopeFactory.CreateScope().Returns(mockScope); - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, new Dictionary(), @@ -768,7 +768,7 @@ IFeatureCollection featuresCollection ) { // Arrange - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, new Dictionary(), @@ -796,7 +796,7 @@ IFeatureCollection featuresCollection ) { // Arrange & Act - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, new Dictionary(), @@ -810,14 +810,14 @@ IFeatureCollection featuresCollection [Theory] [AutoNSubstituteData] - internal void ContextImplementsILambdaHostContext( + internal void ContextImplementsILambdaInvocationContext( ILambdaContext lambdaContext, IServiceScopeFactory serviceScopeFactory, IFeatureCollection featuresCollection ) { // Arrange & Act - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, new Dictionary(), @@ -826,7 +826,7 @@ IFeatureCollection featuresCollection ); // Assert - context.Should().BeAssignableTo(); + context.Should().BeAssignableTo(); } [Theory] @@ -838,7 +838,7 @@ IFeatureCollection featuresCollection ) { // Arrange & Act - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, new Dictionary(), @@ -860,14 +860,14 @@ IFeatureCollection featuresCollection ) { // Arrange - var context1 = new DefaultLambdaHostContext( + var context1 = new LambdaInvocationContext( lambdaContext1, serviceScopeFactory, new Dictionary(), featuresCollection, CancellationToken.None ); - var context2 = new DefaultLambdaHostContext( + var context2 = new LambdaInvocationContext( lambdaContext2, serviceScopeFactory, new Dictionary(), @@ -892,7 +892,7 @@ IFeatureCollection featuresCollection ) { // Arrange - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, new Dictionary(), @@ -920,7 +920,7 @@ IFeatureCollection featuresCollection { // Arrange var properties = new Dictionary { { "persistent", "value" } }; - var context = new DefaultLambdaHostContext( + var context = new LambdaInvocationContext( lambdaContext, serviceScopeFactory, properties, diff --git a/tests/MinimalLambda.UnitTests/Core/Features/DefaultEventFeatureProviderTests.cs b/tests/MinimalLambda.UnitTests/Core/Features/DefaultEventFeatureProviderTests.cs index b2d4f6eb..2c29734d 100644 --- a/tests/MinimalLambda.UnitTests/Core/Features/DefaultEventFeatureProviderTests.cs +++ b/tests/MinimalLambda.UnitTests/Core/Features/DefaultEventFeatureProviderTests.cs @@ -85,7 +85,7 @@ DefaultEventFeatureProvider provider internal void TryCreate_WithIEventFeatureType_InitializesFeatureWithSerializer( [Frozen] ILambdaSerializer serializer, DefaultEventFeatureProvider provider, - ILambdaHostContext context + ILambdaInvocationContext context ) { // Arrange diff --git a/tests/MinimalLambda.UnitTests/Core/Features/DefaultEventFeatureTests.cs b/tests/MinimalLambda.UnitTests/Core/Features/DefaultEventFeatureTests.cs index 69367c2e..b20d2a86 100644 --- a/tests/MinimalLambda.UnitTests/Core/Features/DefaultEventFeatureTests.cs +++ b/tests/MinimalLambda.UnitTests/Core/Features/DefaultEventFeatureTests.cs @@ -15,7 +15,7 @@ internal void GetEvent_PassesRawEventStreamToSerializer( [Frozen] IInvocationDataFeature dataFeature, [Frozen] Stream stream, DefaultEventFeature feature, - ILambdaHostContext context + ILambdaInvocationContext context ) { // Arrange @@ -64,7 +64,7 @@ ILambdaSerializer serializer internal void GetEvent_WithSimpleStringEvent_ReturnsDeserializedString( [Frozen] ILambdaSerializer serializer, DefaultEventFeature feature, - ILambdaHostContext context + ILambdaInvocationContext context ) { // Arrange @@ -84,7 +84,7 @@ ILambdaHostContext context internal void GetEvent_WithComplexObject_ReturnsDeserializedObject( [Frozen] ILambdaSerializer serializer, DefaultEventFeature feature, - ILambdaHostContext context + ILambdaInvocationContext context ) { // Arrange @@ -104,7 +104,7 @@ ILambdaHostContext context internal void GetEvent_WithNullableEvent_ReturnsDeserializedNullValue( [Frozen] ILambdaSerializer serializer, DefaultEventFeature feature, - ILambdaHostContext context + ILambdaInvocationContext context ) { // Arrange @@ -127,7 +127,7 @@ ILambdaHostContext context internal void GetEvent_CallsDeserializerOnFirstInvocation( [Frozen] ILambdaSerializer serializer, DefaultEventFeature feature, - ILambdaHostContext context + ILambdaInvocationContext context ) { // Arrange @@ -146,7 +146,7 @@ ILambdaHostContext context internal void GetEvent_CachesResultAndDoesNotDeserializeOnSecondInvocation( [Frozen] ILambdaSerializer serializer, DefaultEventFeature feature, - ILambdaHostContext context + ILambdaInvocationContext context ) { // Arrange @@ -168,7 +168,7 @@ ILambdaHostContext context internal void GetEvent_ReturnsSameCachedInstanceOnMultipleInvocations( [Frozen] ILambdaSerializer serializer, DefaultEventFeature feature, - ILambdaHostContext context + ILambdaInvocationContext context ) { // Arrange @@ -190,9 +190,9 @@ ILambdaHostContext context [AutoNSubstituteData] internal void GetEvent_WithMultipleInstances_CachesPerInstance( ILambdaSerializer serializer1, - ILambdaHostContext context1, + ILambdaInvocationContext context1, ILambdaSerializer serializer2, - ILambdaHostContext context2 + ILambdaInvocationContext context2 ) { // Arrange @@ -225,7 +225,7 @@ ILambdaHostContext context2 internal void GetEvent_WithGenericListType_ReturnsDeserializedList( [Frozen] ILambdaSerializer serializer, DefaultEventFeature> feature, - ILambdaHostContext context + ILambdaInvocationContext context ) { // Arrange @@ -249,7 +249,7 @@ ILambdaHostContext context internal void GetEvent_WithGenericDictionaryType_ReturnsDeserializedDictionary( [Frozen] ILambdaSerializer serializer, DefaultEventFeature> feature, - ILambdaHostContext context + ILambdaInvocationContext context ) { // Arrange @@ -268,7 +268,7 @@ ILambdaHostContext context internal void GetEvent_WithNestedGenericType_ReturnsDeserializedNestedType( [Frozen] ILambdaSerializer serializer, DefaultEventFeature feature, - ILambdaHostContext context + ILambdaInvocationContext context ) { // Arrange @@ -297,7 +297,7 @@ ILambdaHostContext context internal void IEventFeatureGetEvent_ReturnsObjectCastFromGenericGetEvent( [Frozen] ILambdaSerializer serializer, DefaultEventFeature feature, - ILambdaHostContext context + ILambdaInvocationContext context ) { // Arrange @@ -316,7 +316,7 @@ ILambdaHostContext context internal void IEventFeatureGetEvent_AndGenericGetEvent_ReturnSameCachedInstance( [Frozen] ILambdaSerializer serializer, DefaultEventFeature feature, - ILambdaHostContext context + ILambdaInvocationContext context ) { // Arrange @@ -354,7 +354,7 @@ [Frozen] ILambdaSerializer serializer internal void GetEvent_WhenDeserializerThrowsException_PropagatesException( [Frozen] ILambdaSerializer serializer, DefaultEventFeature feature, - ILambdaHostContext context + ILambdaInvocationContext context ) { // Arrange @@ -372,7 +372,7 @@ ILambdaHostContext context internal void GetEvent_AfterDeserializationException_RethrowsExceptionOnNextCall( [Frozen] ILambdaSerializer serializer, DefaultEventFeature feature, - ILambdaHostContext context + ILambdaInvocationContext context ) { // Arrange @@ -399,7 +399,7 @@ ILambdaHostContext context internal void GetEvent_WithEmptyMemoryStream_DeserializesEmptyStream( [Frozen] ILambdaSerializer serializer, DefaultEventFeature feature, - ILambdaHostContext context + ILambdaInvocationContext context ) { // Arrange @@ -417,7 +417,7 @@ ILambdaHostContext context internal void GetEvent_WithValueTypeDefaultValue_ReturnsDefaultOfT( [Frozen] ILambdaSerializer serializer, DefaultEventFeature feature, - ILambdaHostContext context + ILambdaInvocationContext context ) { // Arrange @@ -435,7 +435,7 @@ ILambdaHostContext context internal void GetEvent_WithLargeObject_ReturnsDeserializedLargeObject( [Frozen] ILambdaSerializer serializer, DefaultEventFeature feature, - ILambdaHostContext context + ILambdaInvocationContext context ) { // Arrange @@ -455,7 +455,7 @@ ILambdaHostContext context internal void GetEvent_WithNullableStruct_ReturnsDeserializedNullValue( [Frozen] ILambdaSerializer serializer, DefaultEventFeature feature, - ILambdaHostContext context + ILambdaInvocationContext context ) { // Arrange @@ -474,7 +474,7 @@ ILambdaHostContext context internal void GetEvent_WithNullableStructValue_ReturnsDeserializedValue( [Frozen] ILambdaSerializer serializer, DefaultEventFeature feature, - ILambdaHostContext context + ILambdaInvocationContext context ) { // Arrange diff --git a/tests/MinimalLambda.UnitTests/Core/Features/DefaultResponseFeatureTests.cs b/tests/MinimalLambda.UnitTests/Core/Features/DefaultResponseFeatureTests.cs index b0d321c4..f0b138bc 100644 --- a/tests/MinimalLambda.UnitTests/Core/Features/DefaultResponseFeatureTests.cs +++ b/tests/MinimalLambda.UnitTests/Core/Features/DefaultResponseFeatureTests.cs @@ -140,7 +140,7 @@ internal void SerializeToStream_WhenResponseIsSet_CallsSerializer( [Frozen] Stream responseStream, [Frozen] ILambdaSerializer serializer, DefaultResponseFeature feature, - ILambdaHostContext context, + ILambdaInvocationContext context, string testData ) { @@ -159,7 +159,7 @@ string testData internal void SerializeToStream_WhenResponseNotSet_DoesNotCallSerializer( [Frozen] ILambdaSerializer serializer, DefaultResponseFeature feature, - ILambdaHostContext context + ILambdaInvocationContext context ) { // Act @@ -174,7 +174,7 @@ ILambdaHostContext context internal void SerializeToStream_WhenResponseIsSet_ClearsResponseStream( [Frozen] Stream responseStream, DefaultResponseFeature feature, - ILambdaHostContext context, + ILambdaInvocationContext context, string testData ) { @@ -193,7 +193,7 @@ string testData internal void SerializeToStream_WhenResponseIsSet_ResetsStreamPosition( [Frozen] Stream responseStream, DefaultResponseFeature feature, - ILambdaHostContext context, + ILambdaInvocationContext context, string testData ) { diff --git a/tests/MinimalLambda.UnitTests/Core/Features/FeatureLambdaHostContextExtensionsTests.cs b/tests/MinimalLambda.UnitTests/Core/Features/FeatureLambdaInvocationContextExtensionsTest.cs similarity index 90% rename from tests/MinimalLambda.UnitTests/Core/Features/FeatureLambdaHostContextExtensionsTests.cs rename to tests/MinimalLambda.UnitTests/Core/Features/FeatureLambdaInvocationContextExtensionsTest.cs index 6a58b7df..ef4119d9 100644 --- a/tests/MinimalLambda.UnitTests/Core/Features/FeatureLambdaHostContextExtensionsTests.cs +++ b/tests/MinimalLambda.UnitTests/Core/Features/FeatureLambdaInvocationContextExtensionsTest.cs @@ -1,7 +1,7 @@ namespace MinimalLambda.UnitTests.Core.Features; -[TestSubject(typeof(FeatureLambdaHostContextExtensions))] -public class FeatureLambdaHostContextExtensionsTest +[TestSubject(typeof(FeatureLambdaInvocationContextExtensions))] +public class FeatureLambdaInvocationContextExtensionsTest { #region GetEvent Tests @@ -9,7 +9,7 @@ public class FeatureLambdaHostContextExtensionsTest [AutoNSubstituteData] public void GetEvent_ReturnsEventWhenFeatureExistsAndTypeMatches( [Frozen] IFeatureCollection features, - ILambdaHostContext context, + ILambdaInvocationContext context, IEventFeature eventFeature, TestEvent expectedEvent ) @@ -29,7 +29,7 @@ TestEvent expectedEvent [AutoNSubstituteData] public void GetEvent_ReturnsNullWhenFeatureNotInCollection( [Frozen] IFeatureCollection features, - ILambdaHostContext context + ILambdaInvocationContext context ) { // Arrange @@ -46,7 +46,7 @@ ILambdaHostContext context [AutoNSubstituteData] public void GetEvent_ReturnsNullWhenGetEventReturnsNull( [Frozen] IFeatureCollection features, - ILambdaHostContext context, + ILambdaInvocationContext context, IEventFeature eventFeature ) { @@ -65,7 +65,7 @@ IEventFeature eventFeature [AutoNSubstituteData] public void GetEvent_ReturnsNullWhenEventTypeDoesNotMatch( [Frozen] IFeatureCollection features, - ILambdaHostContext context, + ILambdaInvocationContext context, IEventFeature eventFeature, string wrongTypeEvent ) @@ -85,7 +85,7 @@ string wrongTypeEvent [AutoNSubstituteData] public void GetEvent_WorksWithDifferentEventTypes( [Frozen] IFeatureCollection features, - ILambdaHostContext context, + ILambdaInvocationContext context, IEventFeature eventFeature, string stringEvent ) @@ -109,7 +109,7 @@ string stringEvent [AutoNSubstituteData] public void TryGetEvent_ReturnsTrueWhenEventExists( [Frozen] IFeatureCollection features, - ILambdaHostContext context, + ILambdaInvocationContext context, IEventFeature eventFeature, TestEvent expectedEvent ) @@ -130,7 +130,7 @@ TestEvent expectedEvent [AutoNSubstituteData] public void TryGetEvent_ReturnsFalseWhenFeatureNotFound( [Frozen] IFeatureCollection features, - ILambdaHostContext context + ILambdaInvocationContext context ) { // Arrange @@ -148,7 +148,7 @@ ILambdaHostContext context [AutoNSubstituteData] public void TryGetEvent_ReturnsFalseWhenTypeDoesNotMatch( [Frozen] IFeatureCollection features, - ILambdaHostContext context, + ILambdaInvocationContext context, IEventFeature eventFeature, string wrongTypeEvent ) @@ -169,7 +169,7 @@ string wrongTypeEvent [AutoNSubstituteData] public void TryGetEvent_WorksWithDifferentEventTypes( [Frozen] IFeatureCollection features, - ILambdaHostContext context, + ILambdaInvocationContext context, IEventFeature eventFeature, string stringEvent ) @@ -194,7 +194,7 @@ string stringEvent [AutoNSubstituteData] public void GetResponse_ReturnsResponseWhenFeatureExistsAndTypeMatches( [Frozen] IFeatureCollection features, - ILambdaHostContext context, + ILambdaInvocationContext context, IResponseFeature responseFeature, TestResponse expectedResponse ) @@ -214,7 +214,7 @@ TestResponse expectedResponse [AutoNSubstituteData] public void GetResponse_ReturnsNullWhenFeatureNotInCollection( [Frozen] IFeatureCollection features, - ILambdaHostContext context + ILambdaInvocationContext context ) { // Arrange @@ -231,7 +231,7 @@ ILambdaHostContext context [AutoNSubstituteData] public void GetResponse_ReturnsNullWhenGetResponseReturnsNull( [Frozen] IFeatureCollection features, - ILambdaHostContext context, + ILambdaInvocationContext context, IResponseFeature responseFeature ) { @@ -250,7 +250,7 @@ IResponseFeature responseFeature [AutoNSubstituteData] public void GetResponse_ReturnsNullWhenResponseTypeDoesNotMatch( [Frozen] IFeatureCollection features, - ILambdaHostContext context, + ILambdaInvocationContext context, IResponseFeature responseFeature, string wrongTypeResponse ) @@ -270,7 +270,7 @@ string wrongTypeResponse [AutoNSubstituteData] public void GetResponse_WorksWithDifferentResponseTypes( [Frozen] IFeatureCollection features, - ILambdaHostContext context, + ILambdaInvocationContext context, IResponseFeature responseFeature, string stringResponse ) @@ -294,7 +294,7 @@ string stringResponse [AutoNSubstituteData] public void TryGetResponse_ReturnsTrueWhenResponseExists( [Frozen] IFeatureCollection features, - ILambdaHostContext context, + ILambdaInvocationContext context, IResponseFeature responseFeature, TestResponse expectedResponse ) @@ -315,7 +315,7 @@ TestResponse expectedResponse [AutoNSubstituteData] public void TryGetResponse_ReturnsFalseWhenFeatureNotFound( [Frozen] IFeatureCollection features, - ILambdaHostContext context + ILambdaInvocationContext context ) { // Arrange @@ -333,7 +333,7 @@ ILambdaHostContext context [AutoNSubstituteData] public void TryGetResponse_ReturnsFalseWhenTypeDoesNotMatch( [Frozen] IFeatureCollection features, - ILambdaHostContext context, + ILambdaInvocationContext context, IResponseFeature responseFeature, string wrongTypeResponse ) @@ -354,7 +354,7 @@ string wrongTypeResponse [AutoNSubstituteData] public void TryGetResponse_WorksWithDifferentResponseTypes( [Frozen] IFeatureCollection features, - ILambdaHostContext context, + ILambdaInvocationContext context, IResponseFeature responseFeature, string stringResponse ) @@ -379,7 +379,7 @@ string stringResponse [AutoNSubstituteData] public void GetRequiredEvent_ReturnsEventWhenFeatureExistsAndTypeMatches( [Frozen] IFeatureCollection features, - ILambdaHostContext context, + ILambdaInvocationContext context, IEventFeature eventFeature, TestEvent expectedEvent ) @@ -399,7 +399,7 @@ TestEvent expectedEvent [AutoNSubstituteData] public void GetRequiredEvent_ThrowsInvalidOperationExceptionWhenFeatureNotFound( [Frozen] IFeatureCollection features, - ILambdaHostContext context + ILambdaInvocationContext context ) { // Arrange @@ -418,7 +418,7 @@ ILambdaHostContext context [AutoNSubstituteData] public void GetRequiredEvent_ThrowsInvalidOperationExceptionWhenEventIsNull( [Frozen] IFeatureCollection features, - ILambdaHostContext context, + ILambdaInvocationContext context, IEventFeature eventFeature ) { @@ -439,7 +439,7 @@ IEventFeature eventFeature [AutoNSubstituteData] public void GetRequiredEvent_ThrowsInvalidOperationExceptionWhenTypeDoesNotMatch( [Frozen] IFeatureCollection features, - ILambdaHostContext context, + ILambdaInvocationContext context, IEventFeature eventFeature, string wrongTypeEvent ) @@ -461,7 +461,7 @@ string wrongTypeEvent [AutoNSubstituteData] public void GetRequiredEvent_WorksWithDifferentEventTypes( [Frozen] IFeatureCollection features, - ILambdaHostContext context, + ILambdaInvocationContext context, IEventFeature eventFeature, string stringEvent ) @@ -485,7 +485,7 @@ string stringEvent [AutoNSubstituteData] public void GetRequiredResponse_ReturnsResponseWhenFeatureExistsAndTypeMatches( [Frozen] IFeatureCollection features, - ILambdaHostContext context, + ILambdaInvocationContext context, IResponseFeature responseFeature, TestResponse expectedResponse ) @@ -505,7 +505,7 @@ TestResponse expectedResponse [AutoNSubstituteData] public void GetRequiredResponse_ThrowsInvalidOperationExceptionWhenFeatureNotFound( [Frozen] IFeatureCollection features, - ILambdaHostContext context + ILambdaInvocationContext context ) { // Arrange @@ -524,7 +524,7 @@ ILambdaHostContext context [AutoNSubstituteData] public void GetRequiredResponse_ThrowsInvalidOperationExceptionWhenResponseIsNull( [Frozen] IFeatureCollection features, - ILambdaHostContext context, + ILambdaInvocationContext context, IResponseFeature responseFeature ) { @@ -545,7 +545,7 @@ IResponseFeature responseFeature [AutoNSubstituteData] public void GetRequiredResponse_ThrowsInvalidOperationExceptionWhenTypeDoesNotMatch( [Frozen] IFeatureCollection features, - ILambdaHostContext context, + ILambdaInvocationContext context, IResponseFeature responseFeature, string wrongTypeResponse ) @@ -567,7 +567,7 @@ string wrongTypeResponse [AutoNSubstituteData] public void GetRequiredResponse_WorksWithDifferentResponseTypes( [Frozen] IFeatureCollection features, - ILambdaHostContext context, + ILambdaInvocationContext context, IResponseFeature responseFeature, string stringResponse ) @@ -591,7 +591,7 @@ string stringResponse public void GetEvent_ThrowsArgumentNullExceptionWhenContextIsNull() { // Act & Assert - var act = () => ((ILambdaHostContext?)null)!.GetEvent(); + var act = () => ((ILambdaInvocationContext?)null)!.GetEvent(); act.Should().ThrowExactly(); } @@ -599,7 +599,7 @@ public void GetEvent_ThrowsArgumentNullExceptionWhenContextIsNull() public void TryGetEvent_ThrowsArgumentNullExceptionWhenContextIsNull() { // Act & Assert - var act = () => ((ILambdaHostContext?)null)!.TryGetEvent(out TestEvent? _); + var act = () => ((ILambdaInvocationContext?)null)!.TryGetEvent(out TestEvent? _); act.Should().ThrowExactly(); } @@ -607,7 +607,7 @@ public void TryGetEvent_ThrowsArgumentNullExceptionWhenContextIsNull() public void GetResponse_ThrowsArgumentNullExceptionWhenContextIsNull() { // Act & Assert - var act = () => ((ILambdaHostContext?)null)!.GetResponse(); + var act = () => ((ILambdaInvocationContext?)null)!.GetResponse(); act.Should().ThrowExactly(); } @@ -615,7 +615,7 @@ public void GetResponse_ThrowsArgumentNullExceptionWhenContextIsNull() public void TryGetResponse_ThrowsArgumentNullExceptionWhenContextIsNull() { // Act & Assert - var act = () => ((ILambdaHostContext?)null)!.TryGetResponse(out TestResponse? _); + var act = () => ((ILambdaInvocationContext?)null)!.TryGetResponse(out TestResponse? _); act.Should().ThrowExactly(); } @@ -623,7 +623,7 @@ public void TryGetResponse_ThrowsArgumentNullExceptionWhenContextIsNull() public void GetRequiredEvent_ThrowsArgumentNullExceptionWhenContextIsNull() { // Act & Assert - var act = () => ((ILambdaHostContext?)null)!.GetRequiredEvent(); + var act = () => ((ILambdaInvocationContext?)null)!.GetRequiredEvent(); act.Should().ThrowExactly(); } @@ -631,7 +631,7 @@ public void GetRequiredEvent_ThrowsArgumentNullExceptionWhenContextIsNull() public void GetRequiredResponse_ThrowsArgumentNullExceptionWhenContextIsNull() { // Act & Assert - var act = () => ((ILambdaHostContext?)null)!.GetRequiredResponse(); + var act = () => ((ILambdaInvocationContext?)null)!.GetRequiredResponse(); act.Should().ThrowExactly(); } diff --git a/tests/MinimalLambda.UnitTests/Core/Runtime/LambdaHandlerComposerTests.cs b/tests/MinimalLambda.UnitTests/Core/Runtime/LambdaHandlerComposerTests.cs index 5f6af7d9..5764e368 100644 --- a/tests/MinimalLambda.UnitTests/Core/Runtime/LambdaHandlerComposerTests.cs +++ b/tests/MinimalLambda.UnitTests/Core/Runtime/LambdaHandlerComposerTests.cs @@ -39,14 +39,14 @@ public Fixture() LambdaInvocationBuilderFactory = Substitute.For(); CancellationFactory = Substitute.For(); Options = Microsoft.Extensions.Options.Options.Create(new LambdaHostedServiceOptions()); - LambdaHostContextFactory = Substitute.For(); + LambdaInvocationContextFactory = Substitute.For(); InvocationDataFeatureFactory = Substitute.For(); InvocationBuilder = Substitute.For(); CancellationTokenSource = new CancellationTokenSource(); LambdaContext = Substitute.For(); ResponseFeature = Substitute.For(); - LambdaHostContext = Substitute.For(); + LambdaInvocationContext = Substitute.For(); SetupDefaults(); } @@ -56,8 +56,8 @@ public Fixture() public ILambdaInvocationBuilder InvocationBuilder { get; } public IInvocationDataFeatureFactory InvocationDataFeatureFactory { get; } public ILambdaContext LambdaContext { get; } - public ILambdaHostContext LambdaHostContext { get; } - public ILambdaHostContextFactory LambdaHostContextFactory { get; } + public ILambdaInvocationContext LambdaInvocationContext { get; } + public ILambdaInvocationContextFactory LambdaInvocationContextFactory { get; } public ILambdaInvocationBuilderFactory LambdaInvocationBuilderFactory { get; } public IOptions Options { get; } public IResponseFeature ResponseFeature { get; } @@ -85,7 +85,7 @@ private void SetupDefaults() .Returns(mockInvocationDataFeature); // Set up the context factory to return a mock context for any Create call - LambdaHostContextFactory + LambdaInvocationContextFactory .Create( Arg.Any(), Arg.Any>(), @@ -94,11 +94,11 @@ private void SetupDefaults() .Returns(info => { // Create a new mock context for each call - LambdaHostContext.Features.Returns(mockFeatures); - ((IAsyncDisposable)LambdaHostContext) + LambdaInvocationContext.Features.Returns(mockFeatures); + ((IAsyncDisposable)LambdaInvocationContext) .DisposeAsync() .Returns(ValueTask.CompletedTask); - return LambdaHostContext; + return LambdaInvocationContext; }); } @@ -108,7 +108,7 @@ public LambdaHandlerComposer CreateComposer() => LambdaInvocationBuilderFactory, CancellationFactory, Options, - LambdaHostContextFactory, + LambdaInvocationContextFactory, InvocationDataFeatureFactory ); @@ -133,7 +133,7 @@ public CancellationTokenSource CreateNewCancellationTokenSource() [InlineData(0)] // LambdaInvocationBuilderFactory [InlineData(1)] // CancellationFactory [InlineData(2)] // Options - [InlineData(3)] // LambdaHostContextFactory + [InlineData(3)] // LambdaInvocationContextFactory [InlineData(4)] // InvocationDataFeatureFactory public void Constructor_WithNullParameter_ThrowsArgumentNullException(int parameterIndex) { @@ -142,7 +142,7 @@ public void Constructor_WithNullParameter_ThrowsArgumentNullException(int parame parameterIndex == 0 ? null : _fixture.LambdaInvocationBuilderFactory; var cancellationFactory = parameterIndex == 1 ? null : _fixture.CancellationFactory; var options = parameterIndex == 2 ? null : _fixture.Options; - var contextFactory = parameterIndex == 3 ? null : _fixture.LambdaHostContextFactory; + var contextFactory = parameterIndex == 3 ? null : _fixture.LambdaInvocationContextFactory; var invocationDataFeatureFactory = parameterIndex == 4 ? null : _fixture.InvocationDataFeatureFactory; @@ -232,7 +232,7 @@ public void CreateHandler_InvokesConfigureHandlerBuilder_WhenProvided() _fixture.LambdaInvocationBuilderFactory, _fixture.CancellationFactory, options, - _fixture.LambdaHostContextFactory, + _fixture.LambdaInvocationContextFactory, _fixture.InvocationDataFeatureFactory );