From 823311eb48550757598be7bb86148a9d6c44d50d Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Sat, 29 Nov 2025 13:27:28 -0500 Subject: [PATCH 01/48] refactor(core): enhance null safety in DefaultFeatureCollectionFactory - Added null-checking logic to filter out null `IFeatureProvider` instances. - Simplified constructor and improved internal field initialization. --- .../Core/Features/DefaultFeatureCollectionFactory.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/AwsLambda.Host/Core/Features/DefaultFeatureCollectionFactory.cs b/src/AwsLambda.Host/Core/Features/DefaultFeatureCollectionFactory.cs index e86fe504..b7c80584 100644 --- a/src/AwsLambda.Host/Core/Features/DefaultFeatureCollectionFactory.cs +++ b/src/AwsLambda.Host/Core/Features/DefaultFeatureCollectionFactory.cs @@ -1,7 +1,11 @@ namespace AwsLambda.Host.Core; -internal class DefaultFeatureCollectionFactory(IEnumerable featureProviders) - : IFeatureCollectionFactory +internal class DefaultFeatureCollectionFactory : IFeatureCollectionFactory { - public IFeatureCollection Create() => new DefaultFeatureCollection(featureProviders); + private readonly IEnumerable _featureProviders; + + public DefaultFeatureCollectionFactory(IEnumerable featureProviders) => + _featureProviders = featureProviders.Where(x => x is not null).Select(x => x!).ToArray(); + + public IFeatureCollection Create() => new DefaultFeatureCollection(_featureProviders); } From 5027f322bbcab03742dd1858db0b30812de920e6 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Sat, 29 Nov 2025 13:27:28 -0500 Subject: [PATCH 02/48] refactor(core): enhance null safety in DefaultFeatureCollectionFactory - Added null-checking logic to filter out null `IFeatureProvider` instances. - Simplified constructor and improved internal field initialization. --- .../Core/Features/DefaultFeatureCollectionFactory.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/AwsLambda.Host/Core/Features/DefaultFeatureCollectionFactory.cs b/src/AwsLambda.Host/Core/Features/DefaultFeatureCollectionFactory.cs index e86fe504..b7c80584 100644 --- a/src/AwsLambda.Host/Core/Features/DefaultFeatureCollectionFactory.cs +++ b/src/AwsLambda.Host/Core/Features/DefaultFeatureCollectionFactory.cs @@ -1,7 +1,11 @@ namespace AwsLambda.Host.Core; -internal class DefaultFeatureCollectionFactory(IEnumerable featureProviders) - : IFeatureCollectionFactory +internal class DefaultFeatureCollectionFactory : IFeatureCollectionFactory { - public IFeatureCollection Create() => new DefaultFeatureCollection(featureProviders); + private readonly IEnumerable _featureProviders; + + public DefaultFeatureCollectionFactory(IEnumerable featureProviders) => + _featureProviders = featureProviders.Where(x => x is not null).Select(x => x!).ToArray(); + + public IFeatureCollection Create() => new DefaultFeatureCollection(_featureProviders); } From c63db6a0e94fdf4c78840b31c10a9f3430b64263 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Tue, 2 Dec 2025 18:17:53 -0500 Subject: [PATCH 03/48] feat(core): add support for feature provider factories - Introduced `EventFeatureProviderFactory` and `ResponseFeatureProviderFactory` implementations. - Added `IEventFeatureProviderFactory` and `IResponseFeatureProviderFactory` interfaces. - Registered feature provider factories into the service collection. --- .../Features/IEventFeatureProviderFactory.cs | 6 ++++++ .../Features/IResponseFeatureProviderFactory.cs | 6 ++++++ .../Extensions/ServiceCollectionExtensions.cs | 11 +++++++++++ .../Builder/LambdaInvocationBuilder.cs | 2 ++ .../Core/Features/EventFeatureProviderFactory.cs | 13 +++++++++++++ .../Core/Features/ResponseFeatureProviderFactory.cs | 13 +++++++++++++ 6 files changed, 51 insertions(+) create mode 100644 src/AwsLambda.Host.Abstractions/Features/IEventFeatureProviderFactory.cs create mode 100644 src/AwsLambda.Host.Abstractions/Features/IResponseFeatureProviderFactory.cs create mode 100644 src/AwsLambda.Host/Core/Features/EventFeatureProviderFactory.cs create mode 100644 src/AwsLambda.Host/Core/Features/ResponseFeatureProviderFactory.cs diff --git a/src/AwsLambda.Host.Abstractions/Features/IEventFeatureProviderFactory.cs b/src/AwsLambda.Host.Abstractions/Features/IEventFeatureProviderFactory.cs new file mode 100644 index 00000000..2f560e45 --- /dev/null +++ b/src/AwsLambda.Host.Abstractions/Features/IEventFeatureProviderFactory.cs @@ -0,0 +1,6 @@ +namespace AwsLambda.Host.Core; + +public interface IEventFeatureProviderFactory +{ + IFeatureProvider Create(); +} diff --git a/src/AwsLambda.Host.Abstractions/Features/IResponseFeatureProviderFactory.cs b/src/AwsLambda.Host.Abstractions/Features/IResponseFeatureProviderFactory.cs new file mode 100644 index 00000000..d2a6f7ee --- /dev/null +++ b/src/AwsLambda.Host.Abstractions/Features/IResponseFeatureProviderFactory.cs @@ -0,0 +1,6 @@ +namespace AwsLambda.Host.Core; + +public interface IResponseFeatureProviderFactory +{ + IFeatureProvider Create(); +} diff --git a/src/AwsLambda.Host/Builder/Extensions/ServiceCollectionExtensions.cs b/src/AwsLambda.Host/Builder/Extensions/ServiceCollectionExtensions.cs index fc8313e2..507598e7 100644 --- a/src/AwsLambda.Host/Builder/Extensions/ServiceCollectionExtensions.cs +++ b/src/AwsLambda.Host/Builder/Extensions/ServiceCollectionExtensions.cs @@ -1,9 +1,13 @@ +#region + using Amazon.Lambda.Core; using Amazon.Lambda.Serialization.SystemTextJson; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Options; +#endregion + namespace Microsoft.Extensions.DependencyInjection; /// Extension methods for registering Lambda Host services. @@ -48,6 +52,13 @@ public IServiceCollection AddLambdaHostCoreServices() EnvelopeOptionsPostConfiguration >(); + // Register IFeatureProvider factories + services.AddSingleton< + IResponseFeatureProviderFactory, + ResponseFeatureProviderFactory + >(); + services.AddSingleton(); + return services; } diff --git a/src/AwsLambda.Host/Builder/LambdaInvocationBuilder.cs b/src/AwsLambda.Host/Builder/LambdaInvocationBuilder.cs index 1660da93..bd46faa9 100644 --- a/src/AwsLambda.Host/Builder/LambdaInvocationBuilder.cs +++ b/src/AwsLambda.Host/Builder/LambdaInvocationBuilder.cs @@ -2,6 +2,8 @@ namespace AwsLambda.Host.Builder; internal class LambdaInvocationBuilder : ILambdaInvocationBuilder { + internal const string FeatureProvidersKey = "__FeatureProviders"; + private readonly List> _middleware = []; diff --git a/src/AwsLambda.Host/Core/Features/EventFeatureProviderFactory.cs b/src/AwsLambda.Host/Core/Features/EventFeatureProviderFactory.cs new file mode 100644 index 00000000..0560ad53 --- /dev/null +++ b/src/AwsLambda.Host/Core/Features/EventFeatureProviderFactory.cs @@ -0,0 +1,13 @@ +#region + +using Amazon.Lambda.Core; + +#endregion + +namespace AwsLambda.Host.Core; + +internal class EventFeatureProviderFactory(ILambdaSerializer lambdaSerializer) + : IEventFeatureProviderFactory +{ + public IFeatureProvider Create() => new DefaultEventFeatureProvider(lambdaSerializer); +} diff --git a/src/AwsLambda.Host/Core/Features/ResponseFeatureProviderFactory.cs b/src/AwsLambda.Host/Core/Features/ResponseFeatureProviderFactory.cs new file mode 100644 index 00000000..28a270e5 --- /dev/null +++ b/src/AwsLambda.Host/Core/Features/ResponseFeatureProviderFactory.cs @@ -0,0 +1,13 @@ +#region + +using Amazon.Lambda.Core; + +#endregion + +namespace AwsLambda.Host.Core; + +internal class ResponseFeatureProviderFactory(ILambdaSerializer lambdaSerializer) + : IResponseFeatureProviderFactory +{ + public IFeatureProvider Create() => new DefaultResponseFeatureProvider(lambdaSerializer); +} From 1ca12fa2ce530b7073650f60acdacc39e83e67fa Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Tue, 2 Dec 2025 18:22:09 -0500 Subject: [PATCH 04/48] feat(core): add XML documentation to feature provider factories - Added summary and remarks for `IResponseFeatureProviderFactory` and `IEventFeatureProviderFactory`. - Documented type parameters and return values for `Create` methods. --- .../Features/IEventFeatureProviderFactory.cs | 15 +++++++++++++++ .../Features/IResponseFeatureProviderFactory.cs | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/AwsLambda.Host.Abstractions/Features/IEventFeatureProviderFactory.cs b/src/AwsLambda.Host.Abstractions/Features/IEventFeatureProviderFactory.cs index 2f560e45..5d56b2fc 100644 --- a/src/AwsLambda.Host.Abstractions/Features/IEventFeatureProviderFactory.cs +++ b/src/AwsLambda.Host.Abstractions/Features/IEventFeatureProviderFactory.cs @@ -1,6 +1,21 @@ namespace AwsLambda.Host.Core; +/// Creates feature providers for Lambda event deserialization. +/// +/// +/// creates +/// instances for specific event types during Lambda invocations. The factory enables +/// lazy registration of event feature providers. This factory is registered automatically +/// at startup. +/// +/// public interface IEventFeatureProviderFactory { + /// Creates a feature provider for the specified event type. + /// The type of event object to create a provider for. + /// + /// An that can create + /// instances for the specified type. + /// IFeatureProvider Create(); } diff --git a/src/AwsLambda.Host.Abstractions/Features/IResponseFeatureProviderFactory.cs b/src/AwsLambda.Host.Abstractions/Features/IResponseFeatureProviderFactory.cs index d2a6f7ee..d742f0bd 100644 --- a/src/AwsLambda.Host.Abstractions/Features/IResponseFeatureProviderFactory.cs +++ b/src/AwsLambda.Host.Abstractions/Features/IResponseFeatureProviderFactory.cs @@ -1,6 +1,21 @@ namespace AwsLambda.Host.Core; +/// Creates feature providers for Lambda response serialization. +/// +/// +/// creates +/// instances for specific response types during Lambda invocations. The factory enables +/// lazy registration of response feature providers. This factory is registered automatically +/// at startup. +/// +/// public interface IResponseFeatureProviderFactory { + /// Creates a feature provider for the specified response type. + /// The type of response object to create a provider for. + /// + /// An that can create + /// instances for the specified type. + /// IFeatureProvider Create(); } From 56d37ff741254dd5c6f19061cef6697367c7b62a Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Tue, 2 Dec 2025 18:22:53 -0500 Subject: [PATCH 05/48] refactor(core): change feature provider classes to internal - Updated `DefaultEventFeatureProvider` and `DefaultResponseFeatureProvider` visibility to internal. - Enhances encapsulation and restricts unnecessary exposure of types. --- .../Core/Features/DefaultEventFeatureProvider.cs | 6 +++++- .../Core/Features/DefaultResponseFeatureProvider.cs | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/AwsLambda.Host/Core/Features/DefaultEventFeatureProvider.cs b/src/AwsLambda.Host/Core/Features/DefaultEventFeatureProvider.cs index 14bd921e..e2040359 100644 --- a/src/AwsLambda.Host/Core/Features/DefaultEventFeatureProvider.cs +++ b/src/AwsLambda.Host/Core/Features/DefaultEventFeatureProvider.cs @@ -1,5 +1,9 @@ +#region + using Amazon.Lambda.Core; +#endregion + namespace AwsLambda.Host.Core; /// @@ -7,7 +11,7 @@ namespace AwsLambda.Host.Core; /// deserialization. This provider is instantiated by source-generated code to handle Lambda event /// processing using the specified . /// -public class DefaultEventFeatureProvider(ILambdaSerializer lambdaSerializer) : IFeatureProvider +internal class DefaultEventFeatureProvider(ILambdaSerializer lambdaSerializer) : IFeatureProvider { // ReSharper disable once StaticMemberInGenericType private static readonly Type FeatureType = typeof(IEventFeature); diff --git a/src/AwsLambda.Host/Core/Features/DefaultResponseFeatureProvider.cs b/src/AwsLambda.Host/Core/Features/DefaultResponseFeatureProvider.cs index 26e6ec73..25682d04 100644 --- a/src/AwsLambda.Host/Core/Features/DefaultResponseFeatureProvider.cs +++ b/src/AwsLambda.Host/Core/Features/DefaultResponseFeatureProvider.cs @@ -1,5 +1,9 @@ +#region + using Amazon.Lambda.Core; +#endregion + namespace AwsLambda.Host.Core; /// @@ -7,7 +11,7 @@ namespace AwsLambda.Host.Core; /// serialization. This provider is instantiated by source-generated code to handle Lambda response /// processing using the specified . /// -public class DefaultResponseFeatureProvider(ILambdaSerializer lambdaSerializer) +internal class DefaultResponseFeatureProvider(ILambdaSerializer lambdaSerializer) : IFeatureProvider { // ReSharper disable once StaticMemberInGenericType From 16c7e7864ab2583a5a6d2360df9076fcfd636962 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Tue, 2 Dec 2025 18:24:53 -0500 Subject: [PATCH 06/48] feat(core): extend `IFeatureCollectionFactory` with overload for custom providers - Added a new `Create` method overload accepting `IEnumerable`. - Enables combining default and custom feature providers when creating `DefaultFeatureCollection`. --- .../Core/Features/DefaultFeatureCollectionFactory.cs | 3 +++ src/AwsLambda.Host/Core/Features/IFeatureCollectionFactory.cs | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/AwsLambda.Host/Core/Features/DefaultFeatureCollectionFactory.cs b/src/AwsLambda.Host/Core/Features/DefaultFeatureCollectionFactory.cs index b7c80584..4de16c4c 100644 --- a/src/AwsLambda.Host/Core/Features/DefaultFeatureCollectionFactory.cs +++ b/src/AwsLambda.Host/Core/Features/DefaultFeatureCollectionFactory.cs @@ -8,4 +8,7 @@ public DefaultFeatureCollectionFactory(IEnumerable featurePro _featureProviders = featureProviders.Where(x => x is not null).Select(x => x!).ToArray(); public IFeatureCollection Create() => new DefaultFeatureCollection(_featureProviders); + + public IFeatureCollection Create(IEnumerable featureProviders) => + new DefaultFeatureCollection(_featureProviders.Concat(featureProviders)); } diff --git a/src/AwsLambda.Host/Core/Features/IFeatureCollectionFactory.cs b/src/AwsLambda.Host/Core/Features/IFeatureCollectionFactory.cs index 84497607..32592f55 100644 --- a/src/AwsLambda.Host/Core/Features/IFeatureCollectionFactory.cs +++ b/src/AwsLambda.Host/Core/Features/IFeatureCollectionFactory.cs @@ -3,4 +3,6 @@ namespace AwsLambda.Host.Core; internal interface IFeatureCollectionFactory { IFeatureCollection Create(); + + IFeatureCollection Create(IEnumerable featureProviders); } From f1cc52078d2d6f8acc8c6a919c3816b5ba16abee Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Tue, 2 Dec 2025 18:26:25 -0500 Subject: [PATCH 07/48] refactor(core): convert concatenated feature providers to array in factory method - Updated `DefaultFeature in` `IFeatureCollectionFactory.Create` to use `.ToArray()` after concatenation. - Ensures compatibility with collections requiring fixed-size arrays from concatenation outputs. --- .../Core/Features/DefaultFeatureCollectionFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AwsLambda.Host/Core/Features/DefaultFeatureCollectionFactory.cs b/src/AwsLambda.Host/Core/Features/DefaultFeatureCollectionFactory.cs index 4de16c4c..e172c55f 100644 --- a/src/AwsLambda.Host/Core/Features/DefaultFeatureCollectionFactory.cs +++ b/src/AwsLambda.Host/Core/Features/DefaultFeatureCollectionFactory.cs @@ -10,5 +10,5 @@ public DefaultFeatureCollectionFactory(IEnumerable featurePro public IFeatureCollection Create() => new DefaultFeatureCollection(_featureProviders); public IFeatureCollection Create(IEnumerable featureProviders) => - new DefaultFeatureCollection(_featureProviders.Concat(featureProviders)); + new DefaultFeatureCollection(_featureProviders.Concat(featureProviders).ToArray()); } From 4b80f3bbec6a1237269a027d5301e4a33617b357 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Tue, 2 Dec 2025 18:32:07 -0500 Subject: [PATCH 08/48] feat(core): support custom feature providers in LambdaHostContextFactory - Added `_featureProviders` field to store custom feature providers. - Resolved `FeatureProvidersKey` from properties to populate `_featureProviders`. - Updated `DefaultLambdaHostContext` creation to pass `_featureProviders` to `Create` method. --- .../Core/Context/LambdaHostContextFactory.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/AwsLambda.Host/Core/Context/LambdaHostContextFactory.cs b/src/AwsLambda.Host/Core/Context/LambdaHostContextFactory.cs index 9448b21b..1c1ff7d8 100644 --- a/src/AwsLambda.Host/Core/Context/LambdaHostContextFactory.cs +++ b/src/AwsLambda.Host/Core/Context/LambdaHostContextFactory.cs @@ -1,6 +1,10 @@ +#region + using Amazon.Lambda.Core; using Microsoft.Extensions.DependencyInjection; +#endregion + namespace AwsLambda.Host.Core; internal class LambdaHostContextFactory : ILambdaHostContextFactory @@ -8,6 +12,7 @@ internal class LambdaHostContextFactory : ILambdaHostContextFactory private readonly ILambdaHostContextAccessor? _contextAccessor; private readonly IFeatureCollectionFactory _featureCollectionFactory; private readonly IServiceScopeFactory _serviceScopeFactory; + private IEnumerable? _featureProviders; public LambdaHostContextFactory( IServiceScopeFactory serviceScopeFactory, @@ -29,11 +34,17 @@ public ILambdaHostContext Create( CancellationToken cancellationToken ) { + _featureProviders ??= + properties.TryGetValue(LambdaInvocationBuilder.FeatureProvidersKey, out var value) + && value is IEnumerable providers + ? providers + : []; + var context = new DefaultLambdaHostContext( lambdaContext, _serviceScopeFactory, properties, - _featureCollectionFactory.Create(), + _featureCollectionFactory.Create(_featureProviders), cancellationToken ); From 16d118e73d4ef89e054e1957cde3783817f03ed0 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Tue, 2 Dec 2025 18:32:24 -0500 Subject: [PATCH 09/48] refactor(core): remove unused `Create` method from `DefaultFeatureCollectionFactory` - Deleted `IFeatureCollectionFactory.Create()` method that accepts no parameters. - Simplified `DefaultFeatureCollectionFactory` by removing unused functionality. --- .../Core/Features/DefaultFeatureCollectionFactory.cs | 2 -- src/AwsLambda.Host/Core/Features/IFeatureCollectionFactory.cs | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/AwsLambda.Host/Core/Features/DefaultFeatureCollectionFactory.cs b/src/AwsLambda.Host/Core/Features/DefaultFeatureCollectionFactory.cs index e172c55f..b3507f57 100644 --- a/src/AwsLambda.Host/Core/Features/DefaultFeatureCollectionFactory.cs +++ b/src/AwsLambda.Host/Core/Features/DefaultFeatureCollectionFactory.cs @@ -7,8 +7,6 @@ internal class DefaultFeatureCollectionFactory : IFeatureCollectionFactory public DefaultFeatureCollectionFactory(IEnumerable featureProviders) => _featureProviders = featureProviders.Where(x => x is not null).Select(x => x!).ToArray(); - public IFeatureCollection Create() => new DefaultFeatureCollection(_featureProviders); - public IFeatureCollection Create(IEnumerable featureProviders) => new DefaultFeatureCollection(_featureProviders.Concat(featureProviders).ToArray()); } diff --git a/src/AwsLambda.Host/Core/Features/IFeatureCollectionFactory.cs b/src/AwsLambda.Host/Core/Features/IFeatureCollectionFactory.cs index 32592f55..d2db74ba 100644 --- a/src/AwsLambda.Host/Core/Features/IFeatureCollectionFactory.cs +++ b/src/AwsLambda.Host/Core/Features/IFeatureCollectionFactory.cs @@ -2,7 +2,5 @@ namespace AwsLambda.Host.Core; internal interface IFeatureCollectionFactory { - IFeatureCollection Create(); - IFeatureCollection Create(IEnumerable featureProviders); } From fb20c626c92f3fcaa3c9f37ea61e5e6b9cffeeeb Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Tue, 2 Dec 2025 18:34:54 -0500 Subject: [PATCH 10/48] refactor(core): simplify `DefaultFeatureCollectionFactory` constructor - Replaced internal field initialization with constructor parameter assignment. - Removed null-checking and filtering logic as it's no longer necessary. - Updated `Create` method to use the constructor-initialized `providers`. --- .../Core/Features/DefaultFeatureCollectionFactory.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/AwsLambda.Host/Core/Features/DefaultFeatureCollectionFactory.cs b/src/AwsLambda.Host/Core/Features/DefaultFeatureCollectionFactory.cs index b3507f57..ec634ac7 100644 --- a/src/AwsLambda.Host/Core/Features/DefaultFeatureCollectionFactory.cs +++ b/src/AwsLambda.Host/Core/Features/DefaultFeatureCollectionFactory.cs @@ -1,12 +1,8 @@ namespace AwsLambda.Host.Core; -internal class DefaultFeatureCollectionFactory : IFeatureCollectionFactory +internal class DefaultFeatureCollectionFactory(IEnumerable providers) + : IFeatureCollectionFactory { - private readonly IEnumerable _featureProviders; - - public DefaultFeatureCollectionFactory(IEnumerable featureProviders) => - _featureProviders = featureProviders.Where(x => x is not null).Select(x => x!).ToArray(); - public IFeatureCollection Create(IEnumerable featureProviders) => - new DefaultFeatureCollection(_featureProviders.Concat(featureProviders).ToArray()); + new DefaultFeatureCollection(providers.Concat(featureProviders).ToArray()); } From 850d453314ea5d9ee98c6c1ce6f5eea4a683c758 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Tue, 2 Dec 2025 19:59:48 -0500 Subject: [PATCH 11/48] feat(core): enable feature providers in `MapHandlerLambdaApplicationExtensions` - Introduced `FeatureProvidersKey` constant to store feature providers in application properties. - Added logic to resolve and assign event and response feature providers to the application. - Removed redundant `BuildInterceptor` method and associated feature provider registrations. --- .../Templates/MapHandler.scriban | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/AwsLambda.Host.SourceGenerators/Templates/MapHandler.scriban b/src/AwsLambda.Host.SourceGenerators/Templates/MapHandler.scriban index 66857a42..43cf2694 100644 --- a/src/AwsLambda.Host.SourceGenerators/Templates/MapHandler.scriban +++ b/src/AwsLambda.Host.SourceGenerators/Templates/MapHandler.scriban @@ -13,6 +13,8 @@ namespace AwsLambda.Host.Core.Generated {{ generated_code_attribute }} file static class MapHandlerLambdaApplicationExtensions { + private const string FeatureProvidersKey = "__FeatureProviders"; + // Location: {{ location.display_location }} [InterceptsLocation({{ location.version }}, "{{ location.data }}")] internal static ILambdaInvocationBuilder MapHandlerInterceptor( @@ -22,6 +24,18 @@ namespace AwsLambda.Host.Core.Generated { var castHandler = ({{ handler_signature }})handler; + {{~ if (input_event != null && !input_event.is_stream) || (output_response != null && !output_response.response_is_stream) ~}} + application.Properties[FeatureProvidersKey] = new IFeatureProvider[] + { + {{~ if input_event != null && !input_event.is_stream ~}} + application.Services.GetRequiredService().Create<{{ input_event.type }}>(), + {{~ end ~}} + {{~ if output_response != null && !output_response.response_is_stream ~}} + application.Services.GetRequiredService().Create<{{ output_response.response_type }}>(), + {{~ end ~}} + }; + + {{~ end ~}} return application.Handle(InvocationDelegate); {{ if should_await ~}} async {{ end ~}}Task InvocationDelegate(ILambdaHostContext context) @@ -53,21 +67,5 @@ namespace AwsLambda.Host.Core.Generated {{~ end ~}} } } - {{~ if builders.size >= 1 ~}} - - {{~ for builder in builders ~}} - [InterceptsLocation({{ builder.version }}, "{{ builder.data }}")] // Location: {{ builder.display_location }} - {{~ end ~}} - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - {{~ if input_event != null && !input_event.is_stream ~}} - builder.Services.AddSingleton>(); - {{~ end ~}} - {{~ if output_response != null && !output_response.response_is_stream ~}} - builder.Services.AddSingleton>(); - {{~ end ~}} - return builder.Build(); - } - {{~ end ~}} } } From a377f9a479cc62015881d092e519dd7e9cea4af4 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Tue, 2 Dec 2025 20:13:00 -0500 Subject: [PATCH 12/48] feat(source-generators): extend `MapHandler` template for multiple feature providers - Added logic to merge existing feature providers with new ones in `application.Properties`. - Updated imports to include `System.Collections.Generic` and `System.Linq`. --- .../Templates/MapHandler.scriban | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/AwsLambda.Host.SourceGenerators/Templates/MapHandler.scriban b/src/AwsLambda.Host.SourceGenerators/Templates/MapHandler.scriban index 43cf2694..fdd3b696 100644 --- a/src/AwsLambda.Host.SourceGenerators/Templates/MapHandler.scriban +++ b/src/AwsLambda.Host.SourceGenerators/Templates/MapHandler.scriban @@ -2,7 +2,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -25,7 +27,7 @@ namespace AwsLambda.Host.Core.Generated var castHandler = ({{ handler_signature }})handler; {{~ if (input_event != null && !input_event.is_stream) || (output_response != null && !output_response.response_is_stream) ~}} - application.Properties[FeatureProvidersKey] = new IFeatureProvider[] + var providersToAdd = new IFeatureProvider[] { {{~ if input_event != null && !input_event.is_stream ~}} application.Services.GetRequiredService().Create<{{ input_event.type }}>(), @@ -35,6 +37,12 @@ namespace AwsLambda.Host.Core.Generated {{~ end ~}} }; + application.Properties[FeatureProvidersKey] = + application.Properties.TryGetValue(FeatureProvidersKey, out var existing) + && existing is IEnumerable existingProviders + ? existingProviders.Concat(providersToAdd).ToArray() + : providersToAdd; + {{~ end ~}} return application.Handle(InvocationDelegate); From e71f2832adaa652c43eaff03cdbd2267d6cf2df4 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Tue, 2 Dec 2025 20:18:44 -0500 Subject: [PATCH 13/48] refactor(diagnostics): remove `LH0001` rule for duplicate `MapHandler` invocations - Deleted `MultipleMethodCalls` diagnostic descriptor (`LH0001`) and its related validation logic. - Removed associated entry from `AnalyzerReleases.Unshipped.md`. - Updated `AnalyzerReleases.Shipped.md` with a comment for the released diagnostics tracking. --- .../AnalyzerReleases.Shipped.md | 2 ++ .../AnalyzerReleases.Unshipped.md | 4 ++++ .../Diagnostics/DiagnosticGenerator.cs | 12 ------------ .../Diagnostics/Diagnostics.cs | 9 --------- 4 files changed, 6 insertions(+), 21 deletions(-) diff --git a/src/AwsLambda.Host.SourceGenerators/AnalyzerReleases.Shipped.md b/src/AwsLambda.Host.SourceGenerators/AnalyzerReleases.Shipped.md index 2da807aa..a2000cf2 100644 --- a/src/AwsLambda.Host.SourceGenerators/AnalyzerReleases.Shipped.md +++ b/src/AwsLambda.Host.SourceGenerators/AnalyzerReleases.Shipped.md @@ -1,3 +1,5 @@ +[//]: # (https://github.com/dotnet/roslyn/blob/main/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md) + ## Release 1.0.0 ### New Rules diff --git a/src/AwsLambda.Host.SourceGenerators/AnalyzerReleases.Unshipped.md b/src/AwsLambda.Host.SourceGenerators/AnalyzerReleases.Unshipped.md index 8b137891..a4c46e3b 100644 --- a/src/AwsLambda.Host.SourceGenerators/AnalyzerReleases.Unshipped.md +++ b/src/AwsLambda.Host.SourceGenerators/AnalyzerReleases.Unshipped.md @@ -1 +1,5 @@ +### Removed Rules + Rule ID | Category | Severity | Notes +---------|------------------------------|----------|----------------------------------- + LH0001 | AwsLambda.Host.Usage | Error | Multiple method calls detected \ No newline at end of file diff --git a/src/AwsLambda.Host.SourceGenerators/Diagnostics/DiagnosticGenerator.cs b/src/AwsLambda.Host.SourceGenerators/Diagnostics/DiagnosticGenerator.cs index d2c9d6bd..3af20531 100644 --- a/src/AwsLambda.Host.SourceGenerators/Diagnostics/DiagnosticGenerator.cs +++ b/src/AwsLambda.Host.SourceGenerators/Diagnostics/DiagnosticGenerator.cs @@ -14,18 +14,6 @@ internal static List GenerateDiagnostics(CompilationInfo compilation var delegateInfos = compilationInfo.MapHandlerInvocationInfos; - // check for multiple invocations of MapHandler - if (delegateInfos.Count > 1) - diagnostics.AddRange( - delegateInfos.Select(invocationInfo => - Diagnostic.Create( - Diagnostics.MultipleMethodCalls, - invocationInfo.LocationInfo?.ToLocation(), - "LambdaApplication.MapHandler(Delegate)" - ) - ) - ); - // Validate parameters foreach (var invocationInfo in delegateInfos) // check for multiple parameters that use the `[Event]` attribute diff --git a/src/AwsLambda.Host.SourceGenerators/Diagnostics/Diagnostics.cs b/src/AwsLambda.Host.SourceGenerators/Diagnostics/Diagnostics.cs index 57e7a965..09a11819 100644 --- a/src/AwsLambda.Host.SourceGenerators/Diagnostics/Diagnostics.cs +++ b/src/AwsLambda.Host.SourceGenerators/Diagnostics/Diagnostics.cs @@ -7,15 +7,6 @@ internal static class Diagnostics private const string UsageCategory = "AwsLambda.Host.Usage"; private const string ConfigurationCategory = "AwsLambda.Host.Configuration"; - internal static readonly DiagnosticDescriptor MultipleMethodCalls = new( - "LH0001", - "Multiple method calls detected", - "Method '{0}' can only be invoked once per project. Remove this duplicate invocation.", - UsageCategory, - DiagnosticSeverity.Error, - true - ); - internal static readonly DiagnosticDescriptor MultipleParametersUseAttribute = new( "LH0002", "Multiple parameters use attribute", From 9d2bdc28cec5f065e0f7a2f462a37cb62cd2623a Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Tue, 2 Dec 2025 20:19:16 -0500 Subject: [PATCH 14/48] refactor(source-generators): simplify `Predicate` logic in `MapHandlerSyntaxProvider` - Removed unnecessary "Handle" argument from `HandlerInfoExtractor.Predicate` invocation. --- .../SyntaxProviders/MapHandlerSyntaxProvider.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/AwsLambda.Host.SourceGenerators/SyntaxProviders/MapHandlerSyntaxProvider.cs b/src/AwsLambda.Host.SourceGenerators/SyntaxProviders/MapHandlerSyntaxProvider.cs index a5386326..ccedb6a5 100644 --- a/src/AwsLambda.Host.SourceGenerators/SyntaxProviders/MapHandlerSyntaxProvider.cs +++ b/src/AwsLambda.Host.SourceGenerators/SyntaxProviders/MapHandlerSyntaxProvider.cs @@ -1,13 +1,17 @@ +#region + using System.Threading; using AwsLambda.Host.SourceGenerators.Models; using Microsoft.CodeAnalysis; +#endregion + namespace AwsLambda.Host.SourceGenerators; internal static class MapHandlerSyntaxProvider { internal static bool Predicate(SyntaxNode node, CancellationToken cancellationToken) => - HandlerInfoExtractor.Predicate(node, GeneratorConstants.MapHandlerMethodName, "Handle"); + HandlerInfoExtractor.Predicate(node, GeneratorConstants.MapHandlerMethodName); internal static HigherOrderMethodInfo? Transformer( GeneratorSyntaxContext context, From aef4ea5dbedcb92bf41b65474bcd0c829e74012d Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 10:08:24 -0500 Subject: [PATCH 15/48] docs(source-generators): add README and update release tracking - Added `README.md` for `AwsLambda.Host.SourceGenerators` with notes about release tracking files. - Updated `AnalyzerReleases.Shipped.md` to remove unnecessary comment. --- .../AnalyzerReleases.Shipped.md | 4 +--- src/AwsLambda.Host.SourceGenerators/README.md | 7 +++++++ 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 src/AwsLambda.Host.SourceGenerators/README.md diff --git a/src/AwsLambda.Host.SourceGenerators/AnalyzerReleases.Shipped.md b/src/AwsLambda.Host.SourceGenerators/AnalyzerReleases.Shipped.md index a2000cf2..53047bfd 100644 --- a/src/AwsLambda.Host.SourceGenerators/AnalyzerReleases.Shipped.md +++ b/src/AwsLambda.Host.SourceGenerators/AnalyzerReleases.Shipped.md @@ -1,5 +1,3 @@ -[//]: # (https://github.com/dotnet/roslyn/blob/main/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md) - ## Release 1.0.0 ### New Rules @@ -9,4 +7,4 @@ LH0001 | AwsLambda.Host.Usage | Error | Multiple method calls detected LH0002 | AwsLambda.Host.Usage | Error | Multiple parameters use attribute LH0003 | AwsLambda.Host.Usage | Error | Invalid attribute argument - LH0004 | AwsLambda.Host.Configuration | Error | C# language version too low \ No newline at end of file + LH0004 | AwsLambda.Host.Configuration | Error | C# language version too low diff --git a/src/AwsLambda.Host.SourceGenerators/README.md b/src/AwsLambda.Host.SourceGenerators/README.md new file mode 100644 index 00000000..94287259 --- /dev/null +++ b/src/AwsLambda.Host.SourceGenerators/README.md @@ -0,0 +1,7 @@ +# AwsLambda.Host.SourceGenerators + +## Notes + +### `AnalyzerReleases.Shipped` and` AnalyzerReleases.Unshipped` + +https://github.com/dotnet/roslyn/blob/main/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md From 9613186f52aec7880ccb2ed603aaf01ac57f688c Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 10:08:35 -0500 Subject: [PATCH 16/48] feat(opentelemetry): add OpenTelemetry tracing middleware for AwsLambda - Introduced new `UseOpenTelemetryTracing` extension to enable tracing for Lambda events. - Added dependency on `OpenTelemetry.Instrumentation.AWSLambda` and updated service resolution logic. - Deprecated old `UseOpenTelemetryTracing` method, renamed to `UseOpenTelemetryTracing_old`. --- .../MiddlewareOpenTelemetryExtensions.cs | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/AwsLambda.Host.OpenTelemetry/MiddlewareOpenTelemetryExtensions.cs b/src/AwsLambda.Host.OpenTelemetry/MiddlewareOpenTelemetryExtensions.cs index 9d1ded2e..ffd32e5b 100644 --- a/src/AwsLambda.Host.OpenTelemetry/MiddlewareOpenTelemetryExtensions.cs +++ b/src/AwsLambda.Host.OpenTelemetry/MiddlewareOpenTelemetryExtensions.cs @@ -1,7 +1,14 @@ +#region + using System.Diagnostics; using System.Diagnostics.CodeAnalysis; +using AwsLambda.Host.Core; +using Microsoft.Extensions.DependencyInjection; +using OpenTelemetry.Instrumentation.AWSLambda; using OpenTelemetry.Trace; +#endregion + namespace AwsLambda.Host.Builder; /// @@ -80,11 +87,38 @@ public static class MiddlewareOpenTelemetryExtensions /// record Response(string Message); /// /// - public static ILambdaInvocationBuilder UseOpenTelemetryTracing( + public static ILambdaInvocationBuilder UseOpenTelemetryTracing_old( this ILambdaInvocationBuilder application ) { Debug.Fail("This method should have been intercepted at compile time!"); throw new InvalidOperationException("This method is replaced at compile time."); } + + extension(ILambdaInvocationBuilder builder) + { + public ILambdaInvocationBuilder UseOpenTelemetryTracing() + { + ArgumentNullException.ThrowIfNull(builder); + + var tracerProvider = builder.Services.GetRequiredService(); + + return builder.Use(next => + async context => + { + await AWSLambdaWrapper.TraceAsync( + tracerProvider, + async Task (_, _) => + { + await next(context); + + return context.Features.Get()?.GetResponse(); + }, + context.Features.Get()?.GetEvent(context), + context + ); + } + ); + } + } } From b5c899ff8f67cc411158564e05acd67a57fec795 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 10:08:46 -0500 Subject: [PATCH 17/48] feat(source-generators): support multiple MapHandler invocations - Refactored `MapHandlerSources.Generate` to allow multiple `MapHandler` calls with distinct signatures. - Updated template logic to iterate through multiple handler calls and generate interceptors. - Simplified `BuildHandlerParameterAssignment` by converting to an expression-bodied method. - Removed unused `MapHandlerInvocationInfo` filtering logic in `LambdaHostOutputGenerator`. - Disabled OpenTelemetry tracing generation due to incompatible mapping logic. --- .../LambdaHostOutputGenerator.cs | 41 ++++---- .../OutputGenerators/MapHandlerSources.cs | 93 ++++++++++--------- .../Templates/MapHandler.scriban | 42 +++++---- 3 files changed, 92 insertions(+), 84 deletions(-) diff --git a/src/AwsLambda.Host.SourceGenerators/OutputGenerators/LambdaHostOutputGenerator.cs b/src/AwsLambda.Host.SourceGenerators/OutputGenerators/LambdaHostOutputGenerator.cs index 0aadd8bb..925b11d4 100644 --- a/src/AwsLambda.Host.SourceGenerators/OutputGenerators/LambdaHostOutputGenerator.cs +++ b/src/AwsLambda.Host.SourceGenerators/OutputGenerators/LambdaHostOutputGenerator.cs @@ -1,8 +1,12 @@ +#region + using System.Collections.Generic; using System.Linq; using AwsLambda.Host.SourceGenerators.Models; using Microsoft.CodeAnalysis; +#endregion + namespace AwsLambda.Host.SourceGenerators; internal static class LambdaHostOutputGenerator @@ -30,28 +34,23 @@ string generatorVersion // if MapHandler calls found, generate the source code. Will always be 0 or 1 at this point. // Anything that needs to know types from the handler must be generated here. - if (compilationInfo.MapHandlerInvocationInfos.Count(x => x.Name != "Handle") == 1) - { - var mapHandlerInvocationInfo = compilationInfo.MapHandlerInvocationInfos.First(); + outputs.Add( + MapHandlerSources.Generate( + compilationInfo.MapHandlerInvocationInfos, + compilationInfo.BuilderInfos, + generatedCodeAttribute + ) + ); - outputs.Add( - MapHandlerSources.Generate( - mapHandlerInvocationInfo, - compilationInfo.BuilderInfos, - generatedCodeAttribute - ) - ); - - // if UseOpenTelemetryTracing calls found, generate the source code. - if (compilationInfo.UseOpenTelemetryTracingInfos.Count >= 1) - outputs.Add( - OpenTelemetrySources.Generate( - compilationInfo.UseOpenTelemetryTracingInfos, - mapHandlerInvocationInfo.DelegateInfo, - generatedCodeAttribute - ) - ); - } + // // if UseOpenTelemetryTracing calls found, generate the source code. + // if (compilationInfo.UseOpenTelemetryTracingInfos.Count >= 1) + // outputs.Add( + // OpenTelemetrySources.Generate( + // compilationInfo.UseOpenTelemetryTracingInfos, + // mapHandlerInvocationInfo.DelegateInfo, + // generatedCodeAttribute + // ) + // ); // add OnShutdown interceptors if (compilationInfo.OnShutdownInvocationInfos.Count >= 1) diff --git a/src/AwsLambda.Host.SourceGenerators/OutputGenerators/MapHandlerSources.cs b/src/AwsLambda.Host.SourceGenerators/OutputGenerators/MapHandlerSources.cs index 2288bd66..03d51b3f 100644 --- a/src/AwsLambda.Host.SourceGenerators/OutputGenerators/MapHandlerSources.cs +++ b/src/AwsLambda.Host.SourceGenerators/OutputGenerators/MapHandlerSources.cs @@ -1,70 +1,78 @@ +#region + using System.Linq; using AwsLambda.Host.SourceGenerators.Extensions; using AwsLambda.Host.SourceGenerators.Models; using AwsLambda.Host.SourceGenerators.Types; +#endregion + namespace AwsLambda.Host.SourceGenerators; internal static class MapHandlerSources { internal static string Generate( - HigherOrderMethodInfo higherOrderMethodInfo, + EquatableArray mapHandlerInvocationInfos, EquatableArray builderInfo, string generatedCodeAttribute ) { - var delegateInfo = higherOrderMethodInfo.DelegateInfo; + var mapHandlerCalls = mapHandlerInvocationInfos.Select(mapHandlerInvocationInfo => + { + var delegateInfo = mapHandlerInvocationInfo.DelegateInfo; - // build handler function signature - var handlerSignature = delegateInfo.BuildHandlerSignature(); + // build handler function signature + var handlerSignature = delegateInfo.BuildHandlerSignature(); - // build out assignment statements for each handler parameter - var handlerArgs = delegateInfo.BuildHandlerParameterAssignment(); + // build out assignment statements for each handler parameter + var handlerArgs = delegateInfo.BuildHandlerParameterAssignment(); - // get input event type - var inputEvent = delegateInfo.EventParameter is { } p - ? new - { - IsStream = p.TypeInfo.FullyQualifiedType == TypeConstants.Stream, - Type = p.TypeInfo.FullyQualifiedType, - } - : null; + // get input event type + var inputEvent = delegateInfo.EventParameter is { } p + ? new + { + IsStream = p.TypeInfo.FullyQualifiedType == TypeConstants.Stream, + Type = p.TypeInfo.FullyQualifiedType, + } + : null; + + // get output response type and whether it is a stream + var outputResponse = delegateInfo.HasResponse + ? new + { + ResponseType = delegateInfo.ReturnTypeInfo.UnwrappedFullyQualifiedType, + ResponseIsStream = delegateInfo.ReturnTypeInfo.UnwrappedFullyQualifiedType + == TypeConstants.Stream, + } + : null; - // get output response type and whether it is a stream - var outputResponse = delegateInfo.HasResponse - ? new + return new { - ResponseType = delegateInfo.ReturnTypeInfo.UnwrappedFullyQualifiedType, - ResponseIsStream = delegateInfo.ReturnTypeInfo.UnwrappedFullyQualifiedType - == TypeConstants.Stream, - } - : null; - - var builderCalls = builderInfo.Select(b => b.InterceptableLocationInfo).ToArray(); - - var model = new - { - Location = higherOrderMethodInfo.InterceptableLocationInfo, - HandlerSignature = handlerSignature, - delegateInfo.HasAnyKeyedServiceParameter, - HandlerArgs = handlerArgs, - ShouldAwait = delegateInfo.IsAwaitable, - InputEvent = inputEvent, - OutputResponse = outputResponse, - Builders = builderCalls, - GeneratedCodeAttribute = generatedCodeAttribute, - }; + Location = mapHandlerInvocationInfo.InterceptableLocationInfo, + HandlerSignature = handlerSignature, + delegateInfo.HasAnyKeyedServiceParameter, + HandlerArgs = handlerArgs, + ShouldAwait = delegateInfo.IsAwaitable, + InputEvent = inputEvent, + OutputResponse = outputResponse, + }; + }); var template = TemplateHelper.LoadTemplate( GeneratorConstants.LambdaHostMapHandlerExtensionsTemplateFile ); - return template.Render(model); + return template.Render( + new + { + GeneratedCodeAttribute = generatedCodeAttribute, + MapHandlerCalls = mapHandlerCalls, + } + ); } - private static HandlerArg[] BuildHandlerParameterAssignment(this DelegateInfo delegateInfo) - { - var handlerArgs = delegateInfo + private static HandlerArg[] BuildHandlerParameterAssignment(this DelegateInfo delegateInfo) => + delegateInfo .Parameters.Select(param => new HandlerArg { String = param.ToPublicString(), @@ -103,8 +111,5 @@ private static HandlerArg[] BuildHandlerParameterAssignment(this DelegateInfo de }) .ToArray(); - return handlerArgs; - } - private readonly record struct HandlerArg(string String, string Assignment); } diff --git a/src/AwsLambda.Host.SourceGenerators/Templates/MapHandler.scriban b/src/AwsLambda.Host.SourceGenerators/Templates/MapHandler.scriban index fdd3b696..5251427c 100644 --- a/src/AwsLambda.Host.SourceGenerators/Templates/MapHandler.scriban +++ b/src/AwsLambda.Host.SourceGenerators/Templates/MapHandler.scriban @@ -17,23 +17,26 @@ namespace AwsLambda.Host.Core.Generated { private const string FeatureProvidersKey = "__FeatureProviders"; - // Location: {{ location.display_location }} - [InterceptsLocation({{ location.version }}, "{{ location.data }}")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + {{~ for call in map_handler_calls ~}} + // Location: {{ call.location.display_location }} + [InterceptsLocation({{ call.location.version }}, "{{ call.location.data }}")] + internal static ILambdaInvocationBuilder MapHandlerInterceptor{{ for.index }}( this ILambdaInvocationBuilder application, Delegate handler ) { - var castHandler = ({{ handler_signature }})handler; + var castHandler = ({{ call.handler_signature }})handler; + + application.Handle(InvocationDelegate); - {{~ if (input_event != null && !input_event.is_stream) || (output_response != null && !output_response.response_is_stream) ~}} + {{~ if (call.input_event != null && !call.input_event.is_stream) || (call.output_response != null && !call.output_response.response_is_stream) ~}} var providersToAdd = new IFeatureProvider[] { - {{~ if input_event != null && !input_event.is_stream ~}} - application.Services.GetRequiredService().Create<{{ input_event.type }}>(), + {{~ if call.input_event != null && !call.input_event.is_stream ~}} + application.Services.GetRequiredService().Create<{{ call.input_event.type }}>(), {{~ end ~}} - {{~ if output_response != null && !output_response.response_is_stream ~}} - application.Services.GetRequiredService().Create<{{ output_response.response_type }}>(), + {{~ if call.output_response != null && !call.output_response.response_is_stream ~}} + application.Services.GetRequiredService().Create<{{ call.output_response.response_type }}>(), {{~ end ~}} }; @@ -44,36 +47,37 @@ namespace AwsLambda.Host.Core.Generated : providersToAdd; {{~ end ~}} - return application.Handle(InvocationDelegate); + return application; - {{ if should_await ~}} async {{ end ~}}Task InvocationDelegate(ILambdaHostContext context) + {{ if call.should_await ~}} async {{ end ~}}Task InvocationDelegate(ILambdaHostContext context) { - {{~ if has_any_keyed_service_parameter ~}} + {{~ if call.has_any_keyed_service_parameter ~}} if (context.ServiceProvider.GetService() is not IServiceProviderIsKeyedService) { throw new InvalidOperationException($"Unable to resolve service referenced by {nameof(FromKeyedServicesAttribute)}. The service provider doesn't support keyed services."); } {{~ end ~}} - {{~ for handler_arg in handler_args ~}} + {{~ for handler_arg in call.handler_args ~}} // {{ handler_arg.string }} var arg{{ for.index }} = {{ handler_arg.assignment }}; {{~ end ~}} - {{ if output_response != null; ~}} var response = {{ end }}{{ if should_await ~}} await {{ end ~}} castHandler.Invoke({{ for arg in handler_args }}arg{{ for.index }}{{ if !for.last }}, {{ end }}{{ end }}); - {{~ if output_response != null; ~}} - {{~ if output_response.response_is_stream ~}} + {{ if call.output_response != null; ~}} var response = {{ end }}{{ if call.should_await ~}} await {{ end ~}} castHandler.Invoke({{ for arg in call.handler_args }}arg{{ for.index }}{{ if !for.last }}, {{ end }}{{ end }}); + {{~ if call.output_response != null; ~}} + {{~ if call.output_response.response_is_stream ~}} context.Features.GetRequired().ResponseStream = response; {{~ else ~}} - if (context.Features.Get() is not IResponseFeature<{{ output_response.response_type }}> responseFeature) + if (context.Features.Get() is not IResponseFeature<{{ call.output_response.response_type }}> responseFeature) { - throw new InvalidOperationException($"Response feature for type '{{ output_response.response_type }}' is not available in the collection."); + throw new InvalidOperationException($"Response feature for type '{{ call.output_response.response_type }}' is not available in the collection."); } responseFeature.SetResponse(response); {{~ end ~}} {{~ end ~}} - {{~ if !should_await ~}} + {{~ if !call.should_await ~}} return Task.CompletedTask; {{~ end ~}} } } + {{~ end ~}} } } From 1c4791eea27cebb5813b52d99838e946fc787af4 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 10:14:16 -0500 Subject: [PATCH 18/48] fix(source-generators): handle diagnostics with errors before code generation - Added a check to skip source generation if any diagnostic has `DiagnosticSeverity.Error`. - Modified `MapHandlerSources.Generate` logic to ensure source is only generated when handlers exist. --- .../LambdaHostOutputGenerator.cs | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/AwsLambda.Host.SourceGenerators/OutputGenerators/LambdaHostOutputGenerator.cs b/src/AwsLambda.Host.SourceGenerators/OutputGenerators/LambdaHostOutputGenerator.cs index 925b11d4..cc0bcb2d 100644 --- a/src/AwsLambda.Host.SourceGenerators/OutputGenerators/LambdaHostOutputGenerator.cs +++ b/src/AwsLambda.Host.SourceGenerators/OutputGenerators/LambdaHostOutputGenerator.cs @@ -23,7 +23,10 @@ string generatorVersion if (diagnostics.Any()) { diagnostics.ForEach(context.ReportDiagnostic); - return; + + // if there are any errors, return without generating any source code. + if (diagnostics.Any(d => d.Severity == DiagnosticSeverity.Error)) + return; } // create GeneratedCodeAttribute. This is used across all generated source files. @@ -32,15 +35,15 @@ string generatorVersion List outputs = [CommonSources.Generate(generatedCodeAttribute)]; - // if MapHandler calls found, generate the source code. Will always be 0 or 1 at this point. - // Anything that needs to know types from the handler must be generated here. - outputs.Add( - MapHandlerSources.Generate( - compilationInfo.MapHandlerInvocationInfos, - compilationInfo.BuilderInfos, - generatedCodeAttribute - ) - ); + // if MapHandler calls found, generate the source code. + if (compilationInfo.MapHandlerInvocationInfos.Count >= 1) + outputs.Add( + MapHandlerSources.Generate( + compilationInfo.MapHandlerInvocationInfos, + compilationInfo.BuilderInfos, + generatedCodeAttribute + ) + ); // // if UseOpenTelemetryTracing calls found, generate the source code. // if (compilationInfo.UseOpenTelemetryTracingInfos.Count >= 1) From 279d30c606ab90071ba727cb5c0aa962a779dc44 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 10:31:36 -0500 Subject: [PATCH 19/48] feat(source-generators): add feature requirements for event and response handling - Introduced `IsEventFeatureRequired` and `IsResponseFeatureRequired` flags in `MapHandlerSources`. - Updated template logic to use the new flags for determining feature provider inclusion. --- .../OutputGenerators/MapHandlerSources.cs | 8 ++++++++ .../Templates/MapHandler.scriban | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/AwsLambda.Host.SourceGenerators/OutputGenerators/MapHandlerSources.cs b/src/AwsLambda.Host.SourceGenerators/OutputGenerators/MapHandlerSources.cs index 03d51b3f..b3aba49b 100644 --- a/src/AwsLambda.Host.SourceGenerators/OutputGenerators/MapHandlerSources.cs +++ b/src/AwsLambda.Host.SourceGenerators/OutputGenerators/MapHandlerSources.cs @@ -46,10 +46,18 @@ string generatedCodeAttribute } : null; + // determine if event feature is required + var isEventFeatureRequired = inputEvent is { IsStream: false }; + + // determine if response feature is required + var isResponseFeatureRequired = outputResponse is { ResponseIsStream: false }; + return new { Location = mapHandlerInvocationInfo.InterceptableLocationInfo, HandlerSignature = handlerSignature, + IsEventFeatureRequired = isEventFeatureRequired, + IsResponseFeatureRequired = isResponseFeatureRequired, delegateInfo.HasAnyKeyedServiceParameter, HandlerArgs = handlerArgs, ShouldAwait = delegateInfo.IsAwaitable, diff --git a/src/AwsLambda.Host.SourceGenerators/Templates/MapHandler.scriban b/src/AwsLambda.Host.SourceGenerators/Templates/MapHandler.scriban index 5251427c..837f62e2 100644 --- a/src/AwsLambda.Host.SourceGenerators/Templates/MapHandler.scriban +++ b/src/AwsLambda.Host.SourceGenerators/Templates/MapHandler.scriban @@ -29,13 +29,13 @@ namespace AwsLambda.Host.Core.Generated application.Handle(InvocationDelegate); - {{~ if (call.input_event != null && !call.input_event.is_stream) || (call.output_response != null && !call.output_response.response_is_stream) ~}} + {{~ if call.is_event_feature_required || call.is_response_feature_required ~}} var providersToAdd = new IFeatureProvider[] { - {{~ if call.input_event != null && !call.input_event.is_stream ~}} + {{~ if call.is_event_feature_required ~}} application.Services.GetRequiredService().Create<{{ call.input_event.type }}>(), {{~ end ~}} - {{~ if call.output_response != null && !call.output_response.response_is_stream ~}} + {{~ if call.is_response_feature_required ~}} application.Services.GetRequiredService().Create<{{ call.output_response.response_type }}>(), {{~ end ~}} }; From 08b8b88f062df35e9b94a7da173579af792ceab7 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 11:24:01 -0500 Subject: [PATCH 20/48] feat(source-generators): refine feature provider registration in MapHandler templates - Replaced `FeatureProvidersKey` with specific keys for event and response feature providers. - Updated template logic to add feature providers only when not already registered in properties. - Removed redundant merging logic for feature providers in the application properties. --- .../Templates/MapHandler.scriban | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/AwsLambda.Host.SourceGenerators/Templates/MapHandler.scriban b/src/AwsLambda.Host.SourceGenerators/Templates/MapHandler.scriban index 837f62e2..58c5435b 100644 --- a/src/AwsLambda.Host.SourceGenerators/Templates/MapHandler.scriban +++ b/src/AwsLambda.Host.SourceGenerators/Templates/MapHandler.scriban @@ -15,7 +15,8 @@ namespace AwsLambda.Host.Core.Generated {{ generated_code_attribute }} file static class MapHandlerLambdaApplicationExtensions { - private const string FeatureProvidersKey = "__FeatureProviders"; + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; {{~ for call in map_handler_calls ~}} // Location: {{ call.location.display_location }} @@ -28,25 +29,21 @@ namespace AwsLambda.Host.Core.Generated var castHandler = ({{ call.handler_signature }})handler; application.Handle(InvocationDelegate); - - {{~ if call.is_event_feature_required || call.is_response_feature_required ~}} - var providersToAdd = new IFeatureProvider[] - { - {{~ if call.is_event_feature_required ~}} - application.Services.GetRequiredService().Create<{{ call.input_event.type }}>(), - {{~ end ~}} - {{~ if call.is_response_feature_required ~}} - application.Services.GetRequiredService().Create<{{ call.output_response.response_type }}>(), - {{~ end ~}} - }; + {{~ if call.is_event_feature_required ~}} - application.Properties[FeatureProvidersKey] = - application.Properties.TryGetValue(FeatureProvidersKey, out var existing) - && existing is IEnumerable existingProviders - ? existingProviders.Concat(providersToAdd).ToArray() - : providersToAdd; + if (!application.Properties.ContainsKey(EventFeatureProviderKey)) + application.Properties[EventFeatureProviderKey] = application + .Services.GetRequiredService() + .Create<{{ call.input_event.type }}>(); + {{~ end ~}} + {{~ if call.is_response_feature_required ~}} + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create<{{ call.output_response.response_type }}>(); {{~ end ~}} + return application; {{ if call.should_await ~}} async {{ end ~}}Task InvocationDelegate(ILambdaHostContext context) From a287d210000ab2a34db84d4c497d4f6c707dc712 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 11:24:12 -0500 Subject: [PATCH 21/48] fix(opentelemetry): simplify `TraceAsync` usage in middleware - Removed unnecessary async lambda wrapping for `TraceAsync` method. - Updated `UseOpenTelemetryTracing` logic to improve readability and eliminate redundant code. --- .../MiddlewareOpenTelemetryExtensions.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/AwsLambda.Host.OpenTelemetry/MiddlewareOpenTelemetryExtensions.cs b/src/AwsLambda.Host.OpenTelemetry/MiddlewareOpenTelemetryExtensions.cs index ffd32e5b..1488948b 100644 --- a/src/AwsLambda.Host.OpenTelemetry/MiddlewareOpenTelemetryExtensions.cs +++ b/src/AwsLambda.Host.OpenTelemetry/MiddlewareOpenTelemetryExtensions.cs @@ -104,9 +104,8 @@ public ILambdaInvocationBuilder UseOpenTelemetryTracing() var tracerProvider = builder.Services.GetRequiredService(); return builder.Use(next => - async context => - { - await AWSLambdaWrapper.TraceAsync( + context => + AWSLambdaWrapper.TraceAsync( tracerProvider, async Task (_, _) => { @@ -116,8 +115,7 @@ await AWSLambdaWrapper.TraceAsync( }, context.Features.Get()?.GetEvent(context), context - ); - } + ) ); } } From 5070a26172ca2813e803514267c15c1da9196b20 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 11:24:25 -0500 Subject: [PATCH 22/48] feat(lambda-host): refactor feature provider initialization and improve flexibility - Added `CreateFeatureProviders` method for cleaner feature provider initialization logic. - Replaced `FeatureProvidersKey` with `EventFeatureProviderKey` and `ResponseFeatureProviderKey`. - Updated `LambdaHostContextFactory` to use arrays for feature providers instead of `IEnumerable`. - Simplified feature provider resolution using specific keys in `LambdaHostContextFactory`. --- .../Builder/LambdaInvocationBuilder.cs | 3 +- .../Core/Context/LambdaHostContextFactory.cs | 33 +++++++++++++++---- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/AwsLambda.Host/Builder/LambdaInvocationBuilder.cs b/src/AwsLambda.Host/Builder/LambdaInvocationBuilder.cs index bd46faa9..a413c149 100644 --- a/src/AwsLambda.Host/Builder/LambdaInvocationBuilder.cs +++ b/src/AwsLambda.Host/Builder/LambdaInvocationBuilder.cs @@ -2,7 +2,8 @@ namespace AwsLambda.Host.Builder; internal class LambdaInvocationBuilder : ILambdaInvocationBuilder { - internal const string FeatureProvidersKey = "__FeatureProviders"; + internal const string EventFeatureProviderKey = "__EventFeatureProvider"; + internal const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; private readonly List> _middleware = []; diff --git a/src/AwsLambda.Host/Core/Context/LambdaHostContextFactory.cs b/src/AwsLambda.Host/Core/Context/LambdaHostContextFactory.cs index 1c1ff7d8..77bdeef7 100644 --- a/src/AwsLambda.Host/Core/Context/LambdaHostContextFactory.cs +++ b/src/AwsLambda.Host/Core/Context/LambdaHostContextFactory.cs @@ -12,7 +12,7 @@ internal class LambdaHostContextFactory : ILambdaHostContextFactory private readonly ILambdaHostContextAccessor? _contextAccessor; private readonly IFeatureCollectionFactory _featureCollectionFactory; private readonly IServiceScopeFactory _serviceScopeFactory; - private IEnumerable? _featureProviders; + private IFeatureProvider[]? _featureProviders; public LambdaHostContextFactory( IServiceScopeFactory serviceScopeFactory, @@ -34,11 +34,7 @@ public ILambdaHostContext Create( CancellationToken cancellationToken ) { - _featureProviders ??= - properties.TryGetValue(LambdaInvocationBuilder.FeatureProvidersKey, out var value) - && value is IEnumerable providers - ? providers - : []; + _featureProviders ??= CreateFeatureProviders(properties); var context = new DefaultLambdaHostContext( lambdaContext, @@ -52,4 +48,29 @@ CancellationToken cancellationToken return context; } + + private static IFeatureProvider[] CreateFeatureProviders( + IDictionary properties + ) + { + var list = new List(2); + + if ( + properties.TryGetValue( + LambdaInvocationBuilder.EventFeatureProviderKey, + out var eventObj + ) && eventObj is IFeatureProvider eventFeatureProvider + ) + list.Add(eventFeatureProvider); + + if ( + properties.TryGetValue( + LambdaInvocationBuilder.ResponseFeatureProviderKey, + out var responseObj + ) && responseObj is IFeatureProvider responseFeatureProvider + ) + list.Add(responseFeatureProvider); + + return list.ToArray(); + } } From 3c00f9afd88bec628a946490d669acda62460fc8 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 11:31:05 -0500 Subject: [PATCH 23/48] refactor(lambda-host): simplify feature provider resolution in `LambdaHostContextFactory` - Extracted repeating logic for feature provider addition into `AddIfPresent` helper method. - Removed unnecessary `#region` and `#endregion` directives for a cleaner code structure. --- .../Core/Context/LambdaHostContextFactory.cs | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/AwsLambda.Host/Core/Context/LambdaHostContextFactory.cs b/src/AwsLambda.Host/Core/Context/LambdaHostContextFactory.cs index 77bdeef7..fa7977e3 100644 --- a/src/AwsLambda.Host/Core/Context/LambdaHostContextFactory.cs +++ b/src/AwsLambda.Host/Core/Context/LambdaHostContextFactory.cs @@ -1,10 +1,6 @@ -#region - using Amazon.Lambda.Core; using Microsoft.Extensions.DependencyInjection; -#endregion - namespace AwsLambda.Host.Core; internal class LambdaHostContextFactory : ILambdaHostContextFactory @@ -55,22 +51,19 @@ private static IFeatureProvider[] CreateFeatureProviders( { var list = new List(2); - if ( - properties.TryGetValue( - LambdaInvocationBuilder.EventFeatureProviderKey, - out var eventObj - ) && eventObj is IFeatureProvider eventFeatureProvider - ) - list.Add(eventFeatureProvider); - - if ( - properties.TryGetValue( - LambdaInvocationBuilder.ResponseFeatureProviderKey, - out var responseObj - ) && responseObj is IFeatureProvider responseFeatureProvider - ) - list.Add(responseFeatureProvider); + AddIfPresent(properties, LambdaInvocationBuilder.EventFeatureProviderKey, list); + AddIfPresent(properties, LambdaInvocationBuilder.ResponseFeatureProviderKey, list); return list.ToArray(); } + + private static void AddIfPresent( + IDictionary properties, + string key, + ICollection target + ) + { + if (properties.TryGetValue(key, out var value) && value is IFeatureProvider provider) + target.Add(provider); + } } From d9053c99711e02eedefc92efe46653f452229e82 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 11:31:16 -0500 Subject: [PATCH 24/48] chore(settings): update code style and cleanup settings - Adjusted various formatting options for C#, XML, and other languages. - Enabled or refined properties like `OptimizeImports`, `Rearrange`, and wrapping behavior. - Synced cleanup profiles for improved consistency across the project. --- AwsLambda.Host.sln.DotSettings | 122 ++++++++++++++++----------------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/AwsLambda.Host.sln.DotSettings b/AwsLambda.Host.sln.DotSettings index 7d920dee..7c660687 100644 --- a/AwsLambda.Host.sln.DotSettings +++ b/AwsLambda.Host.sln.DotSettings @@ -1,5 +1,5 @@  - <?xml version="1.0" encoding="utf-16"?><Profile name="Full Custom Cleanup"><CppReformatCode>True</CppReformatCode><FSharpReformatCode>True</FSharpReformatCode><ShaderLabReformatCode>True</ShaderLabReformatCode><XMLReformatCode>True</XMLReformatCode><VBReformatCode>True</VBReformatCode><CSReformatCode>True</CSReformatCode><CSharpReformatComments>True</CSharpReformatComments><CSCodeStyleAttributes ArrangeVarStyle="True" ArrangeTypeAccessModifier="True" ArrangeTypeMemberAccessModifier="True" SortModifiers="True" ArrangeArgumentsStyle="True" RemoveRedundantParentheses="True" AddMissingParentheses="True" ArrangeBraces="True" ArrangeAttributes="True" ArrangeCodeBodyStyle="True" ArrangeTrailingCommas="True" ArrangeObjectCreation="True" ArrangeDefaultValue="True" ArrangeNamespaces="True" ArrangeNullCheckingPattern="True" /><CSArrangeQualifiers>True</CSArrangeQualifiers><CSFixBuiltinTypeReferences>True</CSFixBuiltinTypeReferences><CppCodeStyleCleanupDescriptor ArrangeBraces="True" ArrangeAuto="True" ArrangeFunctionDeclarations="True" ArrangeNestedNamespaces="True" ArrangeTypeAliases="True" ArrangeCVQualifiers="True" ArrangeSlashesInIncludeDirectives="True" ArrangeOverridingFunctions="True" SortDefinitions="True" SortIncludeDirectives="True" SortMemberInitializers="True" /><FormatAttributeQuoteDescriptor>True</FormatAttributeQuoteDescriptor><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings><EmbraceInRegion>True</EmbraceInRegion></CSOptimizeUsings><CSShortenReferences>True</CSShortenReferences><VBOptimizeImports>True</VBOptimizeImports><VBShortenReferences>True</VBShortenReferences><Xaml.RemoveRedundantNamespaceAlias>True</Xaml.RemoveRedundantNamespaceAlias><AspOptimizeRegisterDirectives>True</AspOptimizeRegisterDirectives><CSReorderTypeMembers>True</CSReorderTypeMembers><RemoveCodeRedundancies>True</RemoveCodeRedundancies><CSUseAutoProperty>True</CSUseAutoProperty><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSMakeAutoPropertyGetOnly>True</CSMakeAutoPropertyGetOnly><CppAddTypenameTemplateKeywords>True</CppAddTypenameTemplateKeywords><CppCStyleToStaticCastDescriptor>True</CppCStyleToStaticCastDescriptor><CppRedundantDereferences>True</CppRedundantDereferences><CppDeleteRedundantAccessSpecifier>True</CppDeleteRedundantAccessSpecifier><CppRemoveCastDescriptor>True</CppRemoveCastDescriptor><CppRemoveElseKeyword>True</CppRemoveElseKeyword><CppShortenQualifiedName>True</CppShortenQualifiedName><CppDeleteRedundantSpecifier>True</CppDeleteRedundantSpecifier><CppRemoveStatement>True</CppRemoveStatement><CppDeleteRedundantTypenameTemplateKeywords>True</CppDeleteRedundantTypenameTemplateKeywords><CppReplaceExpressionWithBooleanConst>True</CppReplaceExpressionWithBooleanConst><CppMakeIfConstexpr>True</CppMakeIfConstexpr><CppMakePostfixOperatorPrefix>True</CppMakePostfixOperatorPrefix><CppMakeVariableConstexpr>True</CppMakeVariableConstexpr><CppChangeSmartPointerToMakeFunction>True</CppChangeSmartPointerToMakeFunction><CppReplaceThrowWithRethrowFix>True</CppReplaceThrowWithRethrowFix><CppTypeTraitAliasDescriptor>True</CppTypeTraitAliasDescriptor><CppRemoveRedundantConditionalExpressionDescriptor>True</CppRemoveRedundantConditionalExpressionDescriptor><CppSimplifyConditionalExpressionDescriptor>True</CppSimplifyConditionalExpressionDescriptor><CppReplaceExpressionWithNullptr>True</CppReplaceExpressionWithNullptr><CppReplaceTieWithStructuredBindingDescriptor>True</CppReplaceTieWithStructuredBindingDescriptor><CppUseAssociativeContainsDescriptor>True</CppUseAssociativeContainsDescriptor><CppUseEraseAlgorithmDescriptor>True</CppUseEraseAlgorithmDescriptor><CppJoinDeclarationAndAssignmentDescriptor>True</CppJoinDeclarationAndAssignmentDescriptor><CppMakeClassFinal>True</CppMakeClassFinal><CppMakeLocalVarConstDescriptor>True</CppMakeLocalVarConstDescriptor><CppMakeMethodConst>True</CppMakeMethodConst><CppMakeMethodStatic>True</CppMakeMethodStatic><CppMakePtrOrRefParameterConst>True</CppMakePtrOrRefParameterConst><CppMakeParameterConst>True</CppMakeParameterConst><CppPassValueParameterByConstReference>True</CppPassValueParameterByConstReference><CppRemoveElaboratedTypeSpecifierDescriptor>True</CppRemoveElaboratedTypeSpecifierDescriptor><CppRemoveRedundantLambdaParameterListDescriptor>True</CppRemoveRedundantLambdaParameterListDescriptor><CppRemoveRedundantMemberInitializerDescriptor>True</CppRemoveRedundantMemberInitializerDescriptor><CppRemoveRedundantParentheses>True</CppRemoveRedundantParentheses><CppRemoveTemplateArgumentsDescriptor>True</CppRemoveTemplateArgumentsDescriptor><CppRemoveUnreachableCode>True</CppRemoveUnreachableCode><CppRemoveUnusedIncludes>True</CppRemoveUnusedIncludes><CppRemoveUnusedLambdaCaptures>True</CppRemoveUnusedLambdaCaptures><CppReplaceIfWithIfConsteval>True</CppReplaceIfWithIfConsteval><RemoveCodeRedundanciesVB>True</RemoveCodeRedundanciesVB><VBMakeFieldReadonly>True</VBMakeFieldReadonly><Xaml.RedundantFreezeAttribute>True</Xaml.RedundantFreezeAttribute><Xaml.RemoveRedundantModifiersAttribute>True</Xaml.RemoveRedundantModifiersAttribute><Xaml.RemoveRedundantNameAttribute>True</Xaml.RemoveRedundantNameAttribute><Xaml.RemoveRedundantResource>True</Xaml.RemoveRedundantResource><Xaml.RemoveRedundantCollectionProperty>True</Xaml.RemoveRedundantCollectionProperty><Xaml.RemoveRedundantAttachedPropertySetter>True</Xaml.RemoveRedundantAttachedPropertySetter><Xaml.RemoveRedundantStyledValue>True</Xaml.RemoveRedundantStyledValue><Xaml.RemoveForbiddenResourceName>True</Xaml.RemoveForbiddenResourceName><Xaml.RemoveRedundantGridDefinitionsAttribute>True</Xaml.RemoveRedundantGridDefinitionsAttribute><Xaml.RemoveRedundantUpdateSourceTriggerAttribute>True</Xaml.RemoveRedundantUpdateSourceTriggerAttribute><Xaml.RemoveRedundantBindingModeAttribute>True</Xaml.RemoveRedundantBindingModeAttribute><Xaml.RemoveRedundantGridSpanAttribut>True</Xaml.RemoveRedundantGridSpanAttribut><IDEA_SETTINGS>&lt;profile version="1.0"&gt; + <?xml version="1.0" encoding="utf-16"?><Profile name="Full Custom Cleanup"><CppReformatCode>True</CppReformatCode><FSharpReformatCode>True</FSharpReformatCode><ShaderLabReformatCode>True</ShaderLabReformatCode><XMLReformatCode>True</XMLReformatCode><VBReformatCode>True</VBReformatCode><CSReformatCode>True</CSReformatCode><CSharpReformatComments>True</CSharpReformatComments><CSCodeStyleAttributes ArrangeVarStyle="True" ArrangeTypeAccessModifier="True" ArrangeTypeMemberAccessModifier="True" SortModifiers="True" ArrangeArgumentsStyle="True" RemoveRedundantParentheses="True" AddMissingParentheses="True" ArrangeBraces="True" ArrangeAttributes="True" ArrangeCodeBodyStyle="True" ArrangeTrailingCommas="True" ArrangeObjectCreation="True" ArrangeDefaultValue="True" ArrangeNamespaces="True" ArrangeNullCheckingPattern="True" /><CSArrangeQualifiers>True</CSArrangeQualifiers><CSFixBuiltinTypeReferences>True</CSFixBuiltinTypeReferences><CppCodeStyleCleanupDescriptor ArrangeBraces="True" ArrangeAuto="True" ArrangeFunctionDeclarations="True" ArrangeNestedNamespaces="True" ArrangeTypeAliases="True" ArrangeCVQualifiers="True" ArrangeSlashesInIncludeDirectives="True" ArrangeOverridingFunctions="True" SortDefinitions="True" SortIncludeDirectives="True" SortMemberInitializers="True" /><FormatAttributeQuoteDescriptor>True</FormatAttributeQuoteDescriptor><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings></CSOptimizeUsings><CSShortenReferences>True</CSShortenReferences><VBOptimizeImports>True</VBOptimizeImports><VBShortenReferences>True</VBShortenReferences><Xaml.RemoveRedundantNamespaceAlias>True</Xaml.RemoveRedundantNamespaceAlias><AspOptimizeRegisterDirectives>True</AspOptimizeRegisterDirectives><CSReorderTypeMembers>True</CSReorderTypeMembers><RemoveCodeRedundancies>True</RemoveCodeRedundancies><CSUseAutoProperty>True</CSUseAutoProperty><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSMakeAutoPropertyGetOnly>True</CSMakeAutoPropertyGetOnly><CppAddTypenameTemplateKeywords>True</CppAddTypenameTemplateKeywords><CppCStyleToStaticCastDescriptor>True</CppCStyleToStaticCastDescriptor><CppRedundantDereferences>True</CppRedundantDereferences><CppDeleteRedundantAccessSpecifier>True</CppDeleteRedundantAccessSpecifier><CppRemoveCastDescriptor>True</CppRemoveCastDescriptor><CppRemoveElseKeyword>True</CppRemoveElseKeyword><CppShortenQualifiedName>True</CppShortenQualifiedName><CppDeleteRedundantSpecifier>True</CppDeleteRedundantSpecifier><CppRemoveStatement>True</CppRemoveStatement><CppDeleteRedundantTypenameTemplateKeywords>True</CppDeleteRedundantTypenameTemplateKeywords><CppReplaceExpressionWithBooleanConst>True</CppReplaceExpressionWithBooleanConst><CppMakeIfConstexpr>True</CppMakeIfConstexpr><CppMakePostfixOperatorPrefix>True</CppMakePostfixOperatorPrefix><CppMakeVariableConstexpr>True</CppMakeVariableConstexpr><CppChangeSmartPointerToMakeFunction>True</CppChangeSmartPointerToMakeFunction><CppReplaceThrowWithRethrowFix>True</CppReplaceThrowWithRethrowFix><CppTypeTraitAliasDescriptor>True</CppTypeTraitAliasDescriptor><CppRemoveRedundantConditionalExpressionDescriptor>True</CppRemoveRedundantConditionalExpressionDescriptor><CppSimplifyConditionalExpressionDescriptor>True</CppSimplifyConditionalExpressionDescriptor><CppReplaceExpressionWithNullptr>True</CppReplaceExpressionWithNullptr><CppReplaceTieWithStructuredBindingDescriptor>True</CppReplaceTieWithStructuredBindingDescriptor><CppUseAssociativeContainsDescriptor>True</CppUseAssociativeContainsDescriptor><CppUseEraseAlgorithmDescriptor>True</CppUseEraseAlgorithmDescriptor><CppJoinDeclarationAndAssignmentDescriptor>True</CppJoinDeclarationAndAssignmentDescriptor><CppMakeClassFinal>True</CppMakeClassFinal><CppMakeLocalVarConstDescriptor>True</CppMakeLocalVarConstDescriptor><CppMakeMethodConst>True</CppMakeMethodConst><CppMakeMethodStatic>True</CppMakeMethodStatic><CppMakePtrOrRefParameterConst>True</CppMakePtrOrRefParameterConst><CppMakeParameterConst>True</CppMakeParameterConst><CppPassValueParameterByConstReference>True</CppPassValueParameterByConstReference><CppRemoveElaboratedTypeSpecifierDescriptor>True</CppRemoveElaboratedTypeSpecifierDescriptor><CppRemoveRedundantLambdaParameterListDescriptor>True</CppRemoveRedundantLambdaParameterListDescriptor><CppRemoveRedundantMemberInitializerDescriptor>True</CppRemoveRedundantMemberInitializerDescriptor><CppRemoveRedundantParentheses>True</CppRemoveRedundantParentheses><CppRemoveTemplateArgumentsDescriptor>True</CppRemoveTemplateArgumentsDescriptor><CppRemoveUnreachableCode>True</CppRemoveUnreachableCode><CppRemoveUnusedIncludes>True</CppRemoveUnusedIncludes><CppRemoveUnusedLambdaCaptures>True</CppRemoveUnusedLambdaCaptures><CppReplaceIfWithIfConsteval>True</CppReplaceIfWithIfConsteval><RemoveCodeRedundanciesVB>True</RemoveCodeRedundanciesVB><VBMakeFieldReadonly>True</VBMakeFieldReadonly><Xaml.RedundantFreezeAttribute>True</Xaml.RedundantFreezeAttribute><Xaml.RemoveRedundantModifiersAttribute>True</Xaml.RemoveRedundantModifiersAttribute><Xaml.RemoveRedundantNameAttribute>True</Xaml.RemoveRedundantNameAttribute><Xaml.RemoveRedundantResource>True</Xaml.RemoveRedundantResource><Xaml.RemoveRedundantCollectionProperty>True</Xaml.RemoveRedundantCollectionProperty><Xaml.RemoveRedundantAttachedPropertySetter>True</Xaml.RemoveRedundantAttachedPropertySetter><Xaml.RemoveRedundantStyledValue>True</Xaml.RemoveRedundantStyledValue><Xaml.RemoveForbiddenResourceName>True</Xaml.RemoveForbiddenResourceName><Xaml.RemoveRedundantGridDefinitionsAttribute>True</Xaml.RemoveRedundantGridDefinitionsAttribute><Xaml.RemoveRedundantUpdateSourceTriggerAttribute>True</Xaml.RemoveRedundantUpdateSourceTriggerAttribute><Xaml.RemoveRedundantBindingModeAttribute>True</Xaml.RemoveRedundantBindingModeAttribute><Xaml.RemoveRedundantGridSpanAttribut>True</Xaml.RemoveRedundantGridSpanAttribut><IDEA_SETTINGS>&lt;profile version="1.0"&gt; &lt;option name="myName" value="Full Custom Cleanup" /&gt; &lt;inspection_tool class="ConditionalExpressionWithIdenticalBranchesJS" enabled="true" level="WARNING" enabled_by_default="true" /&gt; &lt;inspection_tool class="ES6ShorthandObjectProperty" enabled="true" level="WARNING" enabled_by_default="true" /&gt; @@ -19,8 +19,8 @@ &lt;/Language&gt; &lt;Language id="HTML"&gt; &lt;Reformat&gt;true&lt;/Reformat&gt; - &lt;Rearrange&gt;true&lt;/Rearrange&gt; &lt;OptimizeImports&gt;true&lt;/OptimizeImports&gt; + &lt;Rearrange&gt;true&lt;/Rearrange&gt; &lt;/Language&gt; &lt;Language id="HTTP Request"&gt; &lt;Reformat&gt;true&lt;/Reformat&gt; @@ -39,8 +39,8 @@ &lt;/Language&gt; &lt;Language id="JavaScript"&gt; &lt;Reformat&gt;true&lt;/Reformat&gt; - &lt;Rearrange&gt;true&lt;/Rearrange&gt; &lt;OptimizeImports&gt;true&lt;/OptimizeImports&gt; + &lt;Rearrange&gt;true&lt;/Rearrange&gt; &lt;/Language&gt; &lt;Language id="Markdown"&gt; &lt;Reformat&gt;false&lt;/Reformat&gt; @@ -71,67 +71,67 @@ &lt;/Language&gt; &lt;Language id="XML"&gt; &lt;Reformat&gt;true&lt;/Reformat&gt; - &lt;Rearrange&gt;true&lt;/Rearrange&gt; &lt;OptimizeImports&gt;true&lt;/OptimizeImports&gt; + &lt;Rearrange&gt;true&lt;/Rearrange&gt; &lt;/Language&gt; &lt;Language id="yaml"&gt; &lt;Reformat&gt;true&lt;/Reformat&gt; &lt;/Language&gt; &lt;/profile&gt;</RIDER_SETTINGS></Profile> - Built-in: Full Cleanup - NotRequired - NotRequired - NotRequired - NotRequired - ExpressionBody - ExpressionBody - ExpressionBody - True - False - False - False - False - False - False - False - True - 1 - ALWAYS - ALWAYS - ALWAYS - False - NEVER - False - False - ALWAYS_IF_MULTILINE - True - True - CHOP_IF_LONG - False - True - True - True - True - True - CHOP_IF_LONG - True - CHOP_IF_LONG - CHOP_IF_LONG - 2 - False - False - 2 - ByFirstAttr - True - False - True - False - False - True - False - False - True - True - True - True - True \ No newline at end of file + Built-in: Full Cleanup + NotRequired + NotRequired + NotRequired + NotRequired + ExpressionBody + ExpressionBody + ExpressionBody + True + False + False + False + False + False + False + False + True + 1 + ALWAYS + ALWAYS + ALWAYS + False + NEVER + False + False + ALWAYS_IF_MULTILINE + True + True + CHOP_IF_LONG + False + True + True + True + True + True + CHOP_IF_LONG + True + CHOP_IF_LONG + CHOP_IF_LONG + 2 + False + False + 2 + ByFirstAttr + True + False + True + False + False + True + False + False + True + True + True + True + True \ No newline at end of file From 268b58d85302e0ea8d950bffdbe9b4207b6ac89e Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 13:35:16 -0500 Subject: [PATCH 25/48] feat(opentelemetry): remove OpenTelemetry integrations for AwsLambda - Deleted `LambdaOpenTelemetryAdapters` and associated extensions for unused tracing logic. - Removed related unit tests in `LambdaOpenTelemetryServiceProviderExtensionsTests`. - Streamlined `UseOpenTelemetryTracing` by simplifying middleware definition. - Eliminated outdated `UseOpenTelemetryTracing_old` with replaced new middleware strategy. --- .../LambdaOpenTelemetryAdapters.cs | 220 --------- .../MiddlewareOpenTelemetryExtensions.cs | 102 +--- ...TelemetryServiceProviderExtensionsTests.cs | 459 ------------------ 3 files changed, 18 insertions(+), 763 deletions(-) delete mode 100644 src/AwsLambda.Host.OpenTelemetry/LambdaOpenTelemetryAdapters.cs delete mode 100644 tests/AwsLambda.Host.OpenTelemetry.UnitTests/LambdaOpenTelemetryServiceProviderExtensionsTests.cs diff --git a/src/AwsLambda.Host.OpenTelemetry/LambdaOpenTelemetryAdapters.cs b/src/AwsLambda.Host.OpenTelemetry/LambdaOpenTelemetryAdapters.cs deleted file mode 100644 index 27cc4bb8..00000000 --- a/src/AwsLambda.Host.OpenTelemetry/LambdaOpenTelemetryAdapters.cs +++ /dev/null @@ -1,220 +0,0 @@ -using Amazon.Lambda.Core; -using AwsLambda.Host; -using AwsLambda.Host.Core; -using OpenTelemetry.Instrumentation.AWSLambda; -using OpenTelemetry.Trace; - -namespace Microsoft.Extensions.DependencyInjection; - -/// -/// Provides extension methods for integrating OpenTelemetry tracing with AWS Lambda -/// invocations. -/// -public static class LambdaOpenTelemetryServiceProviderExtensions -{ - extension(IServiceProvider services) - { - /// - /// Creates a middleware function that traces Lambda invocations with both event and response - /// types. - /// - /// The type of the Lambda event expected in the context. - /// The type of the Lambda response expected in the context. - /// A middleware function that wraps the Lambda invocation with OpenTelemetry tracing. - /// - /// - /// Important: These methods are primarily intended to be used by source generators - /// and interceptors. Direct usage is not recommended. Source generation and interception are - /// the primary use cases for automatic tracing integration. - /// - /// - /// Uses the registered to wrap Lambda invocations with - /// distributed tracing capabilities through AWS Lambda instrumentation. This method is a - /// wrapper around from - /// the - /// OpenTelemetry.Instrumentation.AWSLambda - /// NuGet package. - /// - /// - /// The context must contain an event of type and the handler - /// must set a response of type . - /// - /// - /// TracerProvider Registration Required: A instance - /// must be registered in the dependency injection container before calling these methods. - /// Failure to register a will result in an - /// being thrown at startup. - /// - /// - /// - /// Thrown if the context event is not of type - /// or if the context response is not of type - /// , or if a instance is not - /// registered in the dependency injection container. - /// - public Func GetOpenTelemetryTracer< - TEvent, - TResponse - >() - { - ArgumentNullException.ThrowIfNull(services); - - var tracerProvider = services.GetRequiredService(); - - return next => - { - return async context => - { - if ( - context.Features.Get()?.GetEvent(context) - is not TEvent eventT - ) - throw new InvalidOperationException( - $"Lambda event of type '{typeof(TEvent).FullName}' is not available in the context." - ); - - await AWSLambdaWrapper.TraceAsync( - tracerProvider, - async Task (_, _) => - { - await next(context); - - if ( - context.Features.Get()?.GetResponse() - is not TResponse responseT - ) - throw new InvalidOperationException( - $"Lambda response of type '{typeof(TResponse).FullName}' is not available in the context." - ); - - return responseT; - }, - eventT, - context - ); - }; - }; - } - - /// Creates a middleware function that traces Lambda invocations with only a response type. - /// The type of the Lambda response expected in the context. - /// - /// - /// The event - /// type is not relevant or known when using this overload. - /// - /// - /// Thrown if the context response is not of type - /// . - /// - public Func< - LambdaInvocationDelegate, - LambdaInvocationDelegate - > GetOpenTelemetryTracerNoEvent() - { - ArgumentNullException.ThrowIfNull(services); - - var tracerProvider = services.GetRequiredService(); - - return next => - { - return async context => - { - await AWSLambdaWrapper.TraceAsync( - tracerProvider, - async Task (object? _, ILambdaContext _) => - { - await next(context); - - if ( - context.Features.Get()?.GetResponse() - is not TResponse responseT - ) - throw new InvalidOperationException( - $"Lambda response of type '{typeof(TResponse).FullName}' is not available in the context." - ); - - return responseT; - }, - null, - context - ); - }; - }; - } - - /// Creates a middleware function that traces Lambda invocations with only an event type. - /// The type of the Lambda event expected in the context. - /// - /// - /// The - /// response type is not relevant or known when using this overload. - /// - /// - /// Thrown if the context event is not of type - /// . - /// - public Func< - LambdaInvocationDelegate, - LambdaInvocationDelegate - > GetOpenTelemetryTracerNoResponse() - { - ArgumentNullException.ThrowIfNull(services); - - var tracerProvider = services.GetRequiredService(); - - return next => - { - return async context => - { - if ( - context.Features.Get()?.GetEvent(context) - is not TEvent eventT - ) - throw new InvalidOperationException( - $"Lambda event of type '{typeof(TEvent).FullName}' is not available in the context." - ); - - await AWSLambdaWrapper.TraceAsync( - tracerProvider, - async Task (_, _) => await next(context), - eventT, - context - ); - }; - }; - } - - /// - /// Creates a middleware function that traces Lambda invocations without specific event or - /// response types. - /// - /// - /// - /// Neither - /// event nor response types are relevant or known when using this overload. - /// - public Func< - LambdaInvocationDelegate, - LambdaInvocationDelegate - > GetOpenTelemetryTracerNoEventNoResponse() - { - ArgumentNullException.ThrowIfNull(services); - - var tracerProvider = services.GetRequiredService(); - - return next => - { - return async context => - { - await AWSLambdaWrapper.TraceAsync( - tracerProvider, - async Task (object? _, ILambdaContext _) => await next(context), - null, - context - ); - }; - }; - } - } -} diff --git a/src/AwsLambda.Host.OpenTelemetry/MiddlewareOpenTelemetryExtensions.cs b/src/AwsLambda.Host.OpenTelemetry/MiddlewareOpenTelemetryExtensions.cs index 1488948b..995dd42c 100644 --- a/src/AwsLambda.Host.OpenTelemetry/MiddlewareOpenTelemetryExtensions.cs +++ b/src/AwsLambda.Host.OpenTelemetry/MiddlewareOpenTelemetryExtensions.cs @@ -1,102 +1,36 @@ -#region - -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; using OpenTelemetry.Instrumentation.AWSLambda; using OpenTelemetry.Trace; -#endregion - namespace AwsLambda.Host.Builder; /// /// Provides extension methods for enabling OpenTelemetry tracing in the Lambda invocation /// pipeline. /// -[ExcludeFromCodeCoverage] public static class MiddlewareOpenTelemetryExtensions { - /// Enables OpenTelemetry tracing for the AWS Lambda handler. - /// - /// - /// This method is as a no-op that is intercepted and replaced at compile time It uses the - /// OpenTelemetry instrumentation provided by the - /// OpenTelemetry.Instrumentation.AWSLambda - /// package to instrument the Lambda handler invocations with distributed tracing. - /// - /// - /// When this method is called, the source generator creates an interceptor that: - /// - /// - /// - /// At startup, pulls an instance of from - /// the dependency injection container. This will be used for the lifetime of the - /// Lambda. - /// - /// - /// - /// - /// Wraps the handler pipeline with tracing middleware that creates a - /// root span with invocation info. - /// - /// - /// - /// - /// - /// Middleware Placement: For the most accurate trace data, this method should be - /// called at the top of the middleware pipeline, before other middleware where possible. This - /// ensures that tracing captures as much of the invocation as possible, including the - /// execution time of subsequent middleware components. - /// - /// - /// TracerProvider Registration Required: A instance - /// must be registered in the dependency injection container before calling this method. If no - /// instance is registered, an will be thrown at - /// startup. - /// - /// - /// The instance. - /// The same instance for method chaining. - /// - /// - /// First, register OpenTelemetry in the dependency injection container using AWS Lambda - /// configurations: - /// - /// - /// var builder = LambdaApplication.CreateBuilder(); - /// - /// builder - /// .Services.AddOpenTelemetry() - /// .WithTracing(configure => configure - /// .AddAWSLambdaConfigurations() - /// .AddConsoleExporter()); - /// - /// Then call this method in your Lambda handler setup to enable tracing: - /// - /// var lambda = builder.Build(); - /// - /// lambda.UseOpenTelemetryTracing(); - /// - /// lambda.MapHandler(([Event] Request request) => new Response($"Hello {request.Name}!")); - /// - /// await lambda.RunAsync(); - /// - /// record Request(string Name); - /// record Response(string Message); - /// - /// - public static ILambdaInvocationBuilder UseOpenTelemetryTracing_old( - this ILambdaInvocationBuilder application - ) - { - Debug.Fail("This method should have been intercepted at compile time!"); - throw new InvalidOperationException("This method is replaced at compile time."); - } - extension(ILambdaInvocationBuilder builder) { + /// Enables OpenTelemetry tracing for AWS Lambda handler invocations. + /// + /// + /// Adds middleware that wraps each Lambda invocation with distributed tracing using the + /// from the OpenTelemetry AWS Lambda instrumentation + /// package. A root span is created for each invocation with Lambda context information. + /// + /// + /// Middleware Placement: Call this method early in the middleware pipeline to + /// capture the execution time of all subsequent middleware and handler logic. + /// + /// + /// TracerProvider Registration Required: A must be + /// registered in the dependency injection container. If not found, an + /// is thrown at startup. + /// + /// + /// The same instance for method chaining. public ILambdaInvocationBuilder UseOpenTelemetryTracing() { ArgumentNullException.ThrowIfNull(builder); diff --git a/tests/AwsLambda.Host.OpenTelemetry.UnitTests/LambdaOpenTelemetryServiceProviderExtensionsTests.cs b/tests/AwsLambda.Host.OpenTelemetry.UnitTests/LambdaOpenTelemetryServiceProviderExtensionsTests.cs deleted file mode 100644 index 9e02d27f..00000000 --- a/tests/AwsLambda.Host.OpenTelemetry.UnitTests/LambdaOpenTelemetryServiceProviderExtensionsTests.cs +++ /dev/null @@ -1,459 +0,0 @@ -using AwsLambda.Host.UnitTests; -using Microsoft.Extensions.DependencyInjection; -using OpenTelemetry.Trace; - -namespace AwsLambda.Host.OpenTelemetry.UnitTests; - -[TestSubject(typeof(LambdaOpenTelemetryServiceProviderExtensions))] -public class LambdaOpenTelemetryServiceProviderExtensionsTests -{ - [Fact] - public void GetOpenTelemetryTracer_WithNullServiceProvider_ThrowsArgumentNullException() - { - // Arrange - IServiceProvider? nullProvider = null; - - // Act - var action = () => nullProvider!.GetOpenTelemetryTracer(); - - // Assert - action.Should().ThrowExactly(); - } - - [Theory] - [AutoNSubstituteData] - public void GetOpenTelemetryTracer_WithoutTracerProvider_ThrowsInvalidOperationException( - [Frozen] IServiceProvider serviceProvider - ) - { - // Arrange - serviceProvider.GetService(typeof(TracerProvider)).Returns(null); - - // Act - var action = () => serviceProvider.GetOpenTelemetryTracer(); - - // Assert - action.Should().ThrowExactly(); - } - - [Theory] - [AutoNSubstituteData] - public void GetOpenTelemetryTracer_ReturnsMiddlewareFunction( - [Frozen] IServiceProvider serviceProvider, - TracerProvider tracerProvider - ) - { - // Arrange - serviceProvider.GetService(typeof(TracerProvider)).Returns(tracerProvider); - - // Act - var middleware = serviceProvider.GetOpenTelemetryTracer(); - - // Assert - middleware.Should().NotBeNull(); - middleware.Should().BeOfType>(); - } - - [Theory] - [AutoNSubstituteData] - public async Task GetOpenTelemetryTracer_WithIncorrectEventType_ThrowsInvalidOperationException( - [Frozen] IServiceProvider serviceProvider, - TracerProvider tracerProvider, - ILambdaHostContext context, - IFeatureCollection features, - IEventFeature eventFeature, - IResponseFeature responseFeature - ) - { - // Arrange - serviceProvider.GetService(typeof(TracerProvider)).Returns(tracerProvider); - var middleware = serviceProvider.GetOpenTelemetryTracer(); - var nextDelegate = Substitute.For(); - var wrappedDelegate = middleware(nextDelegate); - - context.Features.Returns(features); - features.Get().Returns(eventFeature); - features.Get().Returns(responseFeature); - eventFeature.GetEvent(context).Returns(new object()); - - // Act - var action = async () => await wrappedDelegate(context); - - // Assert - await action.Should().ThrowAsync(); - } - - [Theory] - [AutoNSubstituteData] - public async Task GetOpenTelemetryTracer_WithIncorrectResponseType_ThrowsInvalidOperationException( - [Frozen] IServiceProvider serviceProvider, - TracerProvider tracerProvider, - ILambdaHostContext context, - IFeatureCollection features, - IEventFeature eventFeature, - IResponseFeature responseFeature - ) - { - // Arrange - serviceProvider.GetService(typeof(TracerProvider)).Returns(tracerProvider); - var middleware = serviceProvider.GetOpenTelemetryTracer(); - var nextDelegate = Substitute.For(); - var wrappedDelegate = middleware(nextDelegate); - - context.Features.Returns(features); - features.Get().Returns(eventFeature); - features.Get().Returns(responseFeature); - eventFeature.GetEvent(context).Returns(new TestEvent()); - responseFeature.GetResponse().Returns(new object()); // Wrong type - - nextDelegate(Arg.Any()).Returns(Task.CompletedTask); - - // Act - var action = async () => await wrappedDelegate(context); - - // Assert - await action.Should().ThrowAsync(); - } - - [Theory] - [AutoNSubstituteData] - public async Task GetOpenTelemetryTracer_WithValidEventAndResponse_CallsNextDelegate( - [Frozen] IServiceProvider serviceProvider, - TracerProvider tracerProvider, - ILambdaHostContext context, - IFeatureCollection features, - IEventFeature eventFeature, - IResponseFeature responseFeature - ) - { - // Arrange - serviceProvider.GetService(typeof(TracerProvider)).Returns(tracerProvider); - var middleware = serviceProvider.GetOpenTelemetryTracer(); - var nextDelegate = Substitute.For(); - var wrappedDelegate = middleware(nextDelegate); - - var testEvent = new TestEvent(); - var testResponse = new TestResponse(); - - context.Features.Returns(features); - features.Get().Returns(eventFeature); - features.Get().Returns(responseFeature); - eventFeature.GetEvent(context).Returns(testEvent); - responseFeature.GetResponse().Returns(testResponse); - - nextDelegate(Arg.Any()).Returns(Task.CompletedTask); - - // Act - await wrappedDelegate(context); - - // Assert - await nextDelegate.Received(1)(Arg.Any()); - } - - [Fact] - public void GetOpenTelemetryTracerNoEvent_WithNullServiceProvider_ThrowsArgumentNullException() - { - // Arrange - IServiceProvider? nullProvider = null; - - // Act - var action = () => nullProvider!.GetOpenTelemetryTracerNoEvent(); - - // Assert - action.Should().ThrowExactly(); - } - - [Theory] - [AutoNSubstituteData] - public void GetOpenTelemetryTracerNoEvent_WithoutTracerProvider_ThrowsInvalidOperationException( - [Frozen] IServiceProvider serviceProvider - ) - { - // Arrange - serviceProvider.GetService(typeof(TracerProvider)).Returns(null); - - // Act - var action = () => serviceProvider.GetOpenTelemetryTracerNoEvent(); - - // Assert - action.Should().ThrowExactly(); - } - - [Theory] - [AutoNSubstituteData] - public void GetOpenTelemetryTracerNoEvent_ReturnsMiddlewareFunction( - [Frozen] IServiceProvider serviceProvider, - TracerProvider tracerProvider - ) - { - // Arrange - serviceProvider.GetService(typeof(TracerProvider)).Returns(tracerProvider); - - // Act - var middleware = serviceProvider.GetOpenTelemetryTracerNoEvent(); - - // Assert - middleware.Should().NotBeNull(); - middleware.Should().BeOfType>(); - } - - [Theory] - [AutoNSubstituteData] - public async Task GetOpenTelemetryTracerNoEvent_WithIncorrectResponseType_ThrowsInvalidOperationException( - [Frozen] IServiceProvider serviceProvider, - TracerProvider tracerProvider, - ILambdaHostContext context, - IFeatureCollection features, - IEventFeature eventFeature, - IResponseFeature responseFeature - ) - { - // Arrange - serviceProvider.GetService(typeof(TracerProvider)).Returns(tracerProvider); - var middleware = serviceProvider.GetOpenTelemetryTracerNoEvent(); - var nextDelegate = Substitute.For(); - var wrappedDelegate = middleware(nextDelegate); - - context.Features.Returns(features); - features.Get().Returns(eventFeature); - features.Get().Returns(responseFeature); - eventFeature.GetEvent(context).Returns(new object()); - responseFeature.GetResponse().Returns(new object()); // Wrong type - - nextDelegate(Arg.Any()).Returns(Task.CompletedTask); - - // Act - var action = async () => await wrappedDelegate(context); - - // Assert - await action.Should().ThrowAsync(); - } - - [Theory] - [AutoNSubstituteData] - public async Task GetOpenTelemetryTracerNoEvent_WithValidResponse_CallsNextDelegate( - [Frozen] IServiceProvider serviceProvider, - TracerProvider tracerProvider, - ILambdaHostContext context, - IFeatureCollection features, - IEventFeature eventFeature, - IResponseFeature responseFeature - ) - { - // Arrange - serviceProvider.GetService(typeof(TracerProvider)).Returns(tracerProvider); - var middleware = serviceProvider.GetOpenTelemetryTracerNoEvent(); - var nextDelegate = Substitute.For(); - var wrappedDelegate = middleware(nextDelegate); - - var testResponse = new TestResponse(); - - context.Features.Returns(features); - features.Get().Returns(eventFeature); - features.Get().Returns(responseFeature); - eventFeature.GetEvent(context).Returns(new object()); - responseFeature.GetResponse().Returns(testResponse); - - nextDelegate(Arg.Any()).Returns(Task.CompletedTask); - - // Act - await wrappedDelegate(context); - - // Assert - await nextDelegate.Received(1)(Arg.Any()); - } - - [Fact] - public void GetOpenTelemetryTracerNoResponse_WithNullServiceProvider_ThrowsArgumentNullException() - { - // Arrange - IServiceProvider? nullProvider = null; - - // Act - var action = () => nullProvider!.GetOpenTelemetryTracerNoResponse(); - - // Assert - action.Should().ThrowExactly(); - } - - [Theory] - [AutoNSubstituteData] - public void GetOpenTelemetryTracerNoResponse_WithoutTracerProvider_ThrowsInvalidOperationException( - [Frozen] IServiceProvider serviceProvider - ) - { - // Arrange - serviceProvider.GetService(typeof(TracerProvider)).Returns(null); - - // Act - var action = () => serviceProvider.GetOpenTelemetryTracerNoResponse(); - - // Assert - action.Should().ThrowExactly(); - } - - [Theory] - [AutoNSubstituteData] - public void GetOpenTelemetryTracerNoResponse_ReturnsMiddlewareFunction( - [Frozen] IServiceProvider serviceProvider, - TracerProvider tracerProvider - ) - { - // Arrange - serviceProvider.GetService(typeof(TracerProvider)).Returns(tracerProvider); - - // Act - var middleware = serviceProvider.GetOpenTelemetryTracerNoResponse(); - - // Assert - middleware.Should().NotBeNull(); - middleware.Should().BeOfType>(); - } - - [Theory] - [AutoNSubstituteData] - public async Task GetOpenTelemetryTracerNoResponse_WithIncorrectEventType_ThrowsInvalidOperationException( - [Frozen] IServiceProvider serviceProvider, - TracerProvider tracerProvider, - ILambdaHostContext context, - IFeatureCollection features, - IEventFeature eventFeature, - IResponseFeature responseFeature - ) - { - // Arrange - serviceProvider.GetService(typeof(TracerProvider)).Returns(tracerProvider); - var middleware = serviceProvider.GetOpenTelemetryTracerNoResponse(); - var nextDelegate = Substitute.For(); - var wrappedDelegate = middleware(nextDelegate); - - context.Features.Returns(features); - features.Get().Returns(eventFeature); - features.Get().Returns(responseFeature); - eventFeature.GetEvent(context).Returns(new object()); // Wrong type - responseFeature.GetResponse().Returns(new object()); - - // Act - var action = async () => await wrappedDelegate(context); - - // Assert - await action.Should().ThrowAsync(); - } - - [Theory] - [AutoNSubstituteData] - public async Task GetOpenTelemetryTracerNoResponse_WithValidEvent_CallsNextDelegate( - [Frozen] IServiceProvider serviceProvider, - TracerProvider tracerProvider, - ILambdaHostContext context, - IFeatureCollection features, - IEventFeature eventFeature, - IResponseFeature responseFeature - ) - { - // Arrange - serviceProvider.GetService(typeof(TracerProvider)).Returns(tracerProvider); - var middleware = serviceProvider.GetOpenTelemetryTracerNoResponse(); - var nextDelegate = Substitute.For(); - var wrappedDelegate = middleware(nextDelegate); - - var testEvent = new TestEvent(); - - context.Features.Returns(features); - features.Get().Returns(eventFeature); - features.Get().Returns(responseFeature); - eventFeature.GetEvent(context).Returns(testEvent); - responseFeature.GetResponse().Returns(new object()); - - nextDelegate(Arg.Any()).Returns(Task.CompletedTask); - - // Act - await wrappedDelegate(context); - - // Assert - await nextDelegate.Received(1)(Arg.Any()); - } - - [Fact] - public void GetOpenTelemetryTracerNoEventNoResponse_WithNullServiceProvider_ThrowsArgumentNullException() - { - // Arrange - IServiceProvider? nullProvider = null; - - // Act - var action = () => nullProvider!.GetOpenTelemetryTracerNoEventNoResponse(); - - // Assert - action.Should().ThrowExactly(); - } - - [Theory] - [AutoNSubstituteData] - public void GetOpenTelemetryTracerNoEventNoResponse_WithoutTracerProvider_ThrowsInvalidOperationException( - [Frozen] IServiceProvider serviceProvider - ) - { - // Arrange - serviceProvider.GetService(typeof(TracerProvider)).Returns(null); - - // Act - var action = () => serviceProvider.GetOpenTelemetryTracerNoEventNoResponse(); - - // Assert - action.Should().ThrowExactly(); - } - - [Theory] - [AutoNSubstituteData] - public void GetOpenTelemetryTracerNoEventNoResponse_ReturnsMiddlewareFunction( - [Frozen] IServiceProvider serviceProvider, - TracerProvider tracerProvider - ) - { - // Arrange - serviceProvider.GetService(typeof(TracerProvider)).Returns(tracerProvider); - - // Act - var middleware = serviceProvider.GetOpenTelemetryTracerNoEventNoResponse(); - - // Assert - middleware.Should().NotBeNull(); - middleware.Should().BeOfType>(); - } - - [Theory] - [AutoNSubstituteData] - public async Task GetOpenTelemetryTracerNoEventNoResponse_WithAnyEventAndResponse_CallsNextDelegate( - [Frozen] IServiceProvider serviceProvider, - TracerProvider tracerProvider, - ILambdaHostContext context, - IFeatureCollection features, - IEventFeature eventFeature, - IResponseFeature responseFeature - ) - { - // Arrange - serviceProvider.GetService(typeof(TracerProvider)).Returns(tracerProvider); - var middleware = serviceProvider.GetOpenTelemetryTracerNoEventNoResponse(); - var nextDelegate = Substitute.For(); - var wrappedDelegate = middleware(nextDelegate); - - context.Features.Returns(features); - features.Get().Returns(eventFeature); - features.Get().Returns(responseFeature); - eventFeature.GetEvent(context).Returns(new object()); - responseFeature.GetResponse().Returns(new object()); - - nextDelegate(Arg.Any()).Returns(Task.CompletedTask); - - // Act - await wrappedDelegate(context); - - // Assert - await nextDelegate.Received(1)(Arg.Any()); - } - - private class TestEvent { } - - private class TestResponse { } -} From b842d7a18b6d510434b605710a146544c07f2241 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 13:52:11 -0500 Subject: [PATCH 26/48] feat(opentelemetry): add unit tests for `UseOpenTelemetryTracing` middleware - Added comprehensive unit tests to validate `UseOpenTelemetryTracing` behavior: - Ensures `ArgumentNullException` is thrown for null invocation builder. - Verifies `InvalidOperationException` is thrown when no `TracerProvider` is registered. - Confirms proper middleware registration and builder return behavior. - Tests middleware execution flow, ensuring the next delegate is invoked correctly. - Improves test coverage for OpenTelemetry middleware in AWS Lambda scenarios. --- .../MiddlewareOpenTelemetryExtensionsTest.cs | 117 ++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 tests/AwsLambda.Host.OpenTelemetry.UnitTests/MiddlewareOpenTelemetryExtensionsTest.cs diff --git a/tests/AwsLambda.Host.OpenTelemetry.UnitTests/MiddlewareOpenTelemetryExtensionsTest.cs b/tests/AwsLambda.Host.OpenTelemetry.UnitTests/MiddlewareOpenTelemetryExtensionsTest.cs new file mode 100644 index 00000000..f5b4e94a --- /dev/null +++ b/tests/AwsLambda.Host.OpenTelemetry.UnitTests/MiddlewareOpenTelemetryExtensionsTest.cs @@ -0,0 +1,117 @@ +using AwsLambda.Host.UnitTests; +using OpenTelemetry.Trace; + +namespace AwsLambda.Host.OpenTelemetry.UnitTests; + +[TestSubject(typeof(MiddlewareOpenTelemetryExtensions))] +public class MiddlewareOpenTelemetryExtensionsTest +{ + [Fact] + public void UseOpenTelemetryTracing_WithNullBuilder_ThrowsArgumentNullException() + { + // Arrange + ILambdaInvocationBuilder builder = null!; + + // Act + Action act = () => builder.UseOpenTelemetryTracing(); + + // Assert + act.Should().ThrowExactly(); + } + + [Theory] + [AutoNSubstituteData] + public void UseOpenTelemetryTracing_WithNoTracerProvider_ThrowsInvalidOperationException( + [Frozen] IServiceProvider serviceProvider, + ILambdaInvocationBuilder builder + ) + { + // Arrange + serviceProvider.GetService(typeof(TracerProvider)).Returns(null); + builder.Services.Returns(serviceProvider); + + // Act + Action act = () => builder.UseOpenTelemetryTracing(); + + // Assert + act.Should() + .ThrowExactly() + .WithMessage( + "No service for type 'OpenTelemetry.Trace.TracerProvider' has been registered." + ); + } + + [Theory] + [AutoNSubstituteData] + public void UseOpenTelemetryTracing_RegistersMiddleware_AndReturnsBuilder( + [Frozen] IServiceProvider serviceProvider, + [Frozen] ILambdaInvocationBuilder builder, + TracerProvider tracerProvider + ) + { + // Arrange + serviceProvider.GetService(typeof(TracerProvider)).Returns(tracerProvider); + builder.Services.Returns(serviceProvider); + builder + .Use(Arg.Any>()) + .Returns(builder); + + // Act + var result = builder.UseOpenTelemetryTracing(); + + // Assert + result.Should().Be(builder); + builder + .Received(1) + .Use(Arg.Any>()); + } + + [Theory] + [AutoNSubstituteData] + public async Task UseOpenTelemetryTracing_Middleware_CallsNextDelegate( + [Frozen] IServiceProvider serviceProvider, + [Frozen] ILambdaInvocationBuilder builder, + TracerProvider tracerProvider, + ILambdaHostContext context, + IFeatureCollection features + ) + { + // Arrange + Func? capturedMiddleware = null; + + serviceProvider.GetService(typeof(TracerProvider)).Returns(tracerProvider); + builder.Services.Returns(serviceProvider); + builder + .Use( + Arg.Do>(m => + capturedMiddleware = m + ) + ) + .Returns(builder); + + context.Features.Returns(features); + features.Get().Returns((IEventFeature?)null); + features.Get().Returns((IResponseFeature?)null); + + // Act + builder.UseOpenTelemetryTracing(); + + // Assert - middleware was captured + capturedMiddleware.Should().NotBeNull(); + + // Create a mock next delegate to verify it gets called + var nextWasCalled = false; + LambdaInvocationDelegate next = _ => + { + nextWasCalled = true; + return Task.CompletedTask; + }; + + // Execute the captured middleware + var wrappedDelegate = capturedMiddleware!(next); + await wrappedDelegate(context); + + // Verify the next delegate was called (wrapped by AWSLambdaWrapper.TraceAsync) + nextWasCalled.Should().BeTrue(); + } +} From 40822807a364a3616ce2f403684ac6ee9ab44980 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 13:54:11 -0500 Subject: [PATCH 27/48] feat(source-generators): remove OpenTelemetry tracing tests and snapshots - Deleted OpenTelemetry-related unit tests in `OtelEnabledVerifyTests`. - Removed OpenTelemetry-generated snapshot files from `SourceGenerators.UnitTests`. - Updated `GeneratorTestHelpers` to remove OpenTelemetry references from metadata setup. --- .../GeneratorTestHelpers.cs | 3 - ...entAndResponse#LambdaHandler.g.verified.cs | 98 -------------- ...dAsyncAndAwait#LambdaHandler.g.verified.cs | 99 -------------- ...ventNoResponse#LambdaHandler.g.verified.cs | 89 ------------- ...bled_OnlyEvent#LambdaHandler.g.verified.cs | 92 ------------- ...d_OnlyResponse#LambdaHandler.g.verified.cs | 95 -------------- .../VerifyTests/OtelEnabledVerifyTests.cs | 121 ------------------ 7 files changed, 597 deletions(-) delete mode 100644 tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OtelEnabledVerifyTests.Test_OtelEnabled_EventAndResponse#LambdaHandler.g.verified.cs delete mode 100644 tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OtelEnabledVerifyTests.Test_OtelEnabled_ExpressionLambda_DiAndAsyncAndAwait#LambdaHandler.g.verified.cs delete mode 100644 tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OtelEnabledVerifyTests.Test_OtelEnabled_NoEventNoResponse#LambdaHandler.g.verified.cs delete mode 100644 tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OtelEnabledVerifyTests.Test_OtelEnabled_OnlyEvent#LambdaHandler.g.verified.cs delete mode 100644 tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OtelEnabledVerifyTests.Test_OtelEnabled_OnlyResponse#LambdaHandler.g.verified.cs delete mode 100644 tests/AwsLambda.Host.SourceGenerators.UnitTests/VerifyTests/OtelEnabledVerifyTests.cs diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/GeneratorTestHelpers.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/GeneratorTestHelpers.cs index 59435666..8b283f9f 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/GeneratorTestHelpers.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/GeneratorTestHelpers.cs @@ -88,9 +88,6 @@ .. Net90.References.All.ToList(), MetadataReference.CreateFromFile(typeof(IOptions<>).Assembly.Location), MetadataReference.CreateFromFile(typeof(ILambdaHostContext).Assembly.Location), MetadataReference.CreateFromFile(typeof(APIGatewayProxyResponse).Assembly.Location), - MetadataReference.CreateFromFile( - typeof(LambdaOpenTelemetryServiceProviderExtensions).Assembly.Location - ), ]; var compilationOptions = new CSharpCompilationOptions( diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OtelEnabledVerifyTests.Test_OtelEnabled_EventAndResponse#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OtelEnabledVerifyTests.Test_OtelEnabled_EventAndResponse#LambdaHandler.g.verified.cs deleted file mode 100644 index 75495a3a..00000000 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OtelEnabledVerifyTests.Test_OtelEnabled_EventAndResponse#LambdaHandler.g.verified.cs +++ /dev/null @@ -1,98 +0,0 @@ -//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("AwsLambda.Host.SourceGenerators", "0.0.0")] - [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] - file sealed class InterceptsLocationAttribute : Attribute - { - public InterceptsLocationAttribute(int version, string data) - { - } - } -} - -namespace AwsLambda.Host.Core.Generated -{ - using System; - using System.CodeDom.Compiler; - using System.IO; - using System.Runtime.CompilerServices; - using System.Threading.Tasks; - using Amazon.Lambda.Core; - using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; - using Microsoft.Extensions.DependencyInjection; - - [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions - { - // Location: InputFile.cs(11,8) - [InterceptsLocation(1, "QmALRs8r2abUfl00isjWKtkAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( - this ILambdaInvocationBuilder application, - Delegate handler - ) - { - var castHandler = (global::System.Func)handler; - - return application.Handle(InvocationDelegate); - - Task InvocationDelegate(ILambdaHostContext context) - { - // ParameterInfo { Type = global::Request, Name = request, Source = Event, IsNullable = False, IsOptional = False} - var arg0 = context.GetRequiredEvent(); - var response = castHandler.Invoke(arg0); - if (context.Features.Get() is not IResponseFeature responseFeature) - { - throw new InvalidOperationException($"Response feature for type 'global::Response' is not available in the collection."); - } - responseFeature.SetResponse(response); - return Task.CompletedTask; - } - } - - [InterceptsLocation(1, "QmALRs8r2abUfl00isjWKqUAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(7,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - builder.Services.AddSingleton>(); - return builder.Build(); - } - } -} - -namespace AwsLambda.Host.Core.Generated -{ - using System.CodeDom.Compiler; - using System.Runtime.CompilerServices; - using Microsoft.Extensions.DependencyInjection; - using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; - - [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OpenTelemetryLambdaApplicationExtensions - { - [InterceptsLocation(1, "QmALRs8r2abUfl00isjWKrYAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(9,8) - internal static ILambdaInvocationBuilder UseOpenTelemetryTracingInterceptor( - this ILambdaInvocationBuilder application - ) - { - return application.Use(application.Services.GetOpenTelemetryTracer()); - } - } -} diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OtelEnabledVerifyTests.Test_OtelEnabled_ExpressionLambda_DiAndAsyncAndAwait#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OtelEnabledVerifyTests.Test_OtelEnabled_ExpressionLambda_DiAndAsyncAndAwait#LambdaHandler.g.verified.cs deleted file mode 100644 index 9aa63f7e..00000000 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OtelEnabledVerifyTests.Test_OtelEnabled_ExpressionLambda_DiAndAsyncAndAwait#LambdaHandler.g.verified.cs +++ /dev/null @@ -1,99 +0,0 @@ -//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("AwsLambda.Host.SourceGenerators", "0.0.0")] - [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] - file sealed class InterceptsLocationAttribute : Attribute - { - public InterceptsLocationAttribute(int version, string data) - { - } - } -} - -namespace AwsLambda.Host.Core.Generated -{ - using System; - using System.CodeDom.Compiler; - using System.IO; - using System.Runtime.CompilerServices; - using System.Threading.Tasks; - using Amazon.Lambda.Core; - using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; - using Microsoft.Extensions.DependencyInjection; - - [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions - { - // Location: InputFile.cs(13,8) - [InterceptsLocation(1, "mX/YeIwGYTTDQe0umNPm4ScBAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( - this ILambdaInvocationBuilder application, - Delegate handler - ) - { - var castHandler = (global::System.Func>)handler; - - return application.Handle(InvocationDelegate); - - async Task InvocationDelegate(ILambdaHostContext context) - { - // ParameterInfo { Type = string, Name = input, Source = Event, IsNullable = False, IsOptional = False} - var arg0 = context.GetRequiredEvent(); - // ParameterInfo { Type = global::IService, Name = service, Source = Service, IsNullable = False, IsOptional = False} - var arg1 = context.ServiceProvider.GetRequiredService(); - var response = await 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); - } - } - - [InterceptsLocation(1, "mX/YeIwGYTTDQe0umNPm4fMAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(9,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - builder.Services.AddSingleton>(); - return builder.Build(); - } - } -} - -namespace AwsLambda.Host.Core.Generated -{ - using System.CodeDom.Compiler; - using System.Runtime.CompilerServices; - using Microsoft.Extensions.DependencyInjection; - using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; - - [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OpenTelemetryLambdaApplicationExtensions - { - [InterceptsLocation(1, "mX/YeIwGYTTDQe0umNPm4QQBAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(11,8) - internal static ILambdaInvocationBuilder UseOpenTelemetryTracingInterceptor( - this ILambdaInvocationBuilder application - ) - { - return application.Use(application.Services.GetOpenTelemetryTracer()); - } - } -} diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OtelEnabledVerifyTests.Test_OtelEnabled_NoEventNoResponse#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OtelEnabledVerifyTests.Test_OtelEnabled_NoEventNoResponse#LambdaHandler.g.verified.cs deleted file mode 100644 index 42c9fa5b..00000000 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OtelEnabledVerifyTests.Test_OtelEnabled_NoEventNoResponse#LambdaHandler.g.verified.cs +++ /dev/null @@ -1,89 +0,0 @@ -//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("AwsLambda.Host.SourceGenerators", "0.0.0")] - [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] - file sealed class InterceptsLocationAttribute : Attribute - { - public InterceptsLocationAttribute(int version, string data) - { - } - } -} - -namespace AwsLambda.Host.Core.Generated -{ - using System; - using System.CodeDom.Compiler; - using System.IO; - using System.Runtime.CompilerServices; - using System.Threading.Tasks; - using Amazon.Lambda.Core; - using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; - using Microsoft.Extensions.DependencyInjection; - - [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions - { - // Location: InputFile.cs(11,8) - [InterceptsLocation(1, "PVdPB+yDglPnV0ZNm2bBKtkAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( - this ILambdaInvocationBuilder application, - Delegate handler - ) - { - var castHandler = (global::System.Action)handler; - - return application.Handle(InvocationDelegate); - - Task InvocationDelegate(ILambdaHostContext context) - { - castHandler.Invoke(); - return Task.CompletedTask; - } - } - - [InterceptsLocation(1, "PVdPB+yDglPnV0ZNm2bBKqUAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(7,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - return builder.Build(); - } - } -} - -namespace AwsLambda.Host.Core.Generated -{ - using System.CodeDom.Compiler; - using System.Runtime.CompilerServices; - using Microsoft.Extensions.DependencyInjection; - using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; - - [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OpenTelemetryLambdaApplicationExtensions - { - [InterceptsLocation(1, "PVdPB+yDglPnV0ZNm2bBKrYAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(9,8) - internal static ILambdaInvocationBuilder UseOpenTelemetryTracingInterceptor( - this ILambdaInvocationBuilder application - ) - { - return application.Use(application.Services.GetOpenTelemetryTracerNoEventNoResponse()); - } - } -} diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OtelEnabledVerifyTests.Test_OtelEnabled_OnlyEvent#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OtelEnabledVerifyTests.Test_OtelEnabled_OnlyEvent#LambdaHandler.g.verified.cs deleted file mode 100644 index e83b4c78..00000000 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OtelEnabledVerifyTests.Test_OtelEnabled_OnlyEvent#LambdaHandler.g.verified.cs +++ /dev/null @@ -1,92 +0,0 @@ -//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("AwsLambda.Host.SourceGenerators", "0.0.0")] - [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] - file sealed class InterceptsLocationAttribute : Attribute - { - public InterceptsLocationAttribute(int version, string data) - { - } - } -} - -namespace AwsLambda.Host.Core.Generated -{ - using System; - using System.CodeDom.Compiler; - using System.IO; - using System.Runtime.CompilerServices; - using System.Threading.Tasks; - using Amazon.Lambda.Core; - using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; - using Microsoft.Extensions.DependencyInjection; - - [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions - { - // Location: InputFile.cs(11,8) - [InterceptsLocation(1, "3DxEwWle1IoQD99wxHvHPdkAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( - this ILambdaInvocationBuilder application, - Delegate handler - ) - { - var castHandler = (global::System.Action)handler; - - return application.Handle(InvocationDelegate); - - Task InvocationDelegate(ILambdaHostContext context) - { - // ParameterInfo { Type = global::Request, Name = request, Source = Event, IsNullable = False, IsOptional = False} - var arg0 = context.GetRequiredEvent(); - castHandler.Invoke(arg0); - return Task.CompletedTask; - } - } - - [InterceptsLocation(1, "3DxEwWle1IoQD99wxHvHPaUAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(7,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - return builder.Build(); - } - } -} - -namespace AwsLambda.Host.Core.Generated -{ - using System.CodeDom.Compiler; - using System.Runtime.CompilerServices; - using Microsoft.Extensions.DependencyInjection; - using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; - - [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OpenTelemetryLambdaApplicationExtensions - { - [InterceptsLocation(1, "3DxEwWle1IoQD99wxHvHPbYAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(9,8) - internal static ILambdaInvocationBuilder UseOpenTelemetryTracingInterceptor( - this ILambdaInvocationBuilder application - ) - { - return application.Use(application.Services.GetOpenTelemetryTracerNoResponse()); - } - } -} diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OtelEnabledVerifyTests.Test_OtelEnabled_OnlyResponse#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OtelEnabledVerifyTests.Test_OtelEnabled_OnlyResponse#LambdaHandler.g.verified.cs deleted file mode 100644 index b6405d45..00000000 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OtelEnabledVerifyTests.Test_OtelEnabled_OnlyResponse#LambdaHandler.g.verified.cs +++ /dev/null @@ -1,95 +0,0 @@ -//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("AwsLambda.Host.SourceGenerators", "0.0.0")] - [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] - file sealed class InterceptsLocationAttribute : Attribute - { - public InterceptsLocationAttribute(int version, string data) - { - } - } -} - -namespace AwsLambda.Host.Core.Generated -{ - using System; - using System.CodeDom.Compiler; - using System.IO; - using System.Runtime.CompilerServices; - using System.Threading.Tasks; - using Amazon.Lambda.Core; - using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; - using Microsoft.Extensions.DependencyInjection; - - [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions - { - // Location: InputFile.cs(11,8) - [InterceptsLocation(1, "V1rdx21g5a+slUYwHpqULNkAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( - this ILambdaInvocationBuilder application, - Delegate handler - ) - { - var castHandler = (global::System.Func)handler; - - return application.Handle(InvocationDelegate); - - Task InvocationDelegate(ILambdaHostContext context) - { - var response = castHandler.Invoke(); - if (context.Features.Get() is not IResponseFeature responseFeature) - { - throw new InvalidOperationException($"Response feature for type 'global::Response' is not available in the collection."); - } - responseFeature.SetResponse(response); - return Task.CompletedTask; - } - } - - [InterceptsLocation(1, "V1rdx21g5a+slUYwHpqULKUAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(7,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - return builder.Build(); - } - } -} - -namespace AwsLambda.Host.Core.Generated -{ - using System.CodeDom.Compiler; - using System.Runtime.CompilerServices; - using Microsoft.Extensions.DependencyInjection; - using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; - - [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OpenTelemetryLambdaApplicationExtensions - { - [InterceptsLocation(1, "V1rdx21g5a+slUYwHpqULLYAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(9,8) - internal static ILambdaInvocationBuilder UseOpenTelemetryTracingInterceptor( - this ILambdaInvocationBuilder application - ) - { - return application.Use(application.Services.GetOpenTelemetryTracerNoEvent()); - } - } -} diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/VerifyTests/OtelEnabledVerifyTests.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/VerifyTests/OtelEnabledVerifyTests.cs deleted file mode 100644 index e1d79b26..00000000 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/VerifyTests/OtelEnabledVerifyTests.cs +++ /dev/null @@ -1,121 +0,0 @@ -namespace AwsLambda.Host.SourceGenerators.UnitTests; - -public class OtelEnabledVerifyTests -{ - [Fact] - public async Task Test_OtelEnabled_EventAndResponse() => - await GeneratorTestHelpers.Verify( - """ - using AwsLambda.Host.Core; - using AwsLambda.Host.Builder; - using Microsoft.Extensions.Hosting; - - var builder = LambdaApplication.CreateBuilder(); - - var lambda = builder.Build(); - - lambda.UseOpenTelemetryTracing(); - - lambda.MapHandler(([Event] Request request) => new Response($"Hello {request.Name}!")); - - await lambda.RunAsync(); - - record Request(string Name); - - record Response(string Message); - """ - ); - - [Fact] - public async Task Test_OtelEnabled_OnlyResponse() => - await GeneratorTestHelpers.Verify( - """ - using AwsLambda.Host.Core; - using AwsLambda.Host.Builder; - using Microsoft.Extensions.Hosting; - - var builder = LambdaApplication.CreateBuilder(); - - var lambda = builder.Build(); - - lambda.UseOpenTelemetryTracing(); - - lambda.MapHandler(() => new Response("Hello world!")); - - await lambda.RunAsync(); - - record Response(string Message); - """ - ); - - [Fact] - public async Task Test_OtelEnabled_OnlyEvent() => - await GeneratorTestHelpers.Verify( - """ - using AwsLambda.Host.Core; - using AwsLambda.Host.Builder; - using Microsoft.Extensions.Hosting; - - var builder = LambdaApplication.CreateBuilder(); - - var lambda = builder.Build(); - - lambda.UseOpenTelemetryTracing(); - - lambda.MapHandler(([Event] Request request) => { }); - - await lambda.RunAsync(); - - record Request(string Name); - """ - ); - - [Fact] - public async Task Test_OtelEnabled_NoEventNoResponse() => - await GeneratorTestHelpers.Verify( - """ - using AwsLambda.Host.Core; - using AwsLambda.Host.Builder; - using Microsoft.Extensions.Hosting; - - var builder = LambdaApplication.CreateBuilder(); - - var lambda = builder.Build(); - - lambda.UseOpenTelemetryTracing(); - - lambda.MapHandler(() => { }); - - await lambda.RunAsync(); - """ - ); - - [Fact] - public async Task Test_OtelEnabled_ExpressionLambda_DiAndAsyncAndAwait() => - await GeneratorTestHelpers.Verify( - """ - using System.Threading.Tasks; - using AwsLambda.Host.Core; - using AwsLambda.Host.Builder; - using Microsoft.Extensions.DependencyInjection; - using Microsoft.Extensions.Hosting; - - var builder = LambdaApplication.CreateBuilder(); - - var lambda = builder.Build(); - - lambda.UseOpenTelemetryTracing(); - - lambda.MapHandler( - async ([Event] string input, IService service) => (await service.GetMessage()).ToUpper() - ); - - await lambda.RunAsync(); - - public interface IService - { - Task GetMessage(); - } - """ - ); -} From ae20420ef06a527adb4f937510e995a9844122c1 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 13:58:26 -0500 Subject: [PATCH 28/48] feat(source-generators): refine MapHandler templates and improve feature provider handling - Replaced `BuildInterceptor` methods with refined `MapHandler aInvokerceptor0` for key consistency. - Introduced `EventFeatureProviderKey` & `ResponseFeatureProviderKey`, Execution dynamically setups feature providers into application properties. - Updated handling of application properties to prevent duplicating feature resolution or additions. - Adjusted template test logic to reflect event-response processing adjustments. `Simplify` . --- .../DiagnosticTests.cs | 8 +---- ...llInputSources#LambdaHandler.g.verified.cs | 25 +++++++++------ ...tring_TypeCast#LambdaHandler.g.verified.cs | 25 +++++++++------ ...eturn_TypeCast#LambdaHandler.g.verified.cs | 25 +++++++++------ ...eInfo_TypeCast#LambdaHandler.g.verified.cs | 25 +++++++++------ ...rnExplicitType#LambdaHandler.g.verified.cs | 31 ++++++++++++------- ...plicitNullable#LambdaHandler.g.verified.cs | 31 ++++++++++++------- ...a_ReturnString#LambdaHandler.g.verified.cs | 31 ++++++++++++------- ...turnTaskString#LambdaHandler.g.verified.cs | 25 +++++++++------ ...sTask_TypeCast#LambdaHandler.g.verified.cs | 19 ++++++------ ...StreamResponse#LambdaHandler.g.verified.cs | 19 ++++++------ ...ambda_TypeCast#LambdaHandler.g.verified.cs | 25 +++++++++------ ...mKeyedServices#LambdaHandler.g.verified.cs | 25 +++++++++------ ...cellationToken#LambdaHandler.g.verified.cs | 25 +++++++++------ ...dLambdaContext#LambdaHandler.g.verified.cs | 25 +++++++++------ ...bdaHostContext#LambdaHandler.g.verified.cs | 25 +++++++++------ ...rnExplicitTask#LambdaHandler.g.verified.cs | 19 ++++++------ ..._ComplexOutput#LambdaHandler.g.verified.cs | 31 ++++++++++++------- ...a_ExplicitVoid#LambdaHandler.g.verified.cs | 19 ++++++------ ..._InputDi_Async#LambdaHandler.g.verified.cs | 31 ++++++++++++------- ..._AsyncAndAwait#LambdaHandler.g.verified.cs | 31 ++++++++++++------- ...erentNamespace#LambdaHandler.g.verified.cs | 31 ++++++++++++------- ...da_InputStream#LambdaHandler.g.verified.cs | 19 ++++++------ ...Input_NoOutput#LambdaHandler.g.verified.cs | 19 ++++++------ ...nGenericObject#LambdaHandler.g.verified.cs | 25 +++++++++------ ...lablePrimitive#LambdaHandler.g.verified.cs | 25 +++++++++------ ...t_ReturnString#LambdaHandler.g.verified.cs | 25 +++++++++------ ...plicitNullable#LambdaHandler.g.verified.cs | 31 ++++++++++++------- ...plicitNullable#LambdaHandler.g.verified.cs | 31 ++++++++++++------- ...rnExplicitTask#LambdaHandler.g.verified.cs | 19 ++++++------ ...rnExplicitType#LambdaHandler.g.verified.cs | 31 ++++++++++++------- ...tingPointTypes#LambdaHandler.g.verified.cs | 19 ++++++------ ...IntAndLongKeys#LambdaHandler.g.verified.cs | 19 ++++++------ ...ice_OtherTypes#LambdaHandler.g.verified.cs | 19 ++++++------ ...llIntegerTypes#LambdaHandler.g.verified.cs | 19 ++++++------ ...ingAndEnumKeys#LambdaHandler.g.verified.cs | 19 ++++++------ ...edIntegerTypes#LambdaHandler.g.verified.cs | 19 ++++++------ ...dler_AsyncVoid#LambdaHandler.g.verified.cs | 19 ++++++------ ...turnTaskString#LambdaHandler.g.verified.cs | 25 +++++++++------ ...iKeyedServices#LambdaHandler.g.verified.cs | 31 ++++++++++++------- ...kBody_TypeCast#LambdaHandler.g.verified.cs | 25 +++++++++------ ...ypeCast_Static#LambdaHandler.g.verified.cs | 25 +++++++++------ ...Input_NoOutput#LambdaHandler.g.verified.cs | 19 ++++++------ ...ler_ReturnTask#LambdaHandler.g.verified.cs | 19 ++++++------ ...turnTaskString#LambdaHandler.g.verified.cs | 25 +++++++++------ ...traParentheses#LambdaHandler.g.verified.cs | 25 +++++++++------ 46 files changed, 651 insertions(+), 452 deletions(-) diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/DiagnosticTests.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/DiagnosticTests.cs index 0665395f..2f289aed 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/DiagnosticTests.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/DiagnosticTests.cs @@ -50,13 +50,7 @@ public void Test_MultipleMapHandlersFound() """ ); - diagnostics.Length.Should().Be(2); - - foreach (var diagnostic in diagnostics) - { - diagnostic.Id.Should().Be("LH0001"); - diagnostic.Severity.Should().Be(DiagnosticSeverity.Error); - } + diagnostics.Length.Should().Be(0); } [Fact] diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_AllInputSources#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_AllInputSources#LambdaHandler.g.verified.cs index 5ad4c776..7900f902 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_AllInputSources#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_AllInputSources#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,26 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(14,8) [InterceptsLocation(1, "wCxh64raLv7JZxUcekz6bkIBAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Action)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(EventFeatureProviderKey)) + application.Properties[EventFeatureProviderKey] = application + .Services.GetRequiredService() + .Create(); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -76,12 +88,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "wCxh64raLv7JZxUcekz6bgcBAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(10,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_Async_ReturnTaskString_TypeCast#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_Async_ReturnTaskString_TypeCast#LambdaHandler.g.verified.cs index c4a39b12..5aaacf66 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_Async_ReturnTaskString_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_Async_ReturnTaskString_TypeCast#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,26 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(9,8) [InterceptsLocation(1, "52YQ/UddFuGQH5asNzsp/L0AAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func>)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create(); + + return application; async Task InvocationDelegate(ILambdaHostContext context) { @@ -62,12 +74,5 @@ async Task InvocationDelegate(ILambdaHostContext context) responseFeature.SetResponse(response); } } - - [InterceptsLocation(1, "52YQ/UddFuGQH5asNzsp/KwAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(7,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoReturn_TypeCast#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoReturn_TypeCast#LambdaHandler.g.verified.cs index c2e41cee..387c8394 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoReturn_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoReturn_TypeCast#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,26 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(10,8) [InterceptsLocation(1, "24NtoO22UPa+/C0ogM3RV+EAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Action)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(EventFeatureProviderKey)) + application.Properties[EventFeatureProviderKey] = application + .Services.GetRequiredService() + .Create(); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -62,12 +74,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "24NtoO22UPa+/C0ogM3RV9AAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(8,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoTypeInfo_TypeCast#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoTypeInfo_TypeCast#LambdaHandler.g.verified.cs index 379207e4..f8a2b1a2 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoTypeInfo_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoTypeInfo_TypeCast#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,26 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(9,8) [InterceptsLocation(1, "jx1Tqmn1fJ3pftRGtSvbSsMAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create(); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -67,12 +79,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "jx1Tqmn1fJ3pftRGtSvbSrIAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(7,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnExplicitType#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnExplicitType#LambdaHandler.g.verified.cs index 5cd3b6b1..a832f3ec 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnExplicitType#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnExplicitType#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,31 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(9,8) [InterceptsLocation(1, "kmm35a5GJaoqey+0CeV8vdMAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(EventFeatureProviderKey)) + application.Properties[EventFeatureProviderKey] = application + .Services.GetRequiredService() + .Create(); + + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create(); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -67,13 +84,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "kmm35a5GJaoqey+0CeV8vcIAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(7,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - builder.Services.AddSingleton>(); - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnImplicitNullable#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnImplicitNullable#LambdaHandler.g.verified.cs index 4ffd7dc5..3552c46d 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnImplicitNullable#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnImplicitNullable#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,31 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(8,8) [InterceptsLocation(1, "qgvWtxWrBmeBTRBtlT5A2LUAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(EventFeatureProviderKey)) + application.Properties[EventFeatureProviderKey] = application + .Services.GetRequiredService() + .Create(); + + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create(); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -67,13 +84,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "qgvWtxWrBmeBTRBtlT5A2KQAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(6,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - builder.Services.AddSingleton>(); - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnString#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnString#LambdaHandler.g.verified.cs index f00fc235..0a7b84d8 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnString#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnString#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,31 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(8,8) [InterceptsLocation(1, "SBl4e782DgMu+0FLfrzfUbUAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(EventFeatureProviderKey)) + application.Properties[EventFeatureProviderKey] = application + .Services.GetRequiredService() + .Create(); + + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create(); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -65,13 +82,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "SBl4e782DgMu+0FLfrzfUaQAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(6,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - builder.Services.AddSingleton>(); - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnTaskString#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnTaskString#LambdaHandler.g.verified.cs index 9366ece8..bc2ffe1e 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnTaskString#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnTaskString#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,26 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(12,8) [InterceptsLocation(1, "62ICm9hMTMkVRHJf7bEM0v4AAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func>)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create(); + + return application; async Task InvocationDelegate(ILambdaHostContext context) { @@ -62,12 +74,5 @@ async Task InvocationDelegate(ILambdaHostContext context) responseFeature.SetResponse(response); } } - - [InterceptsLocation(1, "62ICm9hMTMkVRHJf7bEM0sMAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(8,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnsTask_TypeCast#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnsTask_TypeCast#LambdaHandler.g.verified.cs index f178eeaf..d5ae6c33 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnsTask_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnsTask_TypeCast#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,27 +43,26 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(9,8) [InterceptsLocation(1, "hQoB+WlSjNRKx1YwYlKZW70AAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + return application; async Task InvocationDelegate(ILambdaHostContext context) { await castHandler.Invoke(); } } - - [InterceptsLocation(1, "hQoB+WlSjNRKx1YwYlKZW6wAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(7,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_StreamResponse#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_StreamResponse#LambdaHandler.g.verified.cs index b2436e87..3ff1f5f3 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_StreamResponse#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_StreamResponse#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,21 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(10,8) [InterceptsLocation(1, "6HO/UYhbMUo2aMF5OFFj3scAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -59,11 +66,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "6HO/UYhbMUo2aMF5OFFj3rYAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(8,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast#LambdaHandler.g.verified.cs index c8671a94..112d1a82 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,26 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(9,8) [InterceptsLocation(1, "0swNLwUGxn6gmcAxLw2VYcMAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create(); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -65,12 +77,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "0swNLwUGxn6gmcAxLw2VYbIAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(7,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast_InputFromKeyedServices#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast_InputFromKeyedServices#LambdaHandler.g.verified.cs index 95b4c572..51663685 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast_InputFromKeyedServices#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast_InputFromKeyedServices#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,26 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(11,8) [InterceptsLocation(1, "Uxt0NUyaj58kybSiao2f8REBAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create(); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -69,12 +81,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "Uxt0NUyaj58kybSiao2f8QABAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(9,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationToken#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationToken#LambdaHandler.g.verified.cs index 0e7df351..9315c00c 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationToken#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationToken#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,26 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(9,8) [InterceptsLocation(1, "IG1FKecgSQVVqxQ3PHQPeM0AAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create(); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -65,12 +77,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "IG1FKecgSQVVqxQ3PHQPeLwAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(7,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaContext#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaContext#LambdaHandler.g.verified.cs index ccea80d9..98e01734 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaContext#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaContext#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,26 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(10,8) [InterceptsLocation(1, "wn/8VnbL6/5enHoptgINB+cAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create(); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -67,12 +79,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "wn/8VnbL6/5enHoptgINB9YAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(8,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaHostContext#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaHostContext#LambdaHandler.g.verified.cs index 14ff336e..c8e930e5 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaHostContext#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaHostContext#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,26 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(10,8) [InterceptsLocation(1, "f2st4QpM87EqtO+5cVLplOcAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create(); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -67,12 +79,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "f2st4QpM87EqtO+5cVLplNYAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(8,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_Async_ReturnExplicitTask#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_Async_ReturnExplicitTask#LambdaHandler.g.verified.cs index 4ab65507..7c2cedbe 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_Async_ReturnExplicitTask#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_Async_ReturnExplicitTask#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,27 +43,26 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(9,8) [InterceptsLocation(1, "cms2w+IHinDN9XOT4+diatMAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + return application; async Task InvocationDelegate(ILambdaHostContext context) { await castHandler.Invoke(); } } - - [InterceptsLocation(1, "cms2w+IHinDN9XOT4+diasIAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(7,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ComplexInput_ComplexOutput#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ComplexInput_ComplexOutput#LambdaHandler.g.verified.cs index 01400d19..2ab0d95f 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ComplexInput_ComplexOutput#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ComplexInput_ComplexOutput#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,31 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(10,8) [InterceptsLocation(1, "YAIayk0naS2HI+NqiUzlmO0AAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func>)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(EventFeatureProviderKey)) + application.Properties[EventFeatureProviderKey] = application + .Services.GetRequiredService() + .Create(); + + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create(); + + return application; async Task InvocationDelegate(ILambdaHostContext context) { @@ -68,13 +85,5 @@ async Task InvocationDelegate(ILambdaHostContext context) responseFeature.SetResponse(response); } } - - [InterceptsLocation(1, "YAIayk0naS2HI+NqiUzlmNwAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(8,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - builder.Services.AddSingleton>(); - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ExplicitVoid#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ExplicitVoid#LambdaHandler.g.verified.cs index 54625ed8..09f69165 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ExplicitVoid#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ExplicitVoid#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,21 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(11,8) [InterceptsLocation(1, "S8za7TGX8LSwYna0cXthvuAAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Action)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -58,11 +65,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "S8za7TGX8LSwYna0cXthvqUAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(7,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_Async#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_Async#LambdaHandler.g.verified.cs index d9a37a8b..9a7fdb14 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_Async#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_Async#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,31 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(9,8) [InterceptsLocation(1, "K/A2Yp4hzHbk21l61w6haLYAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func>)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(EventFeatureProviderKey)) + application.Properties[EventFeatureProviderKey] = application + .Services.GetRequiredService() + .Create(); + + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create(); + + return application; async Task InvocationDelegate(ILambdaHostContext context) { @@ -66,13 +83,5 @@ async Task InvocationDelegate(ILambdaHostContext context) responseFeature.SetResponse(response); } } - - [InterceptsLocation(1, "K/A2Yp4hzHbk21l61w6haKUAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(7,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - builder.Services.AddSingleton>(); - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait#LambdaHandler.g.verified.cs index ff4ba7d2..5a5249fa 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,31 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(10,8) [InterceptsLocation(1, "VH5MZQ3KsBJFkPsnivxIPdQAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func>)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(EventFeatureProviderKey)) + application.Properties[EventFeatureProviderKey] = application + .Services.GetRequiredService() + .Create(); + + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create(); + + return application; async Task InvocationDelegate(ILambdaHostContext context) { @@ -66,13 +83,5 @@ async Task InvocationDelegate(ILambdaHostContext context) responseFeature.SetResponse(response); } } - - [InterceptsLocation(1, "VH5MZQ3KsBJFkPsnivxIPcMAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(8,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - builder.Services.AddSingleton>(); - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait_EventAndResponseDifferentNamespace#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait_EventAndResponseDifferentNamespace#LambdaHandler.g.verified.cs index 57afef3a..2bf55c53 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait_EventAndResponseDifferentNamespace#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait_EventAndResponseDifferentNamespace#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,31 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(11,8) [InterceptsLocation(1, "2v0Mx0/EAUlNqfkx9U5JLucAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func>)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(EventFeatureProviderKey)) + application.Properties[EventFeatureProviderKey] = application + .Services.GetRequiredService() + .Create(); + + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create(); + + return application; async Task InvocationDelegate(ILambdaHostContext context) { @@ -66,13 +83,5 @@ async Task InvocationDelegate(ILambdaHostContext context) responseFeature.SetResponse(response); } } - - [InterceptsLocation(1, "2v0Mx0/EAUlNqfkx9U5JLtYAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(9,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - builder.Services.AddSingleton>(); - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputStream#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputStream#LambdaHandler.g.verified.cs index 58542a8e..26e28141 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputStream#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputStream#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,21 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(10,8) [InterceptsLocation(1, "EIytviO7ID8d+8z3oQ4Pu8cAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Action)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -60,11 +67,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "EIytviO7ID8d+8z3oQ4Pu7YAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(8,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_NoOutput#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_NoOutput#LambdaHandler.g.verified.cs index 3ed5a217..c5002d3c 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_NoOutput#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_NoOutput#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,21 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(9,8) [InterceptsLocation(1, "YIbj7XiC2amhwIlyj2HW1bYAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Action)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -58,11 +65,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "YIbj7XiC2amhwIlyj2HW1aUAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(7,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnGenericObject#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnGenericObject#LambdaHandler.g.verified.cs index 58bfca4c..fa0696c3 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnGenericObject#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnGenericObject#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,26 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(8,8) [InterceptsLocation(1, "XdsFhkLY1aZYCRYD2HXHFrUAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func>)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create>(); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -63,12 +75,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "XdsFhkLY1aZYCRYD2HXHFqQAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(6,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>>(); - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnNullablePrimitive#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnNullablePrimitive#LambdaHandler.g.verified.cs index 47ce64d1..92a0b9af 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnNullablePrimitive#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnNullablePrimitive#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,26 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(8,8) [InterceptsLocation(1, "fUFDCv62We6/lGMG9FpYS7UAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create(); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -63,12 +75,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "fUFDCv62We6/lGMG9FpYS6QAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(6,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnString#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnString#LambdaHandler.g.verified.cs index 16f6afa4..4b3c8d6b 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnString#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnString#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,26 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(9,8) [InterceptsLocation(1, "Ta7Dv3cnwIzvY2JBRc5ijLYAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create(); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -63,12 +75,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "Ta7Dv3cnwIzvY2JBRc5ijKUAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(7,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnExplicitNullable#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnExplicitNullable#LambdaHandler.g.verified.cs index 5e10cfbd..a2bf93b1 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnExplicitNullable#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnExplicitNullable#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,31 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(8,8) [InterceptsLocation(1, "xtIY1NRH4poO99GLmpoGnbUAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(EventFeatureProviderKey)) + application.Properties[EventFeatureProviderKey] = application + .Services.GetRequiredService() + .Create(); + + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create(); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -67,13 +84,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "xtIY1NRH4poO99GLmpoGnaQAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(6,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - builder.Services.AddSingleton>(); - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnImplicitNullable#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnImplicitNullable#LambdaHandler.g.verified.cs index 65a0c6c3..2e5113ab 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnImplicitNullable#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnImplicitNullable#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,31 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(8,8) [InterceptsLocation(1, "qtXEOV1k02+RkXoOA59GBrUAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(EventFeatureProviderKey)) + application.Properties[EventFeatureProviderKey] = application + .Services.GetRequiredService() + .Create(); + + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create(); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -67,13 +84,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "qtXEOV1k02+RkXoOA59GBqQAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(6,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - builder.Services.AddSingleton>(); - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitTask#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitTask#LambdaHandler.g.verified.cs index eb02a62c..99e8cd61 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitTask#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitTask#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,27 +43,26 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(9,8) [InterceptsLocation(1, "UWCFzECps5Zv/K6OoUlGmtMAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + return application; async Task InvocationDelegate(ILambdaHostContext context) { await castHandler.Invoke(); } } - - [InterceptsLocation(1, "UWCFzECps5Zv/K6OoUlGmsIAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(7,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitType#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitType#LambdaHandler.g.verified.cs index 2d04e72d..91c92f89 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitType#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitType#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,31 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(9,8) [InterceptsLocation(1, "4J9qyNm4aQaoE9yV4I7wUNMAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(EventFeatureProviderKey)) + application.Properties[EventFeatureProviderKey] = application + .Services.GetRequiredService() + .Create(); + + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create(); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -65,13 +82,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "4J9qyNm4aQaoE9yV4I7wUMIAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(7,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - builder.Services.AddSingleton>(); - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_FloatingPointTypes#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_FloatingPointTypes#LambdaHandler.g.verified.cs index 234019ae..f66b559c 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_FloatingPointTypes#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_FloatingPointTypes#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,21 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(12,8) [InterceptsLocation(1, "Zx6wWbKlfl6HcErqMOpfK2EBAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Action)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -66,11 +73,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "Zx6wWbKlfl6HcErqMOpfK1ABAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(10,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_IntAndLongKeys#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_IntAndLongKeys#LambdaHandler.g.verified.cs index 6b0c43ad..0228d78a 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_IntAndLongKeys#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_IntAndLongKeys#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,21 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(12,8) [InterceptsLocation(1, "XD0eRdQJ2xwEO5+zwdJ8IV0BAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Action)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -66,11 +73,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "XD0eRdQJ2xwEO5+zwdJ8IUwBAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(10,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_OtherTypes#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_OtherTypes#LambdaHandler.g.verified.cs index a0f23df0..b0986e17 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_OtherTypes#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_OtherTypes#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,21 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(14,8) [InterceptsLocation(1, "FPApiCPACeBSE0aOLeXmruQBAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Action)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -70,11 +77,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "FPApiCPACeBSE0aOLeXmrtMBAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(12,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_SmallIntegerTypes#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_SmallIntegerTypes#LambdaHandler.g.verified.cs index 891fa8f5..ee224c57 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_SmallIntegerTypes#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_SmallIntegerTypes#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,21 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(13,8) [InterceptsLocation(1, "N8+wyBYUokyoNUAIxBkzoqsBAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Action)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -68,11 +75,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "N8+wyBYUokyoNUAIxBkzopoBAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(11,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_StringAndEnumKeys#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_StringAndEnumKeys#LambdaHandler.g.verified.cs index b5f74e7c..f1a3f10a 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_StringAndEnumKeys#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_StringAndEnumKeys#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,21 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(13,8) [InterceptsLocation(1, "rMkFDEUYJ34h2/gSzQaFl7YBAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Action)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -68,11 +75,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "rMkFDEUYJ34h2/gSzQaFl6UBAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(11,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_UnsignedIntegerTypes#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_UnsignedIntegerTypes#LambdaHandler.g.verified.cs index 27bd35b1..d9cc473a 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_UnsignedIntegerTypes#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_UnsignedIntegerTypes#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,21 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(13,8) [InterceptsLocation(1, "3eiN2asEW2/G+R1Aj4dbcqIBAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Action)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -68,11 +75,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "3eiN2asEW2/G+R1Aj4dbcpEBAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(11,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_AsyncVoid#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_AsyncVoid#LambdaHandler.g.verified.cs index c113ebb9..4ef47bbe 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_AsyncVoid#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_AsyncVoid#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,21 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(9,8) [InterceptsLocation(1, "z6sS8Y9yXWmqDTL/J/JyOsMAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Action)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -58,11 +65,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "z6sS8Y9yXWmqDTL/J/JyOrIAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(7,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_Async_ReturnTaskString#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_Async_ReturnTaskString#LambdaHandler.g.verified.cs index d42ac9af..26a792b8 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_Async_ReturnTaskString#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_Async_ReturnTaskString#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,26 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(9,8) [InterceptsLocation(1, "W6/BEm8FxiRW0gVV9g5fFtMAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func>)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create(); + + return application; async Task InvocationDelegate(ILambdaHostContext context) { @@ -62,12 +74,5 @@ async Task InvocationDelegate(ILambdaHostContext context) responseFeature.SetResponse(response); } } - - [InterceptsLocation(1, "W6/BEm8FxiRW0gVV9g5fFsIAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(7,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_InputDiKeyedServices#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_InputDiKeyedServices#LambdaHandler.g.verified.cs index 2cf0f296..56ab10d7 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_InputDiKeyedServices#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_InputDiKeyedServices#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,31 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(11,8) [InterceptsLocation(1, "8oeVcVLGeqitmbmG/7HeZwABAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(EventFeatureProviderKey)) + application.Properties[EventFeatureProviderKey] = application + .Services.GetRequiredService() + .Create(); + + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create(); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -73,13 +90,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "8oeVcVLGeqitmbmG/7HeZ+8AAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(9,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - builder.Services.AddSingleton>(); - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast#LambdaHandler.g.verified.cs index cce8b5bf..a9eaf1fc 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,26 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(9,8) [InterceptsLocation(1, "I4oSgX2EhCjJlUv+muXhcMMAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create(); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -63,12 +75,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "I4oSgX2EhCjJlUv+muXhcLIAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(7,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast_Static#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast_Static#LambdaHandler.g.verified.cs index f8dc0021..13160267 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast_Static#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast_Static#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,26 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(9,8) [InterceptsLocation(1, "MYd9JR07N7unKiyCLFng0cMAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create(); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -63,12 +75,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "MYd9JR07N7unKiyCLFng0bIAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(7,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_NoInput_NoOutput#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_NoInput_NoOutput#LambdaHandler.g.verified.cs index 956e1a2c..272728bd 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_NoInput_NoOutput#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_NoInput_NoOutput#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,21 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(9,8) [InterceptsLocation(1, "FboZTyPPzSjZNNWYolhn08MAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Action)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -58,11 +65,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "FboZTyPPzSjZNNWYolhn07IAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(7,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTask#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTask#LambdaHandler.g.verified.cs index b752c9b0..f3764c1d 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTask#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTask#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,27 +43,26 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(9,8) [InterceptsLocation(1, "x4hOcx/Mdm3QPU6QMU8PCtMAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + return application; async Task InvocationDelegate(ILambdaHostContext context) { await castHandler.Invoke(); } } - - [InterceptsLocation(1, "x4hOcx/Mdm3QPU6QMU8PCsIAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(7,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTaskString#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTaskString#LambdaHandler.g.verified.cs index 751a00f1..b7ddd37f 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTaskString#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTaskString#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,26 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(9,8) [InterceptsLocation(1, "rezyXVdhsY66Ems4DFa9p9MAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func>)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create(); + + return application; async Task InvocationDelegate(ILambdaHostContext context) { @@ -62,12 +74,5 @@ async Task InvocationDelegate(ILambdaHostContext context) responseFeature.SetResponse(response); } } - - [InterceptsLocation(1, "rezyXVdhsY66Ems4DFa9p8IAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(7,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - return builder.Build(); - } } } diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_TypeCast_ExtraParentheses#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_TypeCast_ExtraParentheses#LambdaHandler.g.verified.cs index 961e199c..299f6699 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_TypeCast_ExtraParentheses#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_TypeCast_ExtraParentheses#LambdaHandler.g.verified.cs @@ -30,7 +30,9 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; + using System.Collections.Generic; using System.IO; + using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Amazon.Lambda.Core; @@ -41,16 +43,26 @@ namespace AwsLambda.Host.Core.Generated [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class MapHandlerLambdaApplicationExtensions { + private const string EventFeatureProviderKey = "__EventFeatureProvider"; + private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; + // Location: InputFile.cs(9,8) [InterceptsLocation(1, "3PhYgT8MPlODZy+E9raU0cMAAABJbnB1dEZpbGUuY3M=")] - internal static ILambdaInvocationBuilder MapHandlerInterceptor( + internal static ILambdaInvocationBuilder MapHandlerInterceptor0( this ILambdaInvocationBuilder application, Delegate handler ) { var castHandler = (global::System.Func)handler; - - return application.Handle(InvocationDelegate); + + application.Handle(InvocationDelegate); + + if (!application.Properties.ContainsKey(ResponseFeatureProviderKey)) + application.Properties[ResponseFeatureProviderKey] = application. + Services.GetRequiredService() + .Create(); + + return application; Task InvocationDelegate(ILambdaHostContext context) { @@ -63,12 +75,5 @@ Task InvocationDelegate(ILambdaHostContext context) return Task.CompletedTask; } } - - [InterceptsLocation(1, "3PhYgT8MPlODZy+E9raU0bIAAABJbnB1dEZpbGUuY3M=")] // Location: InputFile.cs(7,22) - internal static LambdaApplication BuildInterceptor(this LambdaApplicationBuilder builder) - { - builder.Services.AddSingleton>(); - return builder.Build(); - } } } From dcaea5c5adf93564645afc986fe984e80f545557 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 14:01:26 -0500 Subject: [PATCH 29/48] feat(lambda-host): update handler to support request-response model - Refactored `MapHandler` to use `Request` and `Response` records for structured input-output. - Improved response with a timestamped message using `DateTime.Utcreduce verbosity`. - Removed redundant `#region` directives for cleaner code structure. --- .../AwsLambda.Host.Example.HelloWorld/Program.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/AwsLambda.Host.Example.HelloWorld/Program.cs b/examples/AwsLambda.Host.Example.HelloWorld/Program.cs index e70d854e..7a1a8799 100644 --- a/examples/AwsLambda.Host.Example.HelloWorld/Program.cs +++ b/examples/AwsLambda.Host.Example.HelloWorld/Program.cs @@ -1,10 +1,7 @@ -#region - +using System; using AwsLambda.Host.Builder; using Microsoft.Extensions.Hosting; -#endregion - // Create the application builder var builder = LambdaApplication.CreateBuilder(); @@ -12,7 +9,13 @@ var lambda = builder.Build(); // Map your handler - the event is automatically injected -lambda.MapHandler(([Event] string name) => $"Hello {name}!"); +lambda.MapHandler( + ([Event] Request request) => new Response($"Hello {request.Name}!", DateTime.UtcNow) +); // Run the Lambda await lambda.RunAsync(); + +internal record Response(string Message, DateTime TimestampUtc); + +internal record Request(string Name); From f41b98835659ed380da99f24a51db7f6b3de047b Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 14:04:58 -0500 Subject: [PATCH 30/48] refactor(source-generators): remove unused imports in MapHandler template and snapshots - Cleaned up unused imports (e.g., `System.Collections.Generic`, `Amazon.Lambda.Core`) in `MapHandler.scriban` and associated test snapshots. - Simplified generated output by removing unnecessary usings for improved clarity. --- .../Templates/MapHandler.scriban | 4 ---- ...st_BlockLambda_AllInputSources#LambdaHandler.g.verified.cs | 4 ---- ...sync_ReturnTaskString_TypeCast#LambdaHandler.g.verified.cs | 4 ---- ..._BlockLambda_NoReturn_TypeCast#LambdaHandler.g.verified.cs | 4 ---- ...lockLambda_NoTypeInfo_TypeCast#LambdaHandler.g.verified.cs | 4 ---- ...BlockLambda_ReturnExplicitType#LambdaHandler.g.verified.cs | 4 ---- ...kLambda_ReturnImplicitNullable#LambdaHandler.g.verified.cs | 4 ---- ....Test_BlockLambda_ReturnString#LambdaHandler.g.verified.cs | 4 ---- ...t_BlockLambda_ReturnTaskString#LambdaHandler.g.verified.cs | 4 ---- ...ockLambda_ReturnsTask_TypeCast#LambdaHandler.g.verified.cs | 4 ---- ...est_BlockLambda_StreamResponse#LambdaHandler.g.verified.cs | 4 ---- ...ests.Test_BlockLambda_TypeCast#LambdaHandler.g.verified.cs | 4 ---- ...ypeCast_InputFromKeyedServices#LambdaHandler.g.verified.cs | 4 ---- ...ambda_AsksForCancellationToken#LambdaHandler.g.verified.cs | 4 ---- ...cellationTokenAndLambdaContext#LambdaHandler.g.verified.cs | 4 ---- ...ationTokenAndLambdaHostContext#LambdaHandler.g.verified.cs | 4 ---- ...ambda_Async_ReturnExplicitTask#LambdaHandler.g.verified.cs | 4 ---- ...bda_ComplexInput_ComplexOutput#LambdaHandler.g.verified.cs | 4 ---- ..._ExpressionLambda_ExplicitVoid#LambdaHandler.g.verified.cs | 4 ---- ...ExpressionLambda_InputDi_Async#LambdaHandler.g.verified.cs | 4 ---- ...onLambda_InputDi_AsyncAndAwait#LambdaHandler.g.verified.cs | 4 ---- ...tAndResponseDifferentNamespace#LambdaHandler.g.verified.cs | 4 ---- ...t_ExpressionLambda_InputStream#LambdaHandler.g.verified.cs | 4 ---- ...ressionLambda_NoInput_NoOutput#LambdaHandler.g.verified.cs | 4 ---- ...da_NoInput_ReturnGenericObject#LambdaHandler.g.verified.cs | 4 ---- ...oInput_ReturnNullablePrimitive#LambdaHandler.g.verified.cs | 4 ---- ...ionLambda_NoInput_ReturnString#LambdaHandler.g.verified.cs | 4 ---- ...leInput_ReturnExplicitNullable#LambdaHandler.g.verified.cs | 4 ---- ...leInput_ReturnImplicitNullable#LambdaHandler.g.verified.cs | 4 ---- ...ssionLambda_ReturnExplicitTask#LambdaHandler.g.verified.cs | 4 ---- ...ssionLambda_ReturnExplicitType#LambdaHandler.g.verified.cs | 4 ---- ...eyedService_FloatingPointTypes#LambdaHandler.g.verified.cs | 4 ---- ...st_KeyedService_IntAndLongKeys#LambdaHandler.g.verified.cs | 4 ---- ...s.Test_KeyedService_OtherTypes#LambdaHandler.g.verified.cs | 4 ---- ...KeyedService_SmallIntegerTypes#LambdaHandler.g.verified.cs | 4 ---- ...KeyedService_StringAndEnumKeys#LambdaHandler.g.verified.cs | 4 ---- ...edService_UnsignedIntegerTypes#LambdaHandler.g.verified.cs | 4 ---- ...s.Test_MethodHandler_AsyncVoid#LambdaHandler.g.verified.cs | 4 ---- ...Handler_Async_ReturnTaskString#LambdaHandler.g.verified.cs | 4 ---- ...BlockBody_InputDiKeyedServices#LambdaHandler.g.verified.cs | 4 ---- ...thodHandler_BlockBody_TypeCast#LambdaHandler.g.verified.cs | 4 ---- ...dler_BlockBody_TypeCast_Static#LambdaHandler.g.verified.cs | 4 ---- ...MethodHandler_NoInput_NoOutput#LambdaHandler.g.verified.cs | 4 ---- ....Test_MethodHandler_ReturnTask#LambdaHandler.g.verified.cs | 4 ---- ...MethodHandler_ReturnTaskString#LambdaHandler.g.verified.cs | 4 ---- ...dler_TypeCast_ExtraParentheses#LambdaHandler.g.verified.cs | 4 ---- 46 files changed, 184 deletions(-) diff --git a/src/AwsLambda.Host.SourceGenerators/Templates/MapHandler.scriban b/src/AwsLambda.Host.SourceGenerators/Templates/MapHandler.scriban index 58c5435b..e8751879 100644 --- a/src/AwsLambda.Host.SourceGenerators/Templates/MapHandler.scriban +++ b/src/AwsLambda.Host.SourceGenerators/Templates/MapHandler.scriban @@ -2,12 +2,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_AllInputSources#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_AllInputSources#LambdaHandler.g.verified.cs index 7900f902..f8f0ded6 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_AllInputSources#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_AllInputSources#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_Async_ReturnTaskString_TypeCast#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_Async_ReturnTaskString_TypeCast#LambdaHandler.g.verified.cs index 5aaacf66..f6859669 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_Async_ReturnTaskString_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_Async_ReturnTaskString_TypeCast#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoReturn_TypeCast#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoReturn_TypeCast#LambdaHandler.g.verified.cs index 387c8394..8f8cf6fc 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoReturn_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoReturn_TypeCast#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoTypeInfo_TypeCast#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoTypeInfo_TypeCast#LambdaHandler.g.verified.cs index f8a2b1a2..855f0613 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoTypeInfo_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoTypeInfo_TypeCast#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnExplicitType#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnExplicitType#LambdaHandler.g.verified.cs index a832f3ec..6073353b 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnExplicitType#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnExplicitType#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnImplicitNullable#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnImplicitNullable#LambdaHandler.g.verified.cs index 3552c46d..2792bbbd 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnImplicitNullable#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnImplicitNullable#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnString#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnString#LambdaHandler.g.verified.cs index 0a7b84d8..29a6d3a4 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnString#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnString#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnTaskString#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnTaskString#LambdaHandler.g.verified.cs index bc2ffe1e..53567186 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnTaskString#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnTaskString#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnsTask_TypeCast#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnsTask_TypeCast#LambdaHandler.g.verified.cs index d5ae6c33..6ac10d34 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnsTask_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnsTask_TypeCast#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_StreamResponse#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_StreamResponse#LambdaHandler.g.verified.cs index 3ff1f5f3..75c16f2d 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_StreamResponse#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_StreamResponse#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast#LambdaHandler.g.verified.cs index 112d1a82..0ecfa23b 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast_InputFromKeyedServices#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast_InputFromKeyedServices#LambdaHandler.g.verified.cs index 51663685..a11c6a48 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast_InputFromKeyedServices#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast_InputFromKeyedServices#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationToken#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationToken#LambdaHandler.g.verified.cs index 9315c00c..28e19eec 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationToken#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationToken#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaContext#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaContext#LambdaHandler.g.verified.cs index 98e01734..185bf137 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaContext#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaContext#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaHostContext#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaHostContext#LambdaHandler.g.verified.cs index c8e930e5..d5db7ca8 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaHostContext#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaHostContext#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_Async_ReturnExplicitTask#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_Async_ReturnExplicitTask#LambdaHandler.g.verified.cs index 7c2cedbe..fe5543b3 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_Async_ReturnExplicitTask#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_Async_ReturnExplicitTask#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ComplexInput_ComplexOutput#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ComplexInput_ComplexOutput#LambdaHandler.g.verified.cs index 2ab0d95f..6b7e695b 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ComplexInput_ComplexOutput#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ComplexInput_ComplexOutput#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ExplicitVoid#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ExplicitVoid#LambdaHandler.g.verified.cs index 09f69165..91ec3a5c 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ExplicitVoid#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ExplicitVoid#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_Async#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_Async#LambdaHandler.g.verified.cs index 9a7fdb14..a85670a1 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_Async#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_Async#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait#LambdaHandler.g.verified.cs index 5a5249fa..3b13463e 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait_EventAndResponseDifferentNamespace#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait_EventAndResponseDifferentNamespace#LambdaHandler.g.verified.cs index 2bf55c53..79e6c268 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait_EventAndResponseDifferentNamespace#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait_EventAndResponseDifferentNamespace#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputStream#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputStream#LambdaHandler.g.verified.cs index 26e28141..64c27af7 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputStream#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputStream#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_NoOutput#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_NoOutput#LambdaHandler.g.verified.cs index c5002d3c..4cb1ed70 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_NoOutput#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_NoOutput#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnGenericObject#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnGenericObject#LambdaHandler.g.verified.cs index fa0696c3..513ce771 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnGenericObject#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnGenericObject#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnNullablePrimitive#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnNullablePrimitive#LambdaHandler.g.verified.cs index 92a0b9af..a7d2a97b 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnNullablePrimitive#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnNullablePrimitive#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnString#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnString#LambdaHandler.g.verified.cs index 4b3c8d6b..26f9c9ac 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnString#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnString#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnExplicitNullable#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnExplicitNullable#LambdaHandler.g.verified.cs index a2bf93b1..322cdbf2 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnExplicitNullable#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnExplicitNullable#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnImplicitNullable#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnImplicitNullable#LambdaHandler.g.verified.cs index 2e5113ab..da62a57d 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnImplicitNullable#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnImplicitNullable#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitTask#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitTask#LambdaHandler.g.verified.cs index 99e8cd61..dd5fe922 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitTask#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitTask#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitType#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitType#LambdaHandler.g.verified.cs index 91c92f89..e91b9bee 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitType#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitType#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_FloatingPointTypes#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_FloatingPointTypes#LambdaHandler.g.verified.cs index f66b559c..78816fc4 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_FloatingPointTypes#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_FloatingPointTypes#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_IntAndLongKeys#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_IntAndLongKeys#LambdaHandler.g.verified.cs index 0228d78a..e5a602de 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_IntAndLongKeys#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_IntAndLongKeys#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_OtherTypes#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_OtherTypes#LambdaHandler.g.verified.cs index b0986e17..a06bd1b6 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_OtherTypes#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_OtherTypes#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_SmallIntegerTypes#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_SmallIntegerTypes#LambdaHandler.g.verified.cs index ee224c57..3c09ab66 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_SmallIntegerTypes#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_SmallIntegerTypes#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_StringAndEnumKeys#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_StringAndEnumKeys#LambdaHandler.g.verified.cs index f1a3f10a..4b6c2469 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_StringAndEnumKeys#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_StringAndEnumKeys#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_UnsignedIntegerTypes#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_UnsignedIntegerTypes#LambdaHandler.g.verified.cs index d9cc473a..a012596b 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_UnsignedIntegerTypes#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_UnsignedIntegerTypes#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_AsyncVoid#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_AsyncVoid#LambdaHandler.g.verified.cs index 4ef47bbe..63df0c2b 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_AsyncVoid#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_AsyncVoid#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_Async_ReturnTaskString#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_Async_ReturnTaskString#LambdaHandler.g.verified.cs index 26a792b8..a826608e 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_Async_ReturnTaskString#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_Async_ReturnTaskString#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_InputDiKeyedServices#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_InputDiKeyedServices#LambdaHandler.g.verified.cs index 56ab10d7..821c4014 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_InputDiKeyedServices#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_InputDiKeyedServices#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast#LambdaHandler.g.verified.cs index a9eaf1fc..1603f602 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast_Static#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast_Static#LambdaHandler.g.verified.cs index 13160267..de2c4208 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast_Static#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast_Static#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_NoInput_NoOutput#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_NoInput_NoOutput#LambdaHandler.g.verified.cs index 272728bd..a383c4d3 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_NoInput_NoOutput#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_NoInput_NoOutput#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTask#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTask#LambdaHandler.g.verified.cs index f3764c1d..8dbda5d7 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTask#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTask#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTaskString#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTaskString#LambdaHandler.g.verified.cs index b7ddd37f..9aaab077 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTaskString#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTaskString#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_TypeCast_ExtraParentheses#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_TypeCast_ExtraParentheses#LambdaHandler.g.verified.cs index 299f6699..5516d2e6 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_TypeCast_ExtraParentheses#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_TypeCast_ExtraParentheses#LambdaHandler.g.verified.cs @@ -30,12 +30,8 @@ namespace AwsLambda.Host.Core.Generated { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; - using System.IO; - using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using Amazon.Lambda.Core; using AwsLambda.Host.Builder; using AwsLambda.Host.Core; using Microsoft.Extensions.DependencyInjection; From 0c08a27c06597f5e24145c3600fa24ba7be94a19 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 14:05:57 -0500 Subject: [PATCH 31/48] refactor(source-generators): rename MapHandler class to clarify its purpose - Renamed `MapHandlerLambdaApplicationExtensions` to `GeneratedLambdaInvocationBuilderExtensions`. - Improved class naming to better reflect its role in generated lambda invocation handling. --- .../Templates/MapHandler.scriban | 2 +- ...Test_BlockLambda_AllInputSources#LambdaHandler.g.verified.cs | 2 +- ..._Async_ReturnTaskString_TypeCast#LambdaHandler.g.verified.cs | 2 +- ...st_BlockLambda_NoReturn_TypeCast#LambdaHandler.g.verified.cs | 2 +- ..._BlockLambda_NoTypeInfo_TypeCast#LambdaHandler.g.verified.cs | 2 +- ...t_BlockLambda_ReturnExplicitType#LambdaHandler.g.verified.cs | 2 +- ...ockLambda_ReturnImplicitNullable#LambdaHandler.g.verified.cs | 2 +- ...ts.Test_BlockLambda_ReturnString#LambdaHandler.g.verified.cs | 2 +- ...est_BlockLambda_ReturnTaskString#LambdaHandler.g.verified.cs | 2 +- ...BlockLambda_ReturnsTask_TypeCast#LambdaHandler.g.verified.cs | 2 +- ....Test_BlockLambda_StreamResponse#LambdaHandler.g.verified.cs | 2 +- ...yTests.Test_BlockLambda_TypeCast#LambdaHandler.g.verified.cs | 2 +- ..._TypeCast_InputFromKeyedServices#LambdaHandler.g.verified.cs | 2 +- ...nLambda_AsksForCancellationToken#LambdaHandler.g.verified.cs | 2 +- ...ancellationTokenAndLambdaContext#LambdaHandler.g.verified.cs | 2 +- ...llationTokenAndLambdaHostContext#LambdaHandler.g.verified.cs | 2 +- ...nLambda_Async_ReturnExplicitTask#LambdaHandler.g.verified.cs | 2 +- ...ambda_ComplexInput_ComplexOutput#LambdaHandler.g.verified.cs | 2 +- ...st_ExpressionLambda_ExplicitVoid#LambdaHandler.g.verified.cs | 2 +- ...t_ExpressionLambda_InputDi_Async#LambdaHandler.g.verified.cs | 2 +- ...sionLambda_InputDi_AsyncAndAwait#LambdaHandler.g.verified.cs | 2 +- ...entAndResponseDifferentNamespace#LambdaHandler.g.verified.cs | 2 +- ...est_ExpressionLambda_InputStream#LambdaHandler.g.verified.cs | 2 +- ...xpressionLambda_NoInput_NoOutput#LambdaHandler.g.verified.cs | 2 +- ...mbda_NoInput_ReturnGenericObject#LambdaHandler.g.verified.cs | 2 +- ..._NoInput_ReturnNullablePrimitive#LambdaHandler.g.verified.cs | 2 +- ...ssionLambda_NoInput_ReturnString#LambdaHandler.g.verified.cs | 2 +- ...ableInput_ReturnExplicitNullable#LambdaHandler.g.verified.cs | 2 +- ...ableInput_ReturnImplicitNullable#LambdaHandler.g.verified.cs | 2 +- ...ressionLambda_ReturnExplicitTask#LambdaHandler.g.verified.cs | 2 +- ...ressionLambda_ReturnExplicitType#LambdaHandler.g.verified.cs | 2 +- ..._KeyedService_FloatingPointTypes#LambdaHandler.g.verified.cs | 2 +- ...Test_KeyedService_IntAndLongKeys#LambdaHandler.g.verified.cs | 2 +- ...sts.Test_KeyedService_OtherTypes#LambdaHandler.g.verified.cs | 2 +- ...t_KeyedService_SmallIntegerTypes#LambdaHandler.g.verified.cs | 2 +- ...t_KeyedService_StringAndEnumKeys#LambdaHandler.g.verified.cs | 2 +- ...eyedService_UnsignedIntegerTypes#LambdaHandler.g.verified.cs | 2 +- ...sts.Test_MethodHandler_AsyncVoid#LambdaHandler.g.verified.cs | 2 +- ...odHandler_Async_ReturnTaskString#LambdaHandler.g.verified.cs | 2 +- ...r_BlockBody_InputDiKeyedServices#LambdaHandler.g.verified.cs | 2 +- ...MethodHandler_BlockBody_TypeCast#LambdaHandler.g.verified.cs | 2 +- ...andler_BlockBody_TypeCast_Static#LambdaHandler.g.verified.cs | 2 +- ...t_MethodHandler_NoInput_NoOutput#LambdaHandler.g.verified.cs | 2 +- ...ts.Test_MethodHandler_ReturnTask#LambdaHandler.g.verified.cs | 2 +- ...t_MethodHandler_ReturnTaskString#LambdaHandler.g.verified.cs | 2 +- ...andler_TypeCast_ExtraParentheses#LambdaHandler.g.verified.cs | 2 +- 46 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/AwsLambda.Host.SourceGenerators/Templates/MapHandler.scriban b/src/AwsLambda.Host.SourceGenerators/Templates/MapHandler.scriban index e8751879..d60d1c94 100644 --- a/src/AwsLambda.Host.SourceGenerators/Templates/MapHandler.scriban +++ b/src/AwsLambda.Host.SourceGenerators/Templates/MapHandler.scriban @@ -9,7 +9,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; {{ generated_code_attribute }} - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_AllInputSources#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_AllInputSources#LambdaHandler.g.verified.cs index f8f0ded6..9bec200a 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_AllInputSources#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_AllInputSources#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_Async_ReturnTaskString_TypeCast#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_Async_ReturnTaskString_TypeCast#LambdaHandler.g.verified.cs index f6859669..2822f220 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_Async_ReturnTaskString_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_Async_ReturnTaskString_TypeCast#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoReturn_TypeCast#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoReturn_TypeCast#LambdaHandler.g.verified.cs index 8f8cf6fc..3d363f12 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoReturn_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoReturn_TypeCast#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoTypeInfo_TypeCast#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoTypeInfo_TypeCast#LambdaHandler.g.verified.cs index 855f0613..6c37b765 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoTypeInfo_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoTypeInfo_TypeCast#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnExplicitType#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnExplicitType#LambdaHandler.g.verified.cs index 6073353b..447689f9 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnExplicitType#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnExplicitType#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnImplicitNullable#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnImplicitNullable#LambdaHandler.g.verified.cs index 2792bbbd..0410bb7b 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnImplicitNullable#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnImplicitNullable#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnString#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnString#LambdaHandler.g.verified.cs index 29a6d3a4..e2ca8757 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnString#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnString#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnTaskString#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnTaskString#LambdaHandler.g.verified.cs index 53567186..b51ae0fc 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnTaskString#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnTaskString#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnsTask_TypeCast#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnsTask_TypeCast#LambdaHandler.g.verified.cs index 6ac10d34..f75bd5b0 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnsTask_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnsTask_TypeCast#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_StreamResponse#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_StreamResponse#LambdaHandler.g.verified.cs index 75c16f2d..d39dfe67 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_StreamResponse#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_StreamResponse#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast#LambdaHandler.g.verified.cs index 0ecfa23b..15af876e 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast_InputFromKeyedServices#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast_InputFromKeyedServices#LambdaHandler.g.verified.cs index a11c6a48..ae5c5d4c 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast_InputFromKeyedServices#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast_InputFromKeyedServices#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationToken#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationToken#LambdaHandler.g.verified.cs index 28e19eec..91c2af82 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationToken#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationToken#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaContext#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaContext#LambdaHandler.g.verified.cs index 185bf137..3c4fe28d 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaContext#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaContext#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaHostContext#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaHostContext#LambdaHandler.g.verified.cs index d5db7ca8..99f4180c 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaHostContext#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaHostContext#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_Async_ReturnExplicitTask#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_Async_ReturnExplicitTask#LambdaHandler.g.verified.cs index fe5543b3..cb67dd68 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_Async_ReturnExplicitTask#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_Async_ReturnExplicitTask#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ComplexInput_ComplexOutput#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ComplexInput_ComplexOutput#LambdaHandler.g.verified.cs index 6b7e695b..1f5e12be 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ComplexInput_ComplexOutput#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ComplexInput_ComplexOutput#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ExplicitVoid#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ExplicitVoid#LambdaHandler.g.verified.cs index 91ec3a5c..b9127749 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ExplicitVoid#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ExplicitVoid#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_Async#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_Async#LambdaHandler.g.verified.cs index a85670a1..a688a8ba 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_Async#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_Async#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait#LambdaHandler.g.verified.cs index 3b13463e..64622794 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait_EventAndResponseDifferentNamespace#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait_EventAndResponseDifferentNamespace#LambdaHandler.g.verified.cs index 79e6c268..f6621812 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait_EventAndResponseDifferentNamespace#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait_EventAndResponseDifferentNamespace#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputStream#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputStream#LambdaHandler.g.verified.cs index 64c27af7..71622551 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputStream#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputStream#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_NoOutput#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_NoOutput#LambdaHandler.g.verified.cs index 4cb1ed70..2e7f3425 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_NoOutput#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_NoOutput#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnGenericObject#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnGenericObject#LambdaHandler.g.verified.cs index 513ce771..e4ddccae 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnGenericObject#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnGenericObject#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnNullablePrimitive#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnNullablePrimitive#LambdaHandler.g.verified.cs index a7d2a97b..b56aa222 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnNullablePrimitive#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnNullablePrimitive#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnString#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnString#LambdaHandler.g.verified.cs index 26f9c9ac..1c0443c1 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnString#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnString#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnExplicitNullable#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnExplicitNullable#LambdaHandler.g.verified.cs index 322cdbf2..3915a303 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnExplicitNullable#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnExplicitNullable#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnImplicitNullable#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnImplicitNullable#LambdaHandler.g.verified.cs index da62a57d..4291d3bb 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnImplicitNullable#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnImplicitNullable#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitTask#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitTask#LambdaHandler.g.verified.cs index dd5fe922..742b789b 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitTask#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitTask#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitType#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitType#LambdaHandler.g.verified.cs index e91b9bee..16eb612f 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitType#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitType#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_FloatingPointTypes#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_FloatingPointTypes#LambdaHandler.g.verified.cs index 78816fc4..dbbc06aa 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_FloatingPointTypes#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_FloatingPointTypes#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_IntAndLongKeys#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_IntAndLongKeys#LambdaHandler.g.verified.cs index e5a602de..6f7e81db 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_IntAndLongKeys#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_IntAndLongKeys#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_OtherTypes#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_OtherTypes#LambdaHandler.g.verified.cs index a06bd1b6..55a711ad 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_OtherTypes#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_OtherTypes#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_SmallIntegerTypes#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_SmallIntegerTypes#LambdaHandler.g.verified.cs index 3c09ab66..5ef64501 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_SmallIntegerTypes#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_SmallIntegerTypes#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_StringAndEnumKeys#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_StringAndEnumKeys#LambdaHandler.g.verified.cs index 4b6c2469..c4c66f24 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_StringAndEnumKeys#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_StringAndEnumKeys#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_UnsignedIntegerTypes#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_UnsignedIntegerTypes#LambdaHandler.g.verified.cs index a012596b..94940e25 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_UnsignedIntegerTypes#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_UnsignedIntegerTypes#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_AsyncVoid#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_AsyncVoid#LambdaHandler.g.verified.cs index 63df0c2b..d680e850 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_AsyncVoid#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_AsyncVoid#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_Async_ReturnTaskString#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_Async_ReturnTaskString#LambdaHandler.g.verified.cs index a826608e..e0ae781e 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_Async_ReturnTaskString#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_Async_ReturnTaskString#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_InputDiKeyedServices#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_InputDiKeyedServices#LambdaHandler.g.verified.cs index 821c4014..e73ca3cb 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_InputDiKeyedServices#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_InputDiKeyedServices#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast#LambdaHandler.g.verified.cs index 1603f602..5650dddd 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast_Static#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast_Static#LambdaHandler.g.verified.cs index de2c4208..7ceff931 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast_Static#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast_Static#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_NoInput_NoOutput#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_NoInput_NoOutput#LambdaHandler.g.verified.cs index a383c4d3..6280b42d 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_NoInput_NoOutput#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_NoInput_NoOutput#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTask#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTask#LambdaHandler.g.verified.cs index 8dbda5d7..7019b5bd 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTask#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTask#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTaskString#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTaskString#LambdaHandler.g.verified.cs index 9aaab077..65925787 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTaskString#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTaskString#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_TypeCast_ExtraParentheses#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_TypeCast_ExtraParentheses#LambdaHandler.g.verified.cs index 5516d2e6..de5c2b88 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_TypeCast_ExtraParentheses#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_TypeCast_ExtraParentheses#LambdaHandler.g.verified.cs @@ -37,7 +37,7 @@ namespace AwsLambda.Host.Core.Generated using Microsoft.Extensions.DependencyInjection; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class MapHandlerLambdaApplicationExtensions + file static class GeneratedLambdaInvocationBuilderExtensions { private const string EventFeatureProviderKey = "__EventFeatureProvider"; private const string ResponseFeatureProviderKey = "__ResponseFeatureProvider"; From c430befb31a8dfd82d415c6dc94bbb0310027b67 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 14:08:02 -0500 Subject: [PATCH 32/48] refactor(source-generators): remove OpenTelemetry tracing template - Deleted `OpenTelemetry.scriban` template for unused tracing logic and related code generation. - Simplified source generator output by removing OpenTelemetry integrations. --- .../Templates/OpenTelemetry.scriban | 30 ------------------- 1 file changed, 30 deletions(-) delete mode 100644 src/AwsLambda.Host.SourceGenerators/Templates/OpenTelemetry.scriban diff --git a/src/AwsLambda.Host.SourceGenerators/Templates/OpenTelemetry.scriban b/src/AwsLambda.Host.SourceGenerators/Templates/OpenTelemetry.scriban deleted file mode 100644 index 5f70b754..00000000 --- a/src/AwsLambda.Host.SourceGenerators/Templates/OpenTelemetry.scriban +++ /dev/null @@ -1,30 +0,0 @@ -namespace AwsLambda.Host.Core.Generated -{ - using System.CodeDom.Compiler; - using System.Runtime.CompilerServices; - using Microsoft.Extensions.DependencyInjection; - using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; - - {{ generated_code_attribute }} - file static class OpenTelemetryLambdaApplicationExtensions - { - {{~ for location in locations ~}} - [InterceptsLocation({{ location.version }}, "{{ location.data }}")] // Location: {{ location.display_location }} - {{~ end ~}} - internal static ILambdaInvocationBuilder UseOpenTelemetryTracingInterceptor( - this ILambdaInvocationBuilder application - ) - { - {{~ if response_type != null && event_type != null ~}} - return application.Use(application.Services.GetOpenTelemetryTracer<{{ event_type }}, {{ response_type }}>()); - {{~ else if response_type != null ~}} - return application.Use(application.Services.GetOpenTelemetryTracerNoEvent<{{ response_type }}>()); - {{~ else if event_type != null ~}} - return application.Use(application.Services.GetOpenTelemetryTracerNoResponse<{{ event_type }}>()); - {{~ else ~}} - return application.Use(application.Services.GetOpenTelemetryTracerNoEventNoResponse()); - {{~ end ~}} - } - } -} From 6f869ab31a07675126547e05c3f80ca7bbcc1a49 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 14:08:14 -0500 Subject: [PATCH 33/48] refactor(source-generators): rename extension classes for consistency - Updated class names in test snapshots and templates: - `OnInitLambdaApplicationExtensions` -> `GeneratedLambdaOnInitBuilderExtensions`. - `OnShutdownLambdaApplicationExtensions` -> `GeneratedLambdaOnShutdownBuilderExtensions`. - Improved naming clarity to align with generated output standards. --- .../Templates/GenericHandler.scriban | 2 +- ...t_OnInit_ExplicitReturnTypeAsync#LambdaHandler.g.verified.cs | 2 +- ..._OnInit_MethodHandler_AsyncAndDi#LambdaHandler.g.verified.cs | 2 +- ...syncAndDiAndReturnUnexpectedType#LambdaHandler.g.verified.cs | 2 +- ...s.Test_OnInit_MethodHandler_NoDi#LambdaHandler.g.verified.cs | 2 +- ...yTests.Test_OnInit_MultipleCalls#LambdaHandler.g.verified.cs | 2 +- ...sts.Test_OnInit_NoInput_NoOutput#LambdaHandler.g.verified.cs | 2 +- ...t_OnInit_NoInput_ReturnAsyncBool#LambdaHandler.g.verified.cs | 2 +- ...s.Test_OnInit_NoInput_ReturnBool#LambdaHandler.g.verified.cs | 2 +- ...it_NoInput_ReturnNotExpectedType#LambdaHandler.g.verified.cs | 2 +- ...Input_ReturnNotExpectedTypeAsync#LambdaHandler.g.verified.cs | 2 +- ...oInput_ReturnNotExpectedTypeTask#LambdaHandler.g.verified.cs | 2 +- ...st_OnInit_NoInput_ReturnTaskBool#LambdaHandler.g.verified.cs | 2 +- ..._NullableValueAndReferenceInputs#LambdaHandler.g.verified.cs | 2 +- ...nit_OneOfEachPossibleKindOfInput#LambdaHandler.g.verified.cs | 2 +- ...Tests.Test_OnInit_PrimitiveInput#LambdaHandler.g.verified.cs | 2 +- ..._BlockLambda_ReturnsImplicitVoid#LambdaHandler.g.verified.cs | 2 +- ...ts.Test_OnShutdown_MultipleCalls#LambdaHandler.g.verified.cs | 2 +- ...ifyTests.Test_OnShutdown_NoInput#LambdaHandler.g.verified.cs | 2 +- ...own_NoInput_ReturnUnexpectedType#LambdaHandler.g.verified.cs | 2 +- ...oInput_ReturnUnexpectedTypeAsync#LambdaHandler.g.verified.cs | 2 +- ...NoInput_ReturnUnexpectedTypeTask#LambdaHandler.g.verified.cs | 2 +- ..._NullableValueAndReferenceInputs#LambdaHandler.g.verified.cs | 2 +- ...own_OneOfEachPossibleKindOfInput#LambdaHandler.g.verified.cs | 2 +- ...s.Test_OnShutdown_PrimitiveInput#LambdaHandler.g.verified.cs | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/AwsLambda.Host.SourceGenerators/Templates/GenericHandler.scriban b/src/AwsLambda.Host.SourceGenerators/Templates/GenericHandler.scriban index 1cfd8746..9352d55b 100644 --- a/src/AwsLambda.Host.SourceGenerators/Templates/GenericHandler.scriban +++ b/src/AwsLambda.Host.SourceGenerators/Templates/GenericHandler.scriban @@ -10,7 +10,7 @@ namespace AwsLambda.Host.Core.Generated using AwsLambda.Host.Core; {{ generated_code_attribute }} - file static class {{ name }}LambdaApplicationExtensions + file static class GeneratedLambda{{ name }}BuilderExtensions { {{~ for call in calls ~}} // Location: {{ call.location.display_location }} diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_ExplicitReturnTypeAsync#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_ExplicitReturnTypeAsync#LambdaHandler.g.verified.cs index bdda4c75..22ccb053 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_ExplicitReturnTypeAsync#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_ExplicitReturnTypeAsync#LambdaHandler.g.verified.cs @@ -38,7 +38,7 @@ namespace AwsLambda.Host.Core.Generated using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OnInitLambdaApplicationExtensions + file static class GeneratedLambdaOnInitBuilderExtensions { // Location: InputFile.cs(10,8) [InterceptsLocation(1, "B75vzDHbMAaDhY3yPDqta9QAAABJbnB1dEZpbGUuY3M=")] diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_AsyncAndDi#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_AsyncAndDi#LambdaHandler.g.verified.cs index 20e3a5b9..74de79d3 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_AsyncAndDi#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_AsyncAndDi#LambdaHandler.g.verified.cs @@ -38,7 +38,7 @@ namespace AwsLambda.Host.Core.Generated using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OnInitLambdaApplicationExtensions + file static class GeneratedLambdaOnInitBuilderExtensions { // Location: InputFile.cs(10,8) [InterceptsLocation(1, "kxwv6MRO7ICWs0/b3FHQYdQAAABJbnB1dEZpbGUuY3M=")] diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_AsyncAndDiAndReturnUnexpectedType#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_AsyncAndDiAndReturnUnexpectedType#LambdaHandler.g.verified.cs index c81a8183..996efaea 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_AsyncAndDiAndReturnUnexpectedType#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_AsyncAndDiAndReturnUnexpectedType#LambdaHandler.g.verified.cs @@ -38,7 +38,7 @@ namespace AwsLambda.Host.Core.Generated using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OnInitLambdaApplicationExtensions + file static class GeneratedLambdaOnInitBuilderExtensions { // Location: InputFile.cs(10,8) [InterceptsLocation(1, "0/e3oTWVwerLdIUT9JSUddQAAABJbnB1dEZpbGUuY3M=")] diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_NoDi#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_NoDi#LambdaHandler.g.verified.cs index 67c410a8..0fd2a644 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_NoDi#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_NoDi#LambdaHandler.g.verified.cs @@ -38,7 +38,7 @@ namespace AwsLambda.Host.Core.Generated using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OnInitLambdaApplicationExtensions + file static class GeneratedLambdaOnInitBuilderExtensions { // Location: InputFile.cs(12,8) [InterceptsLocation(1, "J+znASUyU6XOeL5I7F4a2u4AAABJbnB1dEZpbGUuY3M=")] diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MultipleCalls#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MultipleCalls#LambdaHandler.g.verified.cs index e4527253..7b35ca26 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MultipleCalls#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MultipleCalls#LambdaHandler.g.verified.cs @@ -38,7 +38,7 @@ namespace AwsLambda.Host.Core.Generated using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OnInitLambdaApplicationExtensions + file static class GeneratedLambdaOnInitBuilderExtensions { // Location: InputFile.cs(10,8) [InterceptsLocation(1, "WS5xwmfdbttlkCDwmVN/4dQAAABJbnB1dEZpbGUuY3M=")] diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_NoOutput#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_NoOutput#LambdaHandler.g.verified.cs index cb450aee..e6640281 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_NoOutput#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_NoOutput#LambdaHandler.g.verified.cs @@ -38,7 +38,7 @@ namespace AwsLambda.Host.Core.Generated using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OnInitLambdaApplicationExtensions + file static class GeneratedLambdaOnInitBuilderExtensions { // Location: InputFile.cs(10,8) [InterceptsLocation(1, "DJFXn3qtRzPpemNQ7yH2j9QAAABJbnB1dEZpbGUuY3M=")] diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnAsyncBool#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnAsyncBool#LambdaHandler.g.verified.cs index 2a8d7121..d0f8662f 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnAsyncBool#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnAsyncBool#LambdaHandler.g.verified.cs @@ -38,7 +38,7 @@ namespace AwsLambda.Host.Core.Generated using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OnInitLambdaApplicationExtensions + file static class GeneratedLambdaOnInitBuilderExtensions { // Location: InputFile.cs(10,8) [InterceptsLocation(1, "/9UlP4Hk4OFxTvOz4lI3ztQAAABJbnB1dEZpbGUuY3M=")] diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnBool#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnBool#LambdaHandler.g.verified.cs index 2000a21e..6986ea71 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnBool#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnBool#LambdaHandler.g.verified.cs @@ -38,7 +38,7 @@ namespace AwsLambda.Host.Core.Generated using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OnInitLambdaApplicationExtensions + file static class GeneratedLambdaOnInitBuilderExtensions { // Location: InputFile.cs(10,8) [InterceptsLocation(1, "bfzzWql3BD1qSjdb9bBzM9QAAABJbnB1dEZpbGUuY3M=")] diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedType#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedType#LambdaHandler.g.verified.cs index 72b2ddfe..3e45563a 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedType#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedType#LambdaHandler.g.verified.cs @@ -38,7 +38,7 @@ namespace AwsLambda.Host.Core.Generated using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OnInitLambdaApplicationExtensions + file static class GeneratedLambdaOnInitBuilderExtensions { // Location: InputFile.cs(10,8) [InterceptsLocation(1, "4+YRMciUNXwEwXhvIACxZ9QAAABJbnB1dEZpbGUuY3M=")] diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedTypeAsync#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedTypeAsync#LambdaHandler.g.verified.cs index 08f4aca8..b0e3962f 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedTypeAsync#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedTypeAsync#LambdaHandler.g.verified.cs @@ -38,7 +38,7 @@ namespace AwsLambda.Host.Core.Generated using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OnInitLambdaApplicationExtensions + file static class GeneratedLambdaOnInitBuilderExtensions { // Location: InputFile.cs(10,8) [InterceptsLocation(1, "NcMerHwPBzsgxA7y/XPnH9QAAABJbnB1dEZpbGUuY3M=")] diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedTypeTask#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedTypeTask#LambdaHandler.g.verified.cs index 47a52c64..60965e57 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedTypeTask#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedTypeTask#LambdaHandler.g.verified.cs @@ -38,7 +38,7 @@ namespace AwsLambda.Host.Core.Generated using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OnInitLambdaApplicationExtensions + file static class GeneratedLambdaOnInitBuilderExtensions { // Location: InputFile.cs(10,8) [InterceptsLocation(1, "9fSKeCRgj7MIXk9wvEO289QAAABJbnB1dEZpbGUuY3M=")] diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnTaskBool#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnTaskBool#LambdaHandler.g.verified.cs index 7f927e91..968bf716 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnTaskBool#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnTaskBool#LambdaHandler.g.verified.cs @@ -38,7 +38,7 @@ namespace AwsLambda.Host.Core.Generated using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OnInitLambdaApplicationExtensions + file static class GeneratedLambdaOnInitBuilderExtensions { // Location: InputFile.cs(10,8) [InterceptsLocation(1, "CDEFUo2VYVYEIicqNdjtudQAAABJbnB1dEZpbGUuY3M=")] diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NullableValueAndReferenceInputs#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NullableValueAndReferenceInputs#LambdaHandler.g.verified.cs index b690191b..6fb1e8aa 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NullableValueAndReferenceInputs#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NullableValueAndReferenceInputs#LambdaHandler.g.verified.cs @@ -38,7 +38,7 @@ namespace AwsLambda.Host.Core.Generated using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OnInitLambdaApplicationExtensions + file static class GeneratedLambdaOnInitBuilderExtensions { // Location: InputFile.cs(10,8) [InterceptsLocation(1, "r7SIx1Ceo55ncYApA9O0wtQAAABJbnB1dEZpbGUuY3M=")] diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_OneOfEachPossibleKindOfInput#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_OneOfEachPossibleKindOfInput#LambdaHandler.g.verified.cs index d146c748..5bd77421 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_OneOfEachPossibleKindOfInput#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_OneOfEachPossibleKindOfInput#LambdaHandler.g.verified.cs @@ -38,7 +38,7 @@ namespace AwsLambda.Host.Core.Generated using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OnInitLambdaApplicationExtensions + file static class GeneratedLambdaOnInitBuilderExtensions { // Location: InputFile.cs(12,8) [InterceptsLocation(1, "mD/AfkPVjS93ZD5vENLVJBwBAABJbnB1dEZpbGUuY3M=")] diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_PrimitiveInput#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_PrimitiveInput#LambdaHandler.g.verified.cs index d95d0d13..d91fa3f7 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_PrimitiveInput#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_PrimitiveInput#LambdaHandler.g.verified.cs @@ -38,7 +38,7 @@ namespace AwsLambda.Host.Core.Generated using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OnInitLambdaApplicationExtensions + file static class GeneratedLambdaOnInitBuilderExtensions { // Location: InputFile.cs(10,8) [InterceptsLocation(1, "4H720O/JvOGs29mmtmYgitQAAABJbnB1dEZpbGUuY3M=")] diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_BlockLambda_ReturnsImplicitVoid#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_BlockLambda_ReturnsImplicitVoid#LambdaHandler.g.verified.cs index bd7cff11..36227b63 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_BlockLambda_ReturnsImplicitVoid#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_BlockLambda_ReturnsImplicitVoid#LambdaHandler.g.verified.cs @@ -38,7 +38,7 @@ namespace AwsLambda.Host.Core.Generated using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OnShutdownLambdaApplicationExtensions + file static class GeneratedLambdaOnShutdownBuilderExtensions { // Location: InputFile.cs(10,8) [InterceptsLocation(1, "JG45SVupAX32PicMEg4KYMQAAABJbnB1dEZpbGUuY3M=")] diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_MultipleCalls#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_MultipleCalls#LambdaHandler.g.verified.cs index 47408a48..17009b7c 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_MultipleCalls#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_MultipleCalls#LambdaHandler.g.verified.cs @@ -38,7 +38,7 @@ namespace AwsLambda.Host.Core.Generated using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OnShutdownLambdaApplicationExtensions + file static class GeneratedLambdaOnShutdownBuilderExtensions { // Location: InputFile.cs(10,8) [InterceptsLocation(1, "8z0FL9iGVp57G+1Z1fBD39QAAABJbnB1dEZpbGUuY3M=")] diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput#LambdaHandler.g.verified.cs index 009490ea..7e2e033d 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput#LambdaHandler.g.verified.cs @@ -38,7 +38,7 @@ namespace AwsLambda.Host.Core.Generated using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OnShutdownLambdaApplicationExtensions + file static class GeneratedLambdaOnShutdownBuilderExtensions { // Location: InputFile.cs(10,8) [InterceptsLocation(1, "qjTMZJmT/ICwyqjvKYAro9QAAABJbnB1dEZpbGUuY3M=")] diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedType#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedType#LambdaHandler.g.verified.cs index cffadb35..ca391902 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedType#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedType#LambdaHandler.g.verified.cs @@ -38,7 +38,7 @@ namespace AwsLambda.Host.Core.Generated using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OnShutdownLambdaApplicationExtensions + file static class GeneratedLambdaOnShutdownBuilderExtensions { // Location: InputFile.cs(10,8) [InterceptsLocation(1, "xOmLseZGX64ZVN3IS0hGL9QAAABJbnB1dEZpbGUuY3M=")] diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedTypeAsync#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedTypeAsync#LambdaHandler.g.verified.cs index f9d45256..a9ad7a48 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedTypeAsync#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedTypeAsync#LambdaHandler.g.verified.cs @@ -38,7 +38,7 @@ namespace AwsLambda.Host.Core.Generated using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OnShutdownLambdaApplicationExtensions + file static class GeneratedLambdaOnShutdownBuilderExtensions { // Location: InputFile.cs(10,8) [InterceptsLocation(1, "nxe3yEiiRmdYDNQcN1k3hdQAAABJbnB1dEZpbGUuY3M=")] diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedTypeTask#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedTypeTask#LambdaHandler.g.verified.cs index a31edeaa..6e3198d4 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedTypeTask#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedTypeTask#LambdaHandler.g.verified.cs @@ -38,7 +38,7 @@ namespace AwsLambda.Host.Core.Generated using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OnShutdownLambdaApplicationExtensions + file static class GeneratedLambdaOnShutdownBuilderExtensions { // Location: InputFile.cs(10,8) [InterceptsLocation(1, "2tTPAN/rsaZuzGty9hzBK9QAAABJbnB1dEZpbGUuY3M=")] diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NullableValueAndReferenceInputs#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NullableValueAndReferenceInputs#LambdaHandler.g.verified.cs index 19e01b05..68d66182 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NullableValueAndReferenceInputs#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NullableValueAndReferenceInputs#LambdaHandler.g.verified.cs @@ -38,7 +38,7 @@ namespace AwsLambda.Host.Core.Generated using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OnShutdownLambdaApplicationExtensions + file static class GeneratedLambdaOnShutdownBuilderExtensions { // Location: InputFile.cs(10,8) [InterceptsLocation(1, "UPiaK81+RguBpV3LlTD6qtQAAABJbnB1dEZpbGUuY3M=")] diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_OneOfEachPossibleKindOfInput#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_OneOfEachPossibleKindOfInput#LambdaHandler.g.verified.cs index 74d24674..fff1dabd 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_OneOfEachPossibleKindOfInput#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_OneOfEachPossibleKindOfInput#LambdaHandler.g.verified.cs @@ -38,7 +38,7 @@ namespace AwsLambda.Host.Core.Generated using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OnShutdownLambdaApplicationExtensions + file static class GeneratedLambdaOnShutdownBuilderExtensions { // Location: InputFile.cs(12,8) [InterceptsLocation(1, "YiehluDLQPPtk+Ko8lbJChwBAABJbnB1dEZpbGUuY3M=")] diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_PrimitiveInput#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_PrimitiveInput#LambdaHandler.g.verified.cs index f61b14b1..c37a4cba 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_PrimitiveInput#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_PrimitiveInput#LambdaHandler.g.verified.cs @@ -38,7 +38,7 @@ namespace AwsLambda.Host.Core.Generated using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] - file static class OnShutdownLambdaApplicationExtensions + file static class GeneratedLambdaOnShutdownBuilderExtensions { // Location: InputFile.cs(10,8) [InterceptsLocation(1, "QR3PHAM1SBBcUgDZGFYhBtQAAABJbnB1dEZpbGUuY3M=")] From 9bc882e41054efc1a4a01c4007b5d93a946a7cdb Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 14:09:44 -0500 Subject: [PATCH 34/48] refactor(source-generators): remove unused import in GenericHandler template - Deleted unused `AwsLambda.Host.Core` import in `GenericHandler.scriban`. - Simplified the generated output by cleaning up unnecessary using directives. --- .../Templates/GenericHandler.scriban | 1 - ...st_OnInit_ExplicitReturnTypeAsync#LambdaHandler.g.verified.cs | 1 - ...t_OnInit_MethodHandler_AsyncAndDi#LambdaHandler.g.verified.cs | 1 - ...AsyncAndDiAndReturnUnexpectedType#LambdaHandler.g.verified.cs | 1 - ...ts.Test_OnInit_MethodHandler_NoDi#LambdaHandler.g.verified.cs | 1 - ...fyTests.Test_OnInit_MultipleCalls#LambdaHandler.g.verified.cs | 1 - ...ests.Test_OnInit_NoInput_NoOutput#LambdaHandler.g.verified.cs | 1 - ...st_OnInit_NoInput_ReturnAsyncBool#LambdaHandler.g.verified.cs | 1 - ...ts.Test_OnInit_NoInput_ReturnBool#LambdaHandler.g.verified.cs | 1 - ...nit_NoInput_ReturnNotExpectedType#LambdaHandler.g.verified.cs | 1 - ...oInput_ReturnNotExpectedTypeAsync#LambdaHandler.g.verified.cs | 1 - ...NoInput_ReturnNotExpectedTypeTask#LambdaHandler.g.verified.cs | 1 - ...est_OnInit_NoInput_ReturnTaskBool#LambdaHandler.g.verified.cs | 1 - ...t_NullableValueAndReferenceInputs#LambdaHandler.g.verified.cs | 1 - ...Init_OneOfEachPossibleKindOfInput#LambdaHandler.g.verified.cs | 1 - ...yTests.Test_OnInit_PrimitiveInput#LambdaHandler.g.verified.cs | 1 - ...n_BlockLambda_ReturnsImplicitVoid#LambdaHandler.g.verified.cs | 1 - ...sts.Test_OnShutdown_MultipleCalls#LambdaHandler.g.verified.cs | 1 - ...rifyTests.Test_OnShutdown_NoInput#LambdaHandler.g.verified.cs | 1 - ...down_NoInput_ReturnUnexpectedType#LambdaHandler.g.verified.cs | 1 - ...NoInput_ReturnUnexpectedTypeAsync#LambdaHandler.g.verified.cs | 1 - ..._NoInput_ReturnUnexpectedTypeTask#LambdaHandler.g.verified.cs | 1 - ...n_NullableValueAndReferenceInputs#LambdaHandler.g.verified.cs | 1 - ...down_OneOfEachPossibleKindOfInput#LambdaHandler.g.verified.cs | 1 - ...ts.Test_OnShutdown_PrimitiveInput#LambdaHandler.g.verified.cs | 1 - 25 files changed, 25 deletions(-) diff --git a/src/AwsLambda.Host.SourceGenerators/Templates/GenericHandler.scriban b/src/AwsLambda.Host.SourceGenerators/Templates/GenericHandler.scriban index 9352d55b..949c29dc 100644 --- a/src/AwsLambda.Host.SourceGenerators/Templates/GenericHandler.scriban +++ b/src/AwsLambda.Host.SourceGenerators/Templates/GenericHandler.scriban @@ -7,7 +7,6 @@ namespace AwsLambda.Host.Core.Generated using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; {{ generated_code_attribute }} file static class GeneratedLambda{{ name }}BuilderExtensions diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_ExplicitReturnTypeAsync#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_ExplicitReturnTypeAsync#LambdaHandler.g.verified.cs index 22ccb053..cb509016 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_ExplicitReturnTypeAsync#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_ExplicitReturnTypeAsync#LambdaHandler.g.verified.cs @@ -35,7 +35,6 @@ namespace AwsLambda.Host.Core.Generated using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class GeneratedLambdaOnInitBuilderExtensions diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_AsyncAndDi#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_AsyncAndDi#LambdaHandler.g.verified.cs index 74de79d3..fdf3271e 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_AsyncAndDi#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_AsyncAndDi#LambdaHandler.g.verified.cs @@ -35,7 +35,6 @@ namespace AwsLambda.Host.Core.Generated using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class GeneratedLambdaOnInitBuilderExtensions diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_AsyncAndDiAndReturnUnexpectedType#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_AsyncAndDiAndReturnUnexpectedType#LambdaHandler.g.verified.cs index 996efaea..c3be8b7c 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_AsyncAndDiAndReturnUnexpectedType#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_AsyncAndDiAndReturnUnexpectedType#LambdaHandler.g.verified.cs @@ -35,7 +35,6 @@ namespace AwsLambda.Host.Core.Generated using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class GeneratedLambdaOnInitBuilderExtensions diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_NoDi#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_NoDi#LambdaHandler.g.verified.cs index 0fd2a644..4fac26bf 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_NoDi#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_NoDi#LambdaHandler.g.verified.cs @@ -35,7 +35,6 @@ namespace AwsLambda.Host.Core.Generated using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class GeneratedLambdaOnInitBuilderExtensions diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MultipleCalls#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MultipleCalls#LambdaHandler.g.verified.cs index 7b35ca26..ffa8d89c 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MultipleCalls#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MultipleCalls#LambdaHandler.g.verified.cs @@ -35,7 +35,6 @@ namespace AwsLambda.Host.Core.Generated using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class GeneratedLambdaOnInitBuilderExtensions diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_NoOutput#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_NoOutput#LambdaHandler.g.verified.cs index e6640281..8b714fe9 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_NoOutput#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_NoOutput#LambdaHandler.g.verified.cs @@ -35,7 +35,6 @@ namespace AwsLambda.Host.Core.Generated using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class GeneratedLambdaOnInitBuilderExtensions diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnAsyncBool#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnAsyncBool#LambdaHandler.g.verified.cs index d0f8662f..df732b9c 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnAsyncBool#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnAsyncBool#LambdaHandler.g.verified.cs @@ -35,7 +35,6 @@ namespace AwsLambda.Host.Core.Generated using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class GeneratedLambdaOnInitBuilderExtensions diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnBool#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnBool#LambdaHandler.g.verified.cs index 6986ea71..b5cb6dba 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnBool#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnBool#LambdaHandler.g.verified.cs @@ -35,7 +35,6 @@ namespace AwsLambda.Host.Core.Generated using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class GeneratedLambdaOnInitBuilderExtensions diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedType#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedType#LambdaHandler.g.verified.cs index 3e45563a..a77f3065 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedType#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedType#LambdaHandler.g.verified.cs @@ -35,7 +35,6 @@ namespace AwsLambda.Host.Core.Generated using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class GeneratedLambdaOnInitBuilderExtensions diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedTypeAsync#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedTypeAsync#LambdaHandler.g.verified.cs index b0e3962f..e185e626 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedTypeAsync#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedTypeAsync#LambdaHandler.g.verified.cs @@ -35,7 +35,6 @@ namespace AwsLambda.Host.Core.Generated using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class GeneratedLambdaOnInitBuilderExtensions diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedTypeTask#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedTypeTask#LambdaHandler.g.verified.cs index 60965e57..08f2a165 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedTypeTask#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedTypeTask#LambdaHandler.g.verified.cs @@ -35,7 +35,6 @@ namespace AwsLambda.Host.Core.Generated using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class GeneratedLambdaOnInitBuilderExtensions diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnTaskBool#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnTaskBool#LambdaHandler.g.verified.cs index 968bf716..0e082f1b 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnTaskBool#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnTaskBool#LambdaHandler.g.verified.cs @@ -35,7 +35,6 @@ namespace AwsLambda.Host.Core.Generated using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class GeneratedLambdaOnInitBuilderExtensions diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NullableValueAndReferenceInputs#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NullableValueAndReferenceInputs#LambdaHandler.g.verified.cs index 6fb1e8aa..622ef238 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NullableValueAndReferenceInputs#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NullableValueAndReferenceInputs#LambdaHandler.g.verified.cs @@ -35,7 +35,6 @@ namespace AwsLambda.Host.Core.Generated using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class GeneratedLambdaOnInitBuilderExtensions diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_OneOfEachPossibleKindOfInput#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_OneOfEachPossibleKindOfInput#LambdaHandler.g.verified.cs index 5bd77421..bcc90a41 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_OneOfEachPossibleKindOfInput#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_OneOfEachPossibleKindOfInput#LambdaHandler.g.verified.cs @@ -35,7 +35,6 @@ namespace AwsLambda.Host.Core.Generated using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class GeneratedLambdaOnInitBuilderExtensions diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_PrimitiveInput#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_PrimitiveInput#LambdaHandler.g.verified.cs index d91fa3f7..a8d672a5 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_PrimitiveInput#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_PrimitiveInput#LambdaHandler.g.verified.cs @@ -35,7 +35,6 @@ namespace AwsLambda.Host.Core.Generated using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class GeneratedLambdaOnInitBuilderExtensions diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_BlockLambda_ReturnsImplicitVoid#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_BlockLambda_ReturnsImplicitVoid#LambdaHandler.g.verified.cs index 36227b63..8cdb556b 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_BlockLambda_ReturnsImplicitVoid#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_BlockLambda_ReturnsImplicitVoid#LambdaHandler.g.verified.cs @@ -35,7 +35,6 @@ namespace AwsLambda.Host.Core.Generated using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class GeneratedLambdaOnShutdownBuilderExtensions diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_MultipleCalls#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_MultipleCalls#LambdaHandler.g.verified.cs index 17009b7c..a21a7379 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_MultipleCalls#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_MultipleCalls#LambdaHandler.g.verified.cs @@ -35,7 +35,6 @@ namespace AwsLambda.Host.Core.Generated using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class GeneratedLambdaOnShutdownBuilderExtensions diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput#LambdaHandler.g.verified.cs index 7e2e033d..2cbcf78a 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput#LambdaHandler.g.verified.cs @@ -35,7 +35,6 @@ namespace AwsLambda.Host.Core.Generated using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class GeneratedLambdaOnShutdownBuilderExtensions diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedType#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedType#LambdaHandler.g.verified.cs index ca391902..b7be06a8 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedType#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedType#LambdaHandler.g.verified.cs @@ -35,7 +35,6 @@ namespace AwsLambda.Host.Core.Generated using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class GeneratedLambdaOnShutdownBuilderExtensions diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedTypeAsync#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedTypeAsync#LambdaHandler.g.verified.cs index a9ad7a48..e8c28781 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedTypeAsync#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedTypeAsync#LambdaHandler.g.verified.cs @@ -35,7 +35,6 @@ namespace AwsLambda.Host.Core.Generated using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class GeneratedLambdaOnShutdownBuilderExtensions diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedTypeTask#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedTypeTask#LambdaHandler.g.verified.cs index 6e3198d4..5d5d7841 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedTypeTask#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedTypeTask#LambdaHandler.g.verified.cs @@ -35,7 +35,6 @@ namespace AwsLambda.Host.Core.Generated using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class GeneratedLambdaOnShutdownBuilderExtensions diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NullableValueAndReferenceInputs#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NullableValueAndReferenceInputs#LambdaHandler.g.verified.cs index 68d66182..bf74bdaf 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NullableValueAndReferenceInputs#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NullableValueAndReferenceInputs#LambdaHandler.g.verified.cs @@ -35,7 +35,6 @@ namespace AwsLambda.Host.Core.Generated using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class GeneratedLambdaOnShutdownBuilderExtensions diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_OneOfEachPossibleKindOfInput#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_OneOfEachPossibleKindOfInput#LambdaHandler.g.verified.cs index fff1dabd..6dc057d1 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_OneOfEachPossibleKindOfInput#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_OneOfEachPossibleKindOfInput#LambdaHandler.g.verified.cs @@ -35,7 +35,6 @@ namespace AwsLambda.Host.Core.Generated using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class GeneratedLambdaOnShutdownBuilderExtensions diff --git a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_PrimitiveInput#LambdaHandler.g.verified.cs b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_PrimitiveInput#LambdaHandler.g.verified.cs index c37a4cba..d888bebc 100644 --- a/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_PrimitiveInput#LambdaHandler.g.verified.cs +++ b/tests/AwsLambda.Host.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_PrimitiveInput#LambdaHandler.g.verified.cs @@ -35,7 +35,6 @@ namespace AwsLambda.Host.Core.Generated using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using AwsLambda.Host.Builder; - using AwsLambda.Host.Core; [GeneratedCode("AwsLambda.Host.SourceGenerators", "0.0.0")] file static class GeneratedLambdaOnShutdownBuilderExtensions From fbc8ffd96566a4575ec631a8c28fb16348a7f5a5 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 14:10:35 -0500 Subject: [PATCH 35/48] refactor(source-generators): reorder OnShutdown generator for consistency - Reordered OnShutdown interceptor generation to align with OnInit generator placement. - Improved code readability by maintaining consistent section grouping for interceptors. --- .../LambdaHostOutputGenerator.cs | 34 +++++++------------ 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/src/AwsLambda.Host.SourceGenerators/OutputGenerators/LambdaHostOutputGenerator.cs b/src/AwsLambda.Host.SourceGenerators/OutputGenerators/LambdaHostOutputGenerator.cs index cc0bcb2d..a1dd95bf 100644 --- a/src/AwsLambda.Host.SourceGenerators/OutputGenerators/LambdaHostOutputGenerator.cs +++ b/src/AwsLambda.Host.SourceGenerators/OutputGenerators/LambdaHostOutputGenerator.cs @@ -45,15 +45,18 @@ string generatorVersion ) ); - // // if UseOpenTelemetryTracing calls found, generate the source code. - // if (compilationInfo.UseOpenTelemetryTracingInfos.Count >= 1) - // outputs.Add( - // OpenTelemetrySources.Generate( - // compilationInfo.UseOpenTelemetryTracingInfos, - // mapHandlerInvocationInfo.DelegateInfo, - // generatedCodeAttribute - // ) - // ); + // add OnInit interceptors + if (compilationInfo.OnInitInvocationInfos.Count >= 1) + outputs.Add( + GenericHandlerSources.Generate( + compilationInfo.OnInitInvocationInfos, + "OnInit", + "bool", + "true", + "ILambdaOnInitBuilder", + generatedCodeAttribute + ) + ); // add OnShutdown interceptors if (compilationInfo.OnShutdownInvocationInfos.Count >= 1) @@ -68,19 +71,6 @@ string generatorVersion ) ); - // add OnInit interceptors - if (compilationInfo.OnInitInvocationInfos.Count >= 1) - outputs.Add( - GenericHandlerSources.Generate( - compilationInfo.OnInitInvocationInfos, - "OnInit", - "bool", - "true", - "ILambdaOnInitBuilder", - generatedCodeAttribute - ) - ); - // join all the source code together and add it to the compilation context. var outCode = string.Join("\n", outputs.Where(s => s != null)); From 06ccf78f47602d642946bb153ad8b84b6028074c Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 14:12:13 -0500 Subject: [PATCH 36/48] test(lambda-host): update LambdaHostContextFactoryTests to validate feature provider handling - Updated `Create` assertion to ensure `featureCollectionFactory` receives `IEnumerable`. --- .../Core/Context/LambdaHostContextFactoryTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/AwsLambda.Host.UnitTests/Core/Context/LambdaHostContextFactoryTests.cs b/tests/AwsLambda.Host.UnitTests/Core/Context/LambdaHostContextFactoryTests.cs index a41ce173..db370497 100644 --- a/tests/AwsLambda.Host.UnitTests/Core/Context/LambdaHostContextFactoryTests.cs +++ b/tests/AwsLambda.Host.UnitTests/Core/Context/LambdaHostContextFactoryTests.cs @@ -70,7 +70,7 @@ internal void Create_CallsFeatureCollectionFactoryCreate( _ = factory.Create(lambdaContext, properties, CancellationToken.None); // Assert - featureCollectionFactory.Received(1).Create(); + featureCollectionFactory.Received(1).Create(Arg.Any>()); } [Theory] From 952cb2ceacb8b7f137306ddf3b4f9014e64e6ff8 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 14:13:47 -0500 Subject: [PATCH 37/48] test(lambda-host): refactor DefaultFeatureCollectionFactoryTests to use Theory and AutoNSubstituteData - Replaced Fact with Theory and AutoNSubstituteData for parameterization. - Updated Create tests to accept IEnumerable dependencies. - Ensured improved test coverage with consistent dependency injection handling. --- .../DefaultFeatureCollectionFactoryTests.cs | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/tests/AwsLambda.Host.UnitTests/Core/Features/DefaultFeatureCollectionFactoryTests.cs b/tests/AwsLambda.Host.UnitTests/Core/Features/DefaultFeatureCollectionFactoryTests.cs index d11d3873..496eaabc 100644 --- a/tests/AwsLambda.Host.UnitTests/Core/Features/DefaultFeatureCollectionFactoryTests.cs +++ b/tests/AwsLambda.Host.UnitTests/Core/Features/DefaultFeatureCollectionFactoryTests.cs @@ -3,35 +3,38 @@ namespace AwsLambda.Host.UnitTests.Core.Features; [TestSubject(typeof(DefaultFeatureCollectionFactory))] public class DefaultFeatureCollectionFactoryTest { - [Fact] - public void Create_ReturnsIFeatureCollection() + [Theory] + [AutoNSubstituteData] + public void Create_ReturnsIFeatureCollection(IEnumerable featureProviders) { // Arrange var factory = new DefaultFeatureCollectionFactory([]); // Act - var collection = factory.Create(); + var collection = factory.Create(featureProviders); // Assert collection.Should().BeAssignableTo(); } - [Fact] - public void Create_ReturnsNewInstanceEachCall() + [Theory] + [AutoNSubstituteData] + public void Create_ReturnsNewInstanceEachCall(IEnumerable featureProviders) { // Arrange var factory = new DefaultFeatureCollectionFactory([]); // Act - var collection1 = factory.Create(); - var collection2 = factory.Create(); + var collection1 = factory.Create(featureProviders); + var collection2 = factory.Create(featureProviders); // Assert collection1.Should().NotBeSameAs(collection2); } - [Fact] - public void Create_PassesProvidersToCollection() + [Theory] + [AutoNSubstituteData] + public void Create_PassesProvidersToCollection(IEnumerable featureProviders) { // Arrange var provider = Substitute.For(); @@ -46,7 +49,7 @@ public void Create_PassesProvidersToCollection() }); // Act - var collection = factory.Create(); + var collection = factory.Create(featureProviders); var result = collection.Get(); // Assert From a64e7ed9b08b436d4f3af63d7aa38fc060692fe2 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 14:15:53 -0500 Subject: [PATCH 38/48] test(lambda-host): update AddLambdaHostCoreServices test to use new services count - Changed `InlineData` value from 11 to 13 in `AddLambdaHostCoreServices_RegistersExactlyNServices`. - Updated test to reflect the updated number of registered services. --- .../Builder/Extensions/ServiceCollectionExtensionsTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/AwsLambda.Host.UnitTests/Builder/Extensions/ServiceCollectionExtensionsTests.cs b/tests/AwsLambda.Host.UnitTests/Builder/Extensions/ServiceCollectionExtensionsTests.cs index 9991bfbb..61d09d91 100644 --- a/tests/AwsLambda.Host.UnitTests/Builder/Extensions/ServiceCollectionExtensionsTests.cs +++ b/tests/AwsLambda.Host.UnitTests/Builder/Extensions/ServiceCollectionExtensionsTests.cs @@ -31,7 +31,7 @@ public void AddLambdaHostCoreServices_WithValidServiceCollection_ReturnsServiceC } [Theory] - [InlineData(11)] + [InlineData(13)] public void AddLambdaHostCoreServices_RegistersExactlyNServices(int servicesCount) { // Arrange From 8260830c6edbcbdde441145e714a22396817695d Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 14:36:37 -0500 Subject: [PATCH 39/48] feat(docs): add type-safe feature access guide to middleware documentation - Added a detailed section on `ILambdaHostContext` type-safe feature access methods. - Documented the usage of nullable, try-pattern, and required methods for event/response handling. - Included examples, method descriptions, and usage scenarios for clarity. - Enhanced readability and understanding of available middleware utilities. --- docs/guides/middleware.md | 46 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/docs/guides/middleware.md b/docs/guides/middleware.md index 19708807..0c7da272 100644 --- a/docs/guides/middleware.md +++ b/docs/guides/middleware.md @@ -121,6 +121,52 @@ Common features: - Handlers remain free of middleware-specific dependencies; they just work with the event/response types. - Custom features are easy to add—register an implementation of `IFeatureProvider` and it becomes available to all middleware. +### 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: + +```csharp title="Program.cs" +lambda.UseMiddleware(async (context, next) => +{ + // Nullable access - returns null if not found + var request = context.GetEvent(); + if (request is not null) + Console.WriteLine($"Processing order {request.OrderId}"); + + // Try pattern - safe null checking + if (context.TryGetEvent(out var order)) + { + // Use order safely without additional null checks + Console.WriteLine($"Order {order.OrderId} has {order.Items.Count} items"); + } + + await next(context); + + // Required access - throws if not found + var response = context.GetRequiredResponse(); + Console.WriteLine($"Status: {response.Status}"); +}); +``` + +**Available Methods:** + +| Method | Description | Returns | +|--------|-------------|---------| +| `GetEvent()` | Returns event or `null` if not found | `T?` | +| `GetResponse()` | Returns response or `null` if not found | `T?` | +| `TryGetEvent(out T)` | Try-pattern for safe event access | `bool` | +| `TryGetResponse(out T)` | Try-pattern for safe response access | `bool` | +| `GetRequiredEvent()` | Returns event or throws | `T` (throws `InvalidOperationException`) | +| `GetRequiredResponse()` | Returns response or throws | `T` (throws `InvalidOperationException`) | + +**When to use each:** + +- **Nullable methods** (`GetEvent()`) – When the event/response might not exist and you'll handle null gracefully +- **Try pattern** (`TryGetEvent()`) – When you want explicit null checking without additional conditionals +- **Required methods** (`GetRequiredEvent()`) – When the event/response must exist and missing it is an error condition + +These methods are equivalent to calling `context.Features.Get>()` and accessing the event/response, but provide cleaner syntax and better null-safety annotations. + ### Feature Providers in Practice When `context.Features.Get()` runs, `AwsLambda.Host` walks through every registered `IFeatureProvider` From 503ea6c534a7fabad332bf90bdd7c233e29d336d Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 14:37:53 -0500 Subject: [PATCH 40/48] feat(docs): enhance OpenTelemetry middleware documentation - Improved documentation on `UseOpenTelemetryTracing()` middleware for Lambda invocation pipeline. - Explained dynamic event/response handling using `IEventFeature` and `IResponseFeature`. - Described interoperability with multiple handlers and various AWS Lambda event source types. - Clarified shutdown helpers' function for forcing telemetry flush during environment freeze. --- docs/features/open_telemetry.md | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/docs/features/open_telemetry.md b/docs/features/open_telemetry.md index f4bbad3a..0e83dad3 100644 --- a/docs/features/open_telemetry.md +++ b/docs/features/open_telemetry.md @@ -110,20 +110,27 @@ internal record Response(string Message); --- -## How It Works: Source Generation and Interceptors +## How It Works: Feature-Based Middleware -`AwsLambda.Host` relies on C# source generators to avoid runtime reflection and improve performance. The `UseOpenTelemetryTracing()` method is a key part of this system. +The `UseOpenTelemetryTracing()` method adds middleware to the Lambda invocation pipeline that automatically instruments your handlers with distributed tracing. Here's the step-by-step process: -1. The `UseOpenTelemetryTracing()` method itself is an empty placeholder. -2. At compile time, a source generator finds all calls to this method. -3. For each call it finds, it emits a C# 12 Interceptor. This interceptor replaces the empty method call with code that adds a middleware delegate to the Lambda invocation pipeline. -4. This generated middleware calls an adapter in the `AwsLambda.Host.OpenTelemetry` package, which in turn uses the official `OpenTelemetry.Instrumentation.AWSLambda` package to wrap the Lambda handler execution in a root trace span. +1. The `UseOpenTelemetryTracing()` middleware is registered in the invocation pipeline when you call the method on your Lambda application. +2. During each Lambda invocation, the middleware executes before your handler runs. +3. The middleware dynamically detects the event and response types by reading from the feature collection: + - It checks for an `IEventFeature` to get the incoming event object + - It checks for an `IResponseFeature` to get the outgoing response object +4. These event and response objects are passed to the official `OpenTelemetry.Instrumentation.AWSLambda` package, which wraps the handler execution in a root trace span. +5. The OpenTelemetry instrumentation automatically extracts trace context from supported event types (like API Gateway requests), ensuring proper distributed trace propagation across services. -This entire process happens during compilation, resulting in highly optimized code that instruments your handler without any reflection overhead at runtime. +This approach is both efficient and flexible. Because event and response types are determined at runtime from the feature collection, the same middleware works seamlessly with: -In contrast, the shutdown helpers (`OnShutdownFlushOpenTelemetry`, `OnShutdownFlushTracer`, and `OnShutdownFlushMeter`) are regular extension methods. They execute as-is at runtime and use the registered `TracerProvider`/`MeterProvider` instances to force-flush telemetry before Lambda freezes the environment. +- Multiple handlers registered via `MapHandler()` with different event/response types +- Handlers with or without events/responses +- Any AWS Lambda event source type + +The shutdown helpers (`OnShutdownFlushOpenTelemetry`, `OnShutdownFlushTracer`, and `OnShutdownFlushMeter`) are regular extension methods that execute at runtime and use the registered `TracerProvider`/`MeterProvider` instances to force-flush telemetry before Lambda freezes the environment. --- @@ -148,9 +155,15 @@ lambda.UseOpenTelemetryTracing(); // ... MapHandler, OnShutdown, etc. ... ``` -This method call acts as a compile-time trigger for a source generator. The generator intercepts the call and injects middleware into the request pipeline. This middleware is responsible for creating the root trace span for each Lambda invocation. +This method registers middleware in the invocation pipeline that wraps each handler execution in a root trace span. The middleware is responsible for: + +- Retrieving the event object from the `IEventFeature` in the feature collection (if present) +- Executing the handler and capturing the response from `IResponseFeature` (if present) +- Passing both the event and response to the underlying `OpenTelemetry.Instrumentation.AWSLambda` package + +Because the middleware reads event and response types dynamically from the feature collection, it works seamlessly with any Lambda event source type. The OpenTelemetry instrumentation can correctly extract context and attributes from strongly-typed event objects (such as trace parent headers from an API Gateway request), ensuring proper distributed trace propagation across your services. -Under the covers, the source generator performs a critical task. It inspects the delegate you provided to `MapHandler` to determine the specific input and output types of your function (e.g., `APIGatewayProxyRequest`, `SQSEvent`). It then uses these types to generate a call to a generic helper method. This ensures that the underlying `OpenTelemetry.Instrumentation.AWSLambda` package receives a strongly-typed request object. By preserving the specific event type, the OpenTelemetry instrumentation can correctly extract context and attributes, such as trace parent headers from an API Gateway request, ensuring proper distributed trace propagation. +This dynamic approach also enables you to register multiple handlers with different event types in the same Lambda function—the middleware automatically adapts to whichever handler executes. ### Gracefully Shutdown & Cleaning Up From fead5f42d41a36a6e43c7258b7698bf47c602a26 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 14:45:33 -0500 Subject: [PATCH 41/48] feat(docs): clarify `MapHandler` usage and runtime restrictions - Updated documentation to detail scenarios with multiple `MapHandler` calls in the same codebase. - Added a new "Multiple MapHandler Calls" section with examples and best practices. - Explained design patterns for library-provided handlers and conditional handler registration. - Clarified runtime behavior when multiple handlers are registered, including exceptions thrown. --- docs/guides/handler-registration.md | 61 +++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 8 deletions(-) diff --git a/docs/guides/handler-registration.md b/docs/guides/handler-registration.md index 1fe15230..0c8241ad 100644 --- a/docs/guides/handler-registration.md +++ b/docs/guides/handler-registration.md @@ -33,10 +33,55 @@ interface IGreetingService } ``` -- Register middleware (via `lambda.Use(...)`) before calling `MapHandler`; the handler is always the last piece of the pipeline. -- Only one handler can be mapped. If you call `MapHandler` twice, the generator emits error `LH0001` so you catch the issue before publishing. +- While you can have multiple `MapHandler` calls in your code, only one can be registered at runtime (see [Multiple MapHandler Calls](#multiple-maphandler-calls) below). - The generated handler feeds into the normal invocation builder, so all middleware, features, and diagnostics apply equally to handlers created via `Handle` or `MapHandler`. +## Multiple MapHandler Calls + +You can have multiple `MapHandler` calls in your code, but **only one handler can be registered per Lambda execution**. If more than one `MapHandler` is called at runtime, an exception will be thrown. + +This design enables several useful patterns: + +### Use Cases + +**Library-Provided Handlers** + +Libraries can expose pre-configured handlers that applications can opt into: + +```csharp title="MyLibrary.cs" linenums="1" +namespace MyLibrary; + +public static class OrderHandlers +{ + public static void MapOrderHandler(this ILambdaInvocationBuilder app) + { + app.MapHandler(([Event] OrderRequest req, IOrderService orders) => + orders.ProcessAsync(req) + ); + } +} +``` + +```csharp title="Program.cs" linenums="1" +using MyLibrary; + +var builder = LambdaApplication.CreateBuilder(); +builder.Services.AddOrderServices(); // Library-provided services + +var lambda = builder.Build(); + +// Use the library's handler +lambda.MapOrderHandler(); + +await lambda.RunAsync(); +``` + +### Important Notes + +- Only **one** `MapHandler` can execute at runtime—calling multiple will throw an `InvalidOperationException` +- Feature providers are registered when `MapHandler` is called, so ensure the registered handler matches your expected event/response types +- This pattern is designed for **conditional registration**, not for handling multiple event types in a single Lambda (which requires a custom routing solution) + ## Handler Signatures and the `[Event]` Parameter Handlers that receive an incoming payload must identify exactly one parameter with `[Event]`. The generator uses that marker to synthesize deserialization logic (JSON by default, or whatever envelope/serializer is active). If your Lambda does **not** expect input (e.g., scheduled jobs, health checks, etc.), you can omit the `[Event]` attribute entirely—just define a handler with no payload parameter and `AwsLambda.Host` skips the event binding phase. @@ -133,11 +178,15 @@ lambda.MapHandler(async ( `MapHandler` is decorated as a C# 12 interceptor target. During compilation the generator: 1. Ensures the project is built with C# 11+ so interceptors are available (otherwise `LH0004`). -2. Verifies there is exactly one handler and, when a payload parameter exists, exactly one `[Event]` annotation. +2. When a payload parameter exists, verifies exactly one `[Event]` annotation is present. 3. Validates keyed service metadata so the requested key matches the DI container's capabilities (`LH0003` when the key uses an unsupported type such as arrays). 4. Emits a strongly typed `Handle` call that deserializes the payload (if any), resolves services via generated code, sets up features, and serializes the response. -At runtime the stub `MapHandler` method would throw if invoked, but the interception step guarantees that never happens. You get ahead-of-time compatible, reflection-free code with compile-time errors if the signature is invalid. +At runtime: + +- The stub `MapHandler` method would throw if invoked, but the interception step guarantees that never happens +- Only one handler can be registered—calling `MapHandler` multiple times in the same execution throws an `InvalidOperationException` +- You get ahead-of-time compatible, reflection-free code with compile-time errors if the signature is invalid ## Patterns and Best Practices @@ -174,10 +223,6 @@ At runtime the stub `MapHandler` method would throw if invoked, but the intercep ## Troubleshooting -**`LH0001: Multiple handlers registered`** - -Make sure you call `MapHandler` only once. If you need to branch by trigger type, create separate Lambda projects or use envelope dispatching. - **`LH0002: No parameter marked with [Event]`** Add a `[Event]` attribute when your handler accepts an input payload. This diagnostic does **not** appear for payload-less handlers because no event parameter is required in that case. From aa641cb1903818fc0e945f15fffd715421083393 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 16:19:09 -0500 Subject: [PATCH 42/48] chore(opentelemetry): add back LambdaOpenTelemetryServiceProviderExtensions and tests --- .../LambdaOpenTelemetryAdapters.cs | 232 +++++++++ ...TelemetryServiceProviderExtensionsTests.cs | 459 ++++++++++++++++++ 2 files changed, 691 insertions(+) create mode 100644 src/AwsLambda.Host.OpenTelemetry/LambdaOpenTelemetryAdapters.cs create mode 100644 tests/AwsLambda.Host.OpenTelemetry.UnitTests/LambdaOpenTelemetryServiceProviderExtensionsTests.cs diff --git a/src/AwsLambda.Host.OpenTelemetry/LambdaOpenTelemetryAdapters.cs b/src/AwsLambda.Host.OpenTelemetry/LambdaOpenTelemetryAdapters.cs new file mode 100644 index 00000000..3a900d83 --- /dev/null +++ b/src/AwsLambda.Host.OpenTelemetry/LambdaOpenTelemetryAdapters.cs @@ -0,0 +1,232 @@ +using Amazon.Lambda.Core; +using AwsLambda.Host; +using AwsLambda.Host.Core; +using OpenTelemetry.Instrumentation.AWSLambda; +using OpenTelemetry.Trace; + +namespace Microsoft.Extensions.DependencyInjection; + +/// +/// Provides extension methods for integrating OpenTelemetry tracing with AWS Lambda +/// invocations. +/// +public static class LambdaOpenTelemetryServiceProviderExtensions +{ + extension(IServiceProvider services) + { + /// + /// Creates a middleware function that traces Lambda invocations with both event and response + /// types. + /// + /// The type of the Lambda event expected in the context. + /// The type of the Lambda response expected in the context. + /// A middleware function that wraps the Lambda invocation with OpenTelemetry tracing. + /// + /// + /// Important: These methods are primarily intended to be used by source generators + /// and interceptors. Direct usage is not recommended. Source generation and interception are + /// the primary use cases for automatic tracing integration. + /// + /// + /// Uses the registered to wrap Lambda invocations with + /// distributed tracing capabilities through AWS Lambda instrumentation. This method is a + /// wrapper around from + /// the + /// OpenTelemetry.Instrumentation.AWSLambda + /// NuGet package. + /// + /// + /// The context must contain an event of type and the handler + /// must set a response of type . + /// + /// + /// TracerProvider Registration Required: A instance + /// must be registered in the dependency injection container before calling these methods. + /// Failure to register a will result in an + /// being thrown at startup. + /// + /// + /// + /// Thrown if the context event is not of type + /// or if the context response is not of type + /// , or if a instance is not + /// registered in the dependency injection container. + /// + [Obsolete( + "This method will be removed in v2.0.0 Use UseOpenTelemetryTracing directly instead." + )] + public Func GetOpenTelemetryTracer< + TEvent, + TResponse + >() + { + ArgumentNullException.ThrowIfNull(services); + + var tracerProvider = services.GetRequiredService(); + + return next => + { + return async context => + { + if ( + context.Features.Get()?.GetEvent(context) + is not TEvent eventT + ) + throw new InvalidOperationException( + $"Lambda event of type '{typeof(TEvent).FullName}' is not available in the context." + ); + + await AWSLambdaWrapper.TraceAsync( + tracerProvider, + async Task (_, _) => + { + await next(context); + + if ( + context.Features.Get()?.GetResponse() + is not TResponse responseT + ) + throw new InvalidOperationException( + $"Lambda response of type '{typeof(TResponse).FullName}' is not available in the context." + ); + + return responseT; + }, + eventT, + context + ); + }; + }; + } + + /// Creates a middleware function that traces Lambda invocations with only a response type. + /// The type of the Lambda response expected in the context. + /// + /// + /// The event + /// type is not relevant or known when using this overload. + /// + /// + /// Thrown if the context response is not of type + /// . + /// + [Obsolete( + "This method will be removed in v2.0.0 Use UseOpenTelemetryTracing directly instead." + )] + public Func< + LambdaInvocationDelegate, + LambdaInvocationDelegate + > GetOpenTelemetryTracerNoEvent() + { + ArgumentNullException.ThrowIfNull(services); + + var tracerProvider = services.GetRequiredService(); + + return next => + { + return async context => + { + await AWSLambdaWrapper.TraceAsync( + tracerProvider, + async Task (object? _, ILambdaContext _) => + { + await next(context); + + if ( + context.Features.Get()?.GetResponse() + is not TResponse responseT + ) + throw new InvalidOperationException( + $"Lambda response of type '{typeof(TResponse).FullName}' is not available in the context." + ); + + return responseT; + }, + null, + context + ); + }; + }; + } + + /// Creates a middleware function that traces Lambda invocations with only an event type. + /// The type of the Lambda event expected in the context. + /// + /// + /// The + /// response type is not relevant or known when using this overload. + /// + /// + /// Thrown if the context event is not of type + /// . + /// + [Obsolete( + "This method will be removed in v2.0.0 Use UseOpenTelemetryTracing directly instead." + )] + public Func< + LambdaInvocationDelegate, + LambdaInvocationDelegate + > GetOpenTelemetryTracerNoResponse() + { + ArgumentNullException.ThrowIfNull(services); + + var tracerProvider = services.GetRequiredService(); + + return next => + { + return async context => + { + if ( + context.Features.Get()?.GetEvent(context) + is not TEvent eventT + ) + throw new InvalidOperationException( + $"Lambda event of type '{typeof(TEvent).FullName}' is not available in the context." + ); + + await AWSLambdaWrapper.TraceAsync( + tracerProvider, + async Task (_, _) => await next(context), + eventT, + context + ); + }; + }; + } + + /// + /// Creates a middleware function that traces Lambda invocations without specific event or + /// response types. + /// + /// + /// + /// Neither + /// event nor response types are relevant or known when using this overload. + /// + [Obsolete( + "This method will be removed in v2.0.0 Use UseOpenTelemetryTracing directly instead." + )] + public Func< + LambdaInvocationDelegate, + LambdaInvocationDelegate + > GetOpenTelemetryTracerNoEventNoResponse() + { + ArgumentNullException.ThrowIfNull(services); + + var tracerProvider = services.GetRequiredService(); + + return next => + { + return async context => + { + await AWSLambdaWrapper.TraceAsync( + tracerProvider, + async Task (object? _, ILambdaContext _) => await next(context), + null, + context + ); + }; + }; + } + } +} diff --git a/tests/AwsLambda.Host.OpenTelemetry.UnitTests/LambdaOpenTelemetryServiceProviderExtensionsTests.cs b/tests/AwsLambda.Host.OpenTelemetry.UnitTests/LambdaOpenTelemetryServiceProviderExtensionsTests.cs new file mode 100644 index 00000000..f62c038f --- /dev/null +++ b/tests/AwsLambda.Host.OpenTelemetry.UnitTests/LambdaOpenTelemetryServiceProviderExtensionsTests.cs @@ -0,0 +1,459 @@ +using AwsLambda.Host.UnitTests; +using Microsoft.Extensions.DependencyInjection; +using OpenTelemetry.Trace; + +namespace AwsLambda.Host.OpenTelemetry.UnitTests; + +[TestSubject(typeof(LambdaOpenTelemetryServiceProviderExtensions))] +public class LambdaOpenTelemetryServiceProviderExtensionsTests +{ + [Fact] + public void GetOpenTelemetryTracer_WithNullServiceProvider_ThrowsArgumentNullException() + { + // Arrange + IServiceProvider? nullProvider = null; + + // Act + var action = () => nullProvider!.GetOpenTelemetryTracer(); + + // Assert + action.Should().ThrowExactly(); + } + + [Theory] + [AutoNSubstituteData] + public void GetOpenTelemetryTracer_WithoutTracerProvider_ThrowsInvalidOperationException( + [Frozen] IServiceProvider serviceProvider + ) + { + // Arrange + serviceProvider.GetService(typeof(TracerProvider)).Returns(null); + + // Act + var action = () => serviceProvider.GetOpenTelemetryTracer(); + + // Assert + action.Should().ThrowExactly(); + } + + [Theory] + [AutoNSubstituteData] + public void GetOpenTelemetryTracer_ReturnsMiddlewareFunction( + [Frozen] IServiceProvider serviceProvider, + TracerProvider tracerProvider + ) + { + // Arrange + serviceProvider.GetService(typeof(TracerProvider)).Returns(tracerProvider); + + // Act + var middleware = serviceProvider.GetOpenTelemetryTracer(); + + // Assert + middleware.Should().NotBeNull(); + middleware.Should().BeOfType>(); + } + + [Theory] + [AutoNSubstituteData] + public async Task GetOpenTelemetryTracer_WithIncorrectEventType_ThrowsInvalidOperationException( + [Frozen] IServiceProvider serviceProvider, + TracerProvider tracerProvider, + ILambdaHostContext context, + IFeatureCollection features, + IEventFeature eventFeature, + IResponseFeature responseFeature + ) + { + // Arrange + serviceProvider.GetService(typeof(TracerProvider)).Returns(tracerProvider); + var middleware = serviceProvider.GetOpenTelemetryTracer(); + var nextDelegate = Substitute.For(); + var wrappedDelegate = middleware(nextDelegate); + + context.Features.Returns(features); + features.Get().Returns(eventFeature); + features.Get().Returns(responseFeature); + eventFeature.GetEvent(context).Returns(new object()); + + // Act + var action = async () => await wrappedDelegate(context); + + // Assert + await action.Should().ThrowAsync(); + } + + [Theory] + [AutoNSubstituteData] + public async Task GetOpenTelemetryTracer_WithIncorrectResponseType_ThrowsInvalidOperationException( + [Frozen] IServiceProvider serviceProvider, + TracerProvider tracerProvider, + ILambdaHostContext context, + IFeatureCollection features, + IEventFeature eventFeature, + IResponseFeature responseFeature + ) + { + // Arrange + serviceProvider.GetService(typeof(TracerProvider)).Returns(tracerProvider); + var middleware = serviceProvider.GetOpenTelemetryTracer(); + var nextDelegate = Substitute.For(); + var wrappedDelegate = middleware(nextDelegate); + + context.Features.Returns(features); + features.Get().Returns(eventFeature); + features.Get().Returns(responseFeature); + eventFeature.GetEvent(context).Returns(new TestEvent()); + responseFeature.GetResponse().Returns(new object()); // Wrong type + + nextDelegate(Arg.Any()).Returns(Task.CompletedTask); + + // Act + var action = async () => await wrappedDelegate(context); + + // Assert + await action.Should().ThrowAsync(); + } + + [Theory] + [AutoNSubstituteData] + public async Task GetOpenTelemetryTracer_WithValidEventAndResponse_CallsNextDelegate( + [Frozen] IServiceProvider serviceProvider, + TracerProvider tracerProvider, + ILambdaHostContext context, + IFeatureCollection features, + IEventFeature eventFeature, + IResponseFeature responseFeature + ) + { + // Arrange + serviceProvider.GetService(typeof(TracerProvider)).Returns(tracerProvider); + var middleware = serviceProvider.GetOpenTelemetryTracer(); + var nextDelegate = Substitute.For(); + var wrappedDelegate = middleware(nextDelegate); + + var testEvent = new TestEvent(); + var testResponse = new TestResponse(); + + context.Features.Returns(features); + features.Get().Returns(eventFeature); + features.Get().Returns(responseFeature); + eventFeature.GetEvent(context).Returns(testEvent); + responseFeature.GetResponse().Returns(testResponse); + + nextDelegate(Arg.Any()).Returns(Task.CompletedTask); + + // Act + await wrappedDelegate(context); + + // Assert + await nextDelegate.Received(1)(Arg.Any()); + } + + [Fact] + public void GetOpenTelemetryTracerNoEvent_WithNullServiceProvider_ThrowsArgumentNullException() + { + // Arrange + IServiceProvider? nullProvider = null; + + // Act + var action = () => nullProvider!.GetOpenTelemetryTracerNoEvent(); + + // Assert + action.Should().ThrowExactly(); + } + + [Theory] + [AutoNSubstituteData] + public void GetOpenTelemetryTracerNoEvent_WithoutTracerProvider_ThrowsInvalidOperationException( + [Frozen] IServiceProvider serviceProvider + ) + { + // Arrange + serviceProvider.GetService(typeof(TracerProvider)).Returns(null); + + // Act + var action = () => serviceProvider.GetOpenTelemetryTracerNoEvent(); + + // Assert + action.Should().ThrowExactly(); + } + + [Theory] + [AutoNSubstituteData] + public void GetOpenTelemetryTracerNoEvent_ReturnsMiddlewareFunction( + [Frozen] IServiceProvider serviceProvider, + TracerProvider tracerProvider + ) + { + // Arrange + serviceProvider.GetService(typeof(TracerProvider)).Returns(tracerProvider); + + // Act + var middleware = serviceProvider.GetOpenTelemetryTracerNoEvent(); + + // Assert + middleware.Should().NotBeNull(); + middleware.Should().BeOfType>(); + } + + [Theory] + [AutoNSubstituteData] + public async Task GetOpenTelemetryTracerNoEvent_WithIncorrectResponseType_ThrowsInvalidOperationException( + [Frozen] IServiceProvider serviceProvider, + TracerProvider tracerProvider, + ILambdaHostContext context, + IFeatureCollection features, + IEventFeature eventFeature, + IResponseFeature responseFeature + ) + { + // Arrange + serviceProvider.GetService(typeof(TracerProvider)).Returns(tracerProvider); + var middleware = serviceProvider.GetOpenTelemetryTracerNoEvent(); + var nextDelegate = Substitute.For(); + var wrappedDelegate = middleware(nextDelegate); + + context.Features.Returns(features); + features.Get().Returns(eventFeature); + features.Get().Returns(responseFeature); + eventFeature.GetEvent(context).Returns(new object()); + responseFeature.GetResponse().Returns(new object()); // Wrong type + + nextDelegate(Arg.Any()).Returns(Task.CompletedTask); + + // Act + var action = async () => await wrappedDelegate(context); + + // Assert + await action.Should().ThrowAsync(); + } + + [Theory] + [AutoNSubstituteData] + public async Task GetOpenTelemetryTracerNoEvent_WithValidResponse_CallsNextDelegate( + [Frozen] IServiceProvider serviceProvider, + TracerProvider tracerProvider, + ILambdaHostContext context, + IFeatureCollection features, + IEventFeature eventFeature, + IResponseFeature responseFeature + ) + { + // Arrange + serviceProvider.GetService(typeof(TracerProvider)).Returns(tracerProvider); + var middleware = serviceProvider.GetOpenTelemetryTracerNoEvent(); + var nextDelegate = Substitute.For(); + var wrappedDelegate = middleware(nextDelegate); + + var testResponse = new TestResponse(); + + context.Features.Returns(features); + features.Get().Returns(eventFeature); + features.Get().Returns(responseFeature); + eventFeature.GetEvent(context).Returns(new object()); + responseFeature.GetResponse().Returns(testResponse); + + nextDelegate(Arg.Any()).Returns(Task.CompletedTask); + + // Act + await wrappedDelegate(context); + + // Assert + await nextDelegate.Received(1)(Arg.Any()); + } + + [Fact] + public void GetOpenTelemetryTracerNoResponse_WithNullServiceProvider_ThrowsArgumentNullException() + { + // Arrange + IServiceProvider? nullProvider = null; + + // Act + var action = () => nullProvider!.GetOpenTelemetryTracerNoResponse(); + + // Assert + action.Should().ThrowExactly(); + } + + [Theory] + [AutoNSubstituteData] + public void GetOpenTelemetryTracerNoResponse_WithoutTracerProvider_ThrowsInvalidOperationException( + [Frozen] IServiceProvider serviceProvider + ) + { + // Arrange + serviceProvider.GetService(typeof(TracerProvider)).Returns(null); + + // Act + var action = () => serviceProvider.GetOpenTelemetryTracerNoResponse(); + + // Assert + action.Should().ThrowExactly(); + } + + [Theory] + [AutoNSubstituteData] + public void GetOpenTelemetryTracerNoResponse_ReturnsMiddlewareFunction( + [Frozen] IServiceProvider serviceProvider, + TracerProvider tracerProvider + ) + { + // Arrange + serviceProvider.GetService(typeof(TracerProvider)).Returns(tracerProvider); + + // Act + var middleware = serviceProvider.GetOpenTelemetryTracerNoResponse(); + + // Assert + middleware.Should().NotBeNull(); + middleware.Should().BeOfType>(); + } + + [Theory] + [AutoNSubstituteData] + public async Task GetOpenTelemetryTracerNoResponse_WithIncorrectEventType_ThrowsInvalidOperationException( + [Frozen] IServiceProvider serviceProvider, + TracerProvider tracerProvider, + ILambdaHostContext context, + IFeatureCollection features, + IEventFeature eventFeature, + IResponseFeature responseFeature + ) + { + // Arrange + serviceProvider.GetService(typeof(TracerProvider)).Returns(tracerProvider); + var middleware = serviceProvider.GetOpenTelemetryTracerNoResponse(); + var nextDelegate = Substitute.For(); + var wrappedDelegate = middleware(nextDelegate); + + context.Features.Returns(features); + features.Get().Returns(eventFeature); + features.Get().Returns(responseFeature); + eventFeature.GetEvent(context).Returns(new object()); // Wrong type + responseFeature.GetResponse().Returns(new object()); + + // Act + var action = async () => await wrappedDelegate(context); + + // Assert + await action.Should().ThrowAsync(); + } + + [Theory] + [AutoNSubstituteData] + public async Task GetOpenTelemetryTracerNoResponse_WithValidEvent_CallsNextDelegate( + [Frozen] IServiceProvider serviceProvider, + TracerProvider tracerProvider, + ILambdaHostContext context, + IFeatureCollection features, + IEventFeature eventFeature, + IResponseFeature responseFeature + ) + { + // Arrange + serviceProvider.GetService(typeof(TracerProvider)).Returns(tracerProvider); + var middleware = serviceProvider.GetOpenTelemetryTracerNoResponse(); + var nextDelegate = Substitute.For(); + var wrappedDelegate = middleware(nextDelegate); + + var testEvent = new TestEvent(); + + context.Features.Returns(features); + features.Get().Returns(eventFeature); + features.Get().Returns(responseFeature); + eventFeature.GetEvent(context).Returns(testEvent); + responseFeature.GetResponse().Returns(new object()); + + nextDelegate(Arg.Any()).Returns(Task.CompletedTask); + + // Act + await wrappedDelegate(context); + + // Assert + await nextDelegate.Received(1)(Arg.Any()); + } + + [Fact] + public void GetOpenTelemetryTracerNoEventNoResponse_WithNullServiceProvider_ThrowsArgumentNullException() + { + // Arrange + IServiceProvider? nullProvider = null; + + // Act + var action = () => nullProvider!.GetOpenTelemetryTracerNoEventNoResponse(); + + // Assert + action.Should().ThrowExactly(); + } + + [Theory] + [AutoNSubstituteData] + public void GetOpenTelemetryTracerNoEventNoResponse_WithoutTracerProvider_ThrowsInvalidOperationException( + [Frozen] IServiceProvider serviceProvider + ) + { + // Arrange + serviceProvider.GetService(typeof(TracerProvider)).Returns(null); + + // Act + var action = () => serviceProvider.GetOpenTelemetryTracerNoEventNoResponse(); + + // Assert + action.Should().ThrowExactly(); + } + + [Theory] + [AutoNSubstituteData] + public void GetOpenTelemetryTracerNoEventNoResponse_ReturnsMiddlewareFunction( + [Frozen] IServiceProvider serviceProvider, + TracerProvider tracerProvider + ) + { + // Arrange + serviceProvider.GetService(typeof(TracerProvider)).Returns(tracerProvider); + + // Act + var middleware = serviceProvider.GetOpenTelemetryTracerNoEventNoResponse(); + + // Assert + middleware.Should().NotBeNull(); + middleware.Should().BeOfType>(); + } + + [Theory] + [AutoNSubstituteData] + public async Task GetOpenTelemetryTracerNoEventNoResponse_WithAnyEventAndResponse_CallsNextDelegate( + [Frozen] IServiceProvider serviceProvider, + TracerProvider tracerProvider, + ILambdaHostContext context, + IFeatureCollection features, + IEventFeature eventFeature, + IResponseFeature responseFeature + ) + { + // Arrange + serviceProvider.GetService(typeof(TracerProvider)).Returns(tracerProvider); + var middleware = serviceProvider.GetOpenTelemetryTracerNoEventNoResponse(); + var nextDelegate = Substitute.For(); + var wrappedDelegate = middleware(nextDelegate); + + context.Features.Returns(features); + features.Get().Returns(eventFeature); + features.Get().Returns(responseFeature); + eventFeature.GetEvent(context).Returns(new object()); + responseFeature.GetResponse().Returns(new object()); + + nextDelegate(Arg.Any()).Returns(Task.CompletedTask); + + // Act + await wrappedDelegate(context); + + // Assert + await nextDelegate.Received(1)(Arg.Any()); + } + + private class TestEvent { } + + private class TestResponse { } +} From ee9f5b44d98a5b13555e4d0dfd285abdce3d3711 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 16:25:04 -0500 Subject: [PATCH 43/48] refactor(core): remove unused #region directives for improved readability - Removed redundant #region and #endregion directives across multiple files. - Simplified code structure to enhance maintainability and visual clarity. --- .../OutputGenerators/LambdaHostOutputGenerator.cs | 4 ---- .../OutputGenerators/MapHandlerSources.cs | 4 ---- .../SyntaxProviders/MapHandlerSyntaxProvider.cs | 4 ---- .../Builder/Extensions/ServiceCollectionExtensions.cs | 4 ---- .../Core/Features/DefaultEventFeatureProvider.cs | 4 ---- .../Core/Features/DefaultResponseFeatureProvider.cs | 4 ---- .../Core/Features/EventFeatureProviderFactory.cs | 4 ---- .../Core/Features/ResponseFeatureProviderFactory.cs | 4 ---- 8 files changed, 32 deletions(-) diff --git a/src/AwsLambda.Host.SourceGenerators/OutputGenerators/LambdaHostOutputGenerator.cs b/src/AwsLambda.Host.SourceGenerators/OutputGenerators/LambdaHostOutputGenerator.cs index a1dd95bf..94befc1c 100644 --- a/src/AwsLambda.Host.SourceGenerators/OutputGenerators/LambdaHostOutputGenerator.cs +++ b/src/AwsLambda.Host.SourceGenerators/OutputGenerators/LambdaHostOutputGenerator.cs @@ -1,12 +1,8 @@ -#region - using System.Collections.Generic; using System.Linq; using AwsLambda.Host.SourceGenerators.Models; using Microsoft.CodeAnalysis; -#endregion - namespace AwsLambda.Host.SourceGenerators; internal static class LambdaHostOutputGenerator diff --git a/src/AwsLambda.Host.SourceGenerators/OutputGenerators/MapHandlerSources.cs b/src/AwsLambda.Host.SourceGenerators/OutputGenerators/MapHandlerSources.cs index b3aba49b..472795b4 100644 --- a/src/AwsLambda.Host.SourceGenerators/OutputGenerators/MapHandlerSources.cs +++ b/src/AwsLambda.Host.SourceGenerators/OutputGenerators/MapHandlerSources.cs @@ -1,12 +1,8 @@ -#region - using System.Linq; using AwsLambda.Host.SourceGenerators.Extensions; using AwsLambda.Host.SourceGenerators.Models; using AwsLambda.Host.SourceGenerators.Types; -#endregion - namespace AwsLambda.Host.SourceGenerators; internal static class MapHandlerSources diff --git a/src/AwsLambda.Host.SourceGenerators/SyntaxProviders/MapHandlerSyntaxProvider.cs b/src/AwsLambda.Host.SourceGenerators/SyntaxProviders/MapHandlerSyntaxProvider.cs index ccedb6a5..c280754c 100644 --- a/src/AwsLambda.Host.SourceGenerators/SyntaxProviders/MapHandlerSyntaxProvider.cs +++ b/src/AwsLambda.Host.SourceGenerators/SyntaxProviders/MapHandlerSyntaxProvider.cs @@ -1,11 +1,7 @@ -#region - using System.Threading; using AwsLambda.Host.SourceGenerators.Models; using Microsoft.CodeAnalysis; -#endregion - namespace AwsLambda.Host.SourceGenerators; internal static class MapHandlerSyntaxProvider diff --git a/src/AwsLambda.Host/Builder/Extensions/ServiceCollectionExtensions.cs b/src/AwsLambda.Host/Builder/Extensions/ServiceCollectionExtensions.cs index 507598e7..ec5fa000 100644 --- a/src/AwsLambda.Host/Builder/Extensions/ServiceCollectionExtensions.cs +++ b/src/AwsLambda.Host/Builder/Extensions/ServiceCollectionExtensions.cs @@ -1,13 +1,9 @@ -#region - using Amazon.Lambda.Core; using Amazon.Lambda.Serialization.SystemTextJson; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Options; -#endregion - namespace Microsoft.Extensions.DependencyInjection; /// Extension methods for registering Lambda Host services. diff --git a/src/AwsLambda.Host/Core/Features/DefaultEventFeatureProvider.cs b/src/AwsLambda.Host/Core/Features/DefaultEventFeatureProvider.cs index e2040359..65085640 100644 --- a/src/AwsLambda.Host/Core/Features/DefaultEventFeatureProvider.cs +++ b/src/AwsLambda.Host/Core/Features/DefaultEventFeatureProvider.cs @@ -1,9 +1,5 @@ -#region - using Amazon.Lambda.Core; -#endregion - namespace AwsLambda.Host.Core; /// diff --git a/src/AwsLambda.Host/Core/Features/DefaultResponseFeatureProvider.cs b/src/AwsLambda.Host/Core/Features/DefaultResponseFeatureProvider.cs index 25682d04..73e74ee6 100644 --- a/src/AwsLambda.Host/Core/Features/DefaultResponseFeatureProvider.cs +++ b/src/AwsLambda.Host/Core/Features/DefaultResponseFeatureProvider.cs @@ -1,9 +1,5 @@ -#region - using Amazon.Lambda.Core; -#endregion - namespace AwsLambda.Host.Core; /// diff --git a/src/AwsLambda.Host/Core/Features/EventFeatureProviderFactory.cs b/src/AwsLambda.Host/Core/Features/EventFeatureProviderFactory.cs index 0560ad53..39b16364 100644 --- a/src/AwsLambda.Host/Core/Features/EventFeatureProviderFactory.cs +++ b/src/AwsLambda.Host/Core/Features/EventFeatureProviderFactory.cs @@ -1,9 +1,5 @@ -#region - using Amazon.Lambda.Core; -#endregion - namespace AwsLambda.Host.Core; internal class EventFeatureProviderFactory(ILambdaSerializer lambdaSerializer) diff --git a/src/AwsLambda.Host/Core/Features/ResponseFeatureProviderFactory.cs b/src/AwsLambda.Host/Core/Features/ResponseFeatureProviderFactory.cs index 28a270e5..6196a355 100644 --- a/src/AwsLambda.Host/Core/Features/ResponseFeatureProviderFactory.cs +++ b/src/AwsLambda.Host/Core/Features/ResponseFeatureProviderFactory.cs @@ -1,9 +1,5 @@ -#region - using Amazon.Lambda.Core; -#endregion - namespace AwsLambda.Host.Core; internal class ResponseFeatureProviderFactory(ILambdaSerializer lambdaSerializer) From da5ba7d49482c4f8f41e628cdd4ea5098a64e3a6 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 19:42:55 -0500 Subject: [PATCH 44/48] refactor(lambda-host): replace ICollection with List in LambdaHostContextFactory - Updated `AddIfPresent` method to use `List` instead of `ICollection`. - Improves clarity and ensures compatibility with existing method usage. --- src/AwsLambda.Host/Core/Context/LambdaHostContextFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AwsLambda.Host/Core/Context/LambdaHostContextFactory.cs b/src/AwsLambda.Host/Core/Context/LambdaHostContextFactory.cs index fa7977e3..bf8505fa 100644 --- a/src/AwsLambda.Host/Core/Context/LambdaHostContextFactory.cs +++ b/src/AwsLambda.Host/Core/Context/LambdaHostContextFactory.cs @@ -60,7 +60,7 @@ private static IFeatureProvider[] CreateFeatureProviders( private static void AddIfPresent( IDictionary properties, string key, - ICollection target + List target ) { if (properties.TryGetValue(key, out var value) && value is IFeatureProvider provider) From cbb85c1a1c3b39ced6c556778a40810d7c807859 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 19:54:32 -0500 Subject: [PATCH 45/48] test(lambda-host): add unit test for feature collection creation in LambdaHostContextFactory - Added a test to validate `Create` method retrieves features from properties. - Ensured `featureCollectionFactory` correctly receives the expected feature providers. --- .../Context/LambdaHostContextFactoryTests.cs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/AwsLambda.Host.UnitTests/Core/Context/LambdaHostContextFactoryTests.cs b/tests/AwsLambda.Host.UnitTests/Core/Context/LambdaHostContextFactoryTests.cs index db370497..009bb927 100644 --- a/tests/AwsLambda.Host.UnitTests/Core/Context/LambdaHostContextFactoryTests.cs +++ b/tests/AwsLambda.Host.UnitTests/Core/Context/LambdaHostContextFactoryTests.cs @@ -96,4 +96,36 @@ internal void Create_WithContextAccessor_SetsContextOnAccessor( // Assert contextAccessor!.LambdaHostContext.Should().NotBeNull(); } + + [Theory] + [AutoNSubstituteData] + internal void Create_GetsFeaturesFromProperties( + [Frozen] IFeatureCollectionFactory featureCollectionFactory, + IFeatureProvider eventFeatureProvider, + IFeatureProvider responseFeatureProvider, + ILambdaHostContext lambdaContext, + LambdaHostContextFactory factory + ) + { + // Arrange + var properties = new Dictionary + { + [LambdaInvocationBuilder.EventFeatureProviderKey] = eventFeatureProvider, + [LambdaInvocationBuilder.ResponseFeatureProviderKey] = responseFeatureProvider, + }; + + // Act + _ = factory.Create(lambdaContext, properties, CancellationToken.None); + + // Assert + featureCollectionFactory + .Received(1) + .Create( + Arg.Is>(providers => + providers.Count() == 2 + && providers.Contains(eventFeatureProvider) + && providers.Contains(responseFeatureProvider) + ) + ); + } } From 6c3e7ffd43d3b61adaca258e8cff4e947482e1d2 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Wed, 3 Dec 2025 20:00:20 -0500 Subject: [PATCH 46/48] test(lambda-host): add unit tests for feature provider factories - Added tests for `ResponseFeatureProviderFactory` to validate the `Create` method. - Ensured it returns a `DefaultResponseFeatureProvider`. - Verified it implements `IFeatureProvider`. - Added tests for `EventFeatureProviderFactory` to validate the `Create` method. - Ensured it returns a `DefaultEventFeatureProvider`. - Verified it implements `IFeatureProvider`. --- .../EventFeatureProviderFactoryTest.cs | 27 +++++++++++++++++++ .../ResponseFeatureProviderFactoryTest.cs | 27 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 tests/AwsLambda.Host.UnitTests/Core/Features/EventFeatureProviderFactoryTest.cs create mode 100644 tests/AwsLambda.Host.UnitTests/Core/Features/ResponseFeatureProviderFactoryTest.cs diff --git a/tests/AwsLambda.Host.UnitTests/Core/Features/EventFeatureProviderFactoryTest.cs b/tests/AwsLambda.Host.UnitTests/Core/Features/EventFeatureProviderFactoryTest.cs new file mode 100644 index 00000000..8ddd3b6e --- /dev/null +++ b/tests/AwsLambda.Host.UnitTests/Core/Features/EventFeatureProviderFactoryTest.cs @@ -0,0 +1,27 @@ +namespace AwsLambda.Host.UnitTests.Core.Features; + +[TestSubject(typeof(EventFeatureProviderFactory))] +public class EventFeatureProviderFactoryTest +{ + [Theory] + [AutoNSubstituteData] + internal void Create_ReturnsDefaultEventFeatureProvider(EventFeatureProviderFactory sut) + { + // Act + var provider = sut.Create(); + + // Assert + provider.Should().BeOfType>(); + } + + [Theory] + [AutoNSubstituteData] + internal void Create_ReturnsIFeatureProvider(EventFeatureProviderFactory sut) + { + // Act + var provider = sut.Create(); + + // Assert + provider.Should().BeAssignableTo(); + } +} diff --git a/tests/AwsLambda.Host.UnitTests/Core/Features/ResponseFeatureProviderFactoryTest.cs b/tests/AwsLambda.Host.UnitTests/Core/Features/ResponseFeatureProviderFactoryTest.cs new file mode 100644 index 00000000..ee375d57 --- /dev/null +++ b/tests/AwsLambda.Host.UnitTests/Core/Features/ResponseFeatureProviderFactoryTest.cs @@ -0,0 +1,27 @@ +namespace AwsLambda.Host.UnitTests.Core.Features; + +[TestSubject(typeof(ResponseFeatureProviderFactory))] +public class ResponseFeatureProviderFactoryTest +{ + [Theory] + [AutoNSubstituteData] + internal void Create_ReturnsDefaultEventFeatureProvider(ResponseFeatureProviderFactory sut) + { + // Act + var provider = sut.Create(); + + // Assert + provider.Should().BeOfType>(); + } + + [Theory] + [AutoNSubstituteData] + internal void Create_ReturnsIFeatureProvider(ResponseFeatureProviderFactory sut) + { + // Act + var provider = sut.Create(); + + // Assert + provider.Should().BeAssignableTo(); + } +} From 5d93cf2bf6e1984f961516e36b9c038ca540e43b Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Thu, 4 Dec 2025 17:01:33 -0500 Subject: [PATCH 47/48] docs(opentelemetry): remove redundant section on middleware flexibility - Removed a repetitive section detailing middleware's seamless support for multiple event/response types. - Streamlined the documentation to improve clarity and focus on core OpenTelemetry features. --- docs/features/open_telemetry.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/docs/features/open_telemetry.md b/docs/features/open_telemetry.md index 0e83dad3..f75a64d7 100644 --- a/docs/features/open_telemetry.md +++ b/docs/features/open_telemetry.md @@ -124,12 +124,6 @@ Here's the step-by-step process: 4. These event and response objects are passed to the official `OpenTelemetry.Instrumentation.AWSLambda` package, which wraps the handler execution in a root trace span. 5. The OpenTelemetry instrumentation automatically extracts trace context from supported event types (like API Gateway requests), ensuring proper distributed trace propagation across services. -This approach is both efficient and flexible. Because event and response types are determined at runtime from the feature collection, the same middleware works seamlessly with: - -- Multiple handlers registered via `MapHandler()` with different event/response types -- Handlers with or without events/responses -- Any AWS Lambda event source type - The shutdown helpers (`OnShutdownFlushOpenTelemetry`, `OnShutdownFlushTracer`, and `OnShutdownFlushMeter`) are regular extension methods that execute at runtime and use the registered `TracerProvider`/`MeterProvider` instances to force-flush telemetry before Lambda freezes the environment. --- @@ -163,8 +157,6 @@ This method registers middleware in the invocation pipeline that wraps each hand Because the middleware reads event and response types dynamically from the feature collection, it works seamlessly with any Lambda event source type. The OpenTelemetry instrumentation can correctly extract context and attributes from strongly-typed event objects (such as trace parent headers from an API Gateway request), ensuring proper distributed trace propagation across your services. -This dynamic approach also enables you to register multiple handlers with different event types in the same Lambda function—the middleware automatically adapts to whichever handler executes. - ### Gracefully Shutdown & Cleaning Up From 197243eaeaef78099edec9507dd258542bb608b5 Mon Sep 17 00:00:00 2001 From: Jonas Ha Date: Thu, 4 Dec 2025 17:03:02 -0500 Subject: [PATCH 48/48] docs(middleware): improve table formatting for type-safe feature methods - Adjusted column alignment for better readability in type-safe feature methods table. - Ensured consistent spacing and formatting across all method descriptions. --- docs/guides/middleware.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/guides/middleware.md b/docs/guides/middleware.md index 0c7da272..6e1a6eb3 100644 --- a/docs/guides/middleware.md +++ b/docs/guides/middleware.md @@ -150,14 +150,14 @@ lambda.UseMiddleware(async (context, next) => **Available Methods:** -| Method | Description | Returns | -|--------|-------------|---------| -| `GetEvent()` | Returns event or `null` if not found | `T?` | -| `GetResponse()` | Returns response or `null` if not found | `T?` | -| `TryGetEvent(out T)` | Try-pattern for safe event access | `bool` | -| `TryGetResponse(out T)` | Try-pattern for safe response access | `bool` | -| `GetRequiredEvent()` | Returns event or throws | `T` (throws `InvalidOperationException`) | -| `GetRequiredResponse()` | Returns response or throws | `T` (throws `InvalidOperationException`) | +| Method | Description | Returns | +|----------------------------|-----------------------------------------|------------------------------------------| +| `GetEvent()` | Returns event or `null` if not found | `T?` | +| `GetResponse()` | Returns response or `null` if not found | `T?` | +| `TryGetEvent(out T)` | Try-pattern for safe event access | `bool` | +| `TryGetResponse(out T)` | Try-pattern for safe response access | `bool` | +| `GetRequiredEvent()` | Returns event or throws | `T` (throws `InvalidOperationException`) | +| `GetRequiredResponse()` | Returns response or throws | `T` (throws `InvalidOperationException`) | **When to use each:**