diff --git a/Directory.Build.props b/Directory.Build.props index a3f9256e..67706273 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - 2.0.0-beta.9 + 2.0.0-beta.10 MIT diff --git a/src/MinimalLambda.SourceGenerators/Extensions/DelegateInfoExtensions.cs b/src/MinimalLambda.SourceGenerators/Extensions/DelegateInfoExtensions.cs index b2355feb..c9d968c0 100644 --- a/src/MinimalLambda.SourceGenerators/Extensions/DelegateInfoExtensions.cs +++ b/src/MinimalLambda.SourceGenerators/Extensions/DelegateInfoExtensions.cs @@ -6,51 +6,12 @@ namespace MinimalLambda.SourceGenerators.Extensions; internal static class DelegateInfoExtensions { - internal static string BuildHandlerSignature(this DelegateInfo delegateInfo) - { - // build handler function signature - var signatureBuilder = new StringBuilder(); - signatureBuilder.Append(delegateInfo.DelegateType); - - // angle brackets needed for any parameters or a response type - if ( - delegateInfo.Parameters.Count > 0 - || delegateInfo.ReturnTypeInfo.FullyQualifiedType != TypeConstants.Void - ) - { - signatureBuilder.Append("<"); - - // join parameters with comma - if (delegateInfo.Parameters.Count > 0) - signatureBuilder.Append( - string.Join( - ", ", - delegateInfo.Parameters.Select(p => p.TypeInfo.FullyQualifiedType) - ) - ); - - if (delegateInfo.ReturnTypeInfo.FullyQualifiedType != TypeConstants.Void) - { - // add comma if there are parameters, i.e. this is the last in the list - if (delegateInfo.Parameters.Count > 0) - signatureBuilder.Append(", "); - signatureBuilder.Append(delegateInfo.ReturnTypeInfo.FullyQualifiedType); - } - - signatureBuilder.Append(">"); - } - - var handlerSignature = signatureBuilder.ToString(); - - return handlerSignature; - } - extension(DelegateInfo delegateInfo) { internal string BuildHandlerCastCall() { var signatureBuilder = new StringBuilder(); - signatureBuilder.Append("Cast(handler, "); + signatureBuilder.Append("Utilities.Cast(handler, "); signatureBuilder.Append(delegateInfo.ReturnTypeInfo.FullyQualifiedType); diff --git a/src/MinimalLambda.SourceGenerators/OutputGenerators/LambdaHostOutputGenerator.cs b/src/MinimalLambda.SourceGenerators/OutputGenerators/LambdaHostOutputGenerator.cs index b0578109..f9a88a0a 100644 --- a/src/MinimalLambda.SourceGenerators/OutputGenerators/LambdaHostOutputGenerator.cs +++ b/src/MinimalLambda.SourceGenerators/OutputGenerators/LambdaHostOutputGenerator.cs @@ -29,7 +29,23 @@ string generatorVersion var generatedCodeAttribute = $"[GeneratedCode(\"{generatorName}\", \"{generatorVersion}\")]"; - List outputs = [CommonSources.Generate(generatedCodeAttribute)]; + List outputs = + [ + CommonSources.Generate(generatedCodeAttribute), + """ + namespace MinimalLambda.Generated + { + using System; + using System.CodeDom.Compiler; + using System.Runtime.CompilerServices; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; + + """, + ]; // if MapHandler calls found, generate the source code. if (compilationInfo.MapHandlerInvocationInfos.Count >= 1) @@ -67,6 +83,16 @@ string generatorVersion ) ); + outputs.Add( + """ + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } + } + """ + ); + // join all the source code together and add it to the compilation context. var outCode = string.Join("\n", outputs.Where(s => s != null)); diff --git a/src/MinimalLambda.SourceGenerators/OutputGenerators/MapHandlerSources.cs b/src/MinimalLambda.SourceGenerators/OutputGenerators/MapHandlerSources.cs index 8acd93e8..3617a72b 100644 --- a/src/MinimalLambda.SourceGenerators/OutputGenerators/MapHandlerSources.cs +++ b/src/MinimalLambda.SourceGenerators/OutputGenerators/MapHandlerSources.cs @@ -18,7 +18,7 @@ string generatedCodeAttribute var delegateInfo = mapHandlerInvocationInfo.DelegateInfo; // build handler function signature - var handlerSignature = delegateInfo.BuildHandlerSignature(); + var handlerSignature = delegateInfo.BuildHandlerCastCall(); // build out assignment statements for each handler parameter var handlerArgs = delegateInfo.BuildHandlerParameterAssignment(); diff --git a/src/MinimalLambda.SourceGenerators/Templates/GenericHandler.scriban b/src/MinimalLambda.SourceGenerators/Templates/GenericHandler.scriban index 6773aac6..c0ac89ce 100644 --- a/src/MinimalLambda.SourceGenerators/Templates/GenericHandler.scriban +++ b/src/MinimalLambda.SourceGenerators/Templates/GenericHandler.scriban @@ -1,13 +1,3 @@ -namespace MinimalLambda.Generated -{ - using System; - using System.CodeDom.Compiler; - using System.Runtime.CompilerServices; - using System.Threading; - using System.Threading.Tasks; - using Microsoft.Extensions.DependencyInjection; - using MinimalLambda.Builder; - {{ generated_code_attribute }} file static class GeneratedLambda{{ name }}BuilderExtensions { @@ -50,7 +40,4 @@ namespace MinimalLambda.Generated {{~ end ~}} {{~ end ~}} - - private static T Cast(Delegate d, T _) where T : Delegate => (T)d; - } -} \ No newline at end of file + } \ No newline at end of file diff --git a/src/MinimalLambda.SourceGenerators/Templates/MapHandler.scriban b/src/MinimalLambda.SourceGenerators/Templates/MapHandler.scriban index 064166ed..65412123 100644 --- a/src/MinimalLambda.SourceGenerators/Templates/MapHandler.scriban +++ b/src/MinimalLambda.SourceGenerators/Templates/MapHandler.scriban @@ -1,13 +1,3 @@ -namespace MinimalLambda.Generated -{ - using System; - using System.CodeDom.Compiler; - using System.Runtime.CompilerServices; - using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; - using Microsoft.Extensions.DependencyInjection; - {{ generated_code_attribute }} file static class GeneratedLambdaInvocationBuilderExtensions { @@ -21,7 +11,7 @@ namespace MinimalLambda.Generated Delegate handler ) { - var castHandler = ({{ call.handler_signature }})handler; + var castHandler = {{ call.handler_signature }}; application.Handle(InvocationDelegate); {{~ if call.is_event_feature_required ~}} @@ -72,4 +62,3 @@ namespace MinimalLambda.Generated } {{~ end ~}} } -} diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_AllInputSources#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_AllInputSources#LambdaHandler.g.verified.cs index d9547b17..66e8ea10 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_AllInputSources#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_AllInputSources#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Action)handler; + var castHandler = Utilities.Cast(handler, void (string arg0, global::Amazon.Lambda.Core.ILambdaContext arg1, global::System.Threading.CancellationToken arg2, global::IService arg3, global::IService? arg4, global::IService arg5, global::IService? arg6) => throw null!); application.Handle(InvocationDelegate); @@ -84,4 +85,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_Async_ReturnTaskString_TypeCast#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_Async_ReturnTaskString_TypeCast#LambdaHandler.g.verified.cs index 7708b2c4..e50f5e46 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_Async_ReturnTaskString_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_Async_ReturnTaskString_TypeCast#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func>)handler; + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task () => throw null!); application.Handle(InvocationDelegate); @@ -70,4 +71,9 @@ async Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoReturn_TypeCast#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoReturn_TypeCast#LambdaHandler.g.verified.cs index 5d15ec81..1da56490 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoReturn_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoReturn_TypeCast#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Action)handler; + var castHandler = Utilities.Cast(handler, void (string arg0, global::IService arg1) => throw null!); application.Handle(InvocationDelegate); @@ -70,4 +71,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoTypeInfo_TypeCast#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoTypeInfo_TypeCast#LambdaHandler.g.verified.cs index 45b13bf9..096bf646 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoTypeInfo_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_NoTypeInfo_TypeCast#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func)handler; + var castHandler = Utilities.Cast(handler, string (global::IService arg0, string arg1) => throw null!); application.Handle(InvocationDelegate); @@ -75,4 +76,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnExplicitType#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnExplicitType#LambdaHandler.g.verified.cs index 70c6ad3d..c26eb98f 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnExplicitType#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnExplicitType#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func)handler; + var castHandler = Utilities.Cast(handler, global::IService (string arg0, global::IService arg1) => throw null!); application.Handle(InvocationDelegate); @@ -80,4 +81,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnImplicitNullable#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnImplicitNullable#LambdaHandler.g.verified.cs index 7b3af26b..42e204f7 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnImplicitNullable#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnImplicitNullable#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func)handler; + var castHandler = Utilities.Cast(handler, string? (string arg0, global::IService arg1) => throw null!); application.Handle(InvocationDelegate); @@ -80,4 +81,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnString#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnString#LambdaHandler.g.verified.cs index 787c54f4..d40cbf4b 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnString#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnString#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func)handler; + var castHandler = Utilities.Cast(handler, string (string arg0) => throw null!); application.Handle(InvocationDelegate); @@ -78,4 +79,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnTaskString#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnTaskString#LambdaHandler.g.verified.cs index 85ef2be6..aaa0ec54 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnTaskString#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnTaskString#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func>)handler; + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task () => throw null!); application.Handle(InvocationDelegate); @@ -70,4 +71,9 @@ async Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnsTask_TypeCast#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnsTask_TypeCast#LambdaHandler.g.verified.cs index f4c1f850..103038d7 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnsTask_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_ReturnsTask_TypeCast#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func)handler; + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task () => throw null!); application.Handle(InvocationDelegate); @@ -60,4 +61,9 @@ async Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_StreamResponse#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_StreamResponse#LambdaHandler.g.verified.cs index a3e4f07f..815b2c5a 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_StreamResponse#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_StreamResponse#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func)handler; + var castHandler = Utilities.Cast(handler, global::System.IO.Stream () => throw null!); application.Handle(InvocationDelegate); @@ -62,4 +63,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast#LambdaHandler.g.verified.cs index 68af78be..e02cc045 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func)handler; + var castHandler = Utilities.Cast(handler, string (global::IService arg0) => throw null!); application.Handle(InvocationDelegate); @@ -73,4 +74,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast_InputFromKeyedServices#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast_InputFromKeyedServices#LambdaHandler.g.verified.cs index 5fa24d89..768f73eb 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast_InputFromKeyedServices#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/BlockLambdaVerifyTests.Test_BlockLambda_TypeCast_InputFromKeyedServices#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func)handler; + var castHandler = Utilities.Cast(handler, string (global::IService arg0) => throw null!); application.Handle(InvocationDelegate); @@ -77,4 +78,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationToken#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationToken#LambdaHandler.g.verified.cs index e2e074a1..601afc80 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationToken#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationToken#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func)handler; + var castHandler = Utilities.Cast(handler, string (global::System.Threading.CancellationToken arg0) => throw null!); application.Handle(InvocationDelegate); @@ -73,4 +74,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaContext#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaContext#LambdaHandler.g.verified.cs index 7eb07d44..ce5b5110 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaContext#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaContext#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func)handler; + var castHandler = Utilities.Cast(handler, string (global::System.Threading.CancellationToken arg0, global::Amazon.Lambda.Core.ILambdaContext arg1) => throw null!); application.Handle(InvocationDelegate); @@ -75,4 +76,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaHostContext#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaHostContext#LambdaHandler.g.verified.cs index a85a4c2d..070aa8ab 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaHostContext#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaHostContext#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -75,4 +76,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaInvocationContext#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaInvocationContext#LambdaHandler.g.verified.cs index 90b43b41..aa830755 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaInvocationContext#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_AsksForCancellationTokenAndLambdaInvocationContext#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func)handler; + var castHandler = Utilities.Cast(handler, string (global::System.Threading.CancellationToken arg0, global::MinimalLambda.ILambdaInvocationContext arg1) => throw null!); application.Handle(InvocationDelegate); @@ -75,4 +76,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_Async_ReturnExplicitTask#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_Async_ReturnExplicitTask#LambdaHandler.g.verified.cs index c1cb4fa4..3e341988 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_Async_ReturnExplicitTask#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_Async_ReturnExplicitTask#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func)handler; + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task () => throw null!); application.Handle(InvocationDelegate); @@ -60,4 +61,9 @@ async Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ComplexInput_ComplexOutput#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ComplexInput_ComplexOutput#LambdaHandler.g.verified.cs index cdee1880..5d2a6c8b 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ComplexInput_ComplexOutput#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ComplexInput_ComplexOutput#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func>)handler; + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task (global::CustomRequest arg0, global::IService arg1, global::Amazon.Lambda.Core.ILambdaContext arg2) => throw null!); application.Handle(InvocationDelegate); @@ -81,4 +82,9 @@ async Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ExplicitVoid#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ExplicitVoid#LambdaHandler.g.verified.cs index d8cc1abf..509e38cb 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ExplicitVoid#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ExplicitVoid#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Action)handler; + var castHandler = Utilities.Cast(handler, void () => throw null!); application.Handle(InvocationDelegate); @@ -61,4 +62,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_Async#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_Async#LambdaHandler.g.verified.cs index f00b01f7..4bfa8c8f 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_Async#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_Async#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func>)handler; + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task (string arg0, global::IService arg1) => throw null!); application.Handle(InvocationDelegate); @@ -79,4 +80,9 @@ async Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait#LambdaHandler.g.verified.cs index a2395ad0..49d281e5 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func>)handler; + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task (string arg0, global::IService arg1) => throw null!); application.Handle(InvocationDelegate); @@ -79,4 +80,9 @@ async Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait_EventAndResponseDifferentNamespace#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait_EventAndResponseDifferentNamespace#LambdaHandler.g.verified.cs index 3581561d..50934deb 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait_EventAndResponseDifferentNamespace#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputDi_AsyncAndAwait_EventAndResponseDifferentNamespace#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func>)handler; + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task (global::MyNamespace.Event arg0, global::IService arg1) => throw null!); application.Handle(InvocationDelegate); @@ -79,4 +80,9 @@ async Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputStream#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputStream#LambdaHandler.g.verified.cs index 1aaada7d..bbb0899a 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputStream#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_InputStream#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Action)handler; + var castHandler = Utilities.Cast(handler, void (global::System.IO.Stream arg0) => throw null!); application.Handle(InvocationDelegate); @@ -63,4 +64,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_MainOverload_DeserializerSerializer_NoOp#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_MainOverload_DeserializerSerializer_NoOp#LambdaHandler.g.verified.cs index a80f8bfe..3292b240 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_MainOverload_DeserializerSerializer_NoOp#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_MainOverload_DeserializerSerializer_NoOp#LambdaHandler.g.verified.cs @@ -25,3 +25,20 @@ public InterceptsLocationAttribute(int version, string data) } } } + +namespace MinimalLambda.Generated +{ + using System; + using System.CodeDom.Compiler; + using System.Runtime.CompilerServices; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_MainOverload_NoOp#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_MainOverload_NoOp#LambdaHandler.g.verified.cs index a80f8bfe..3292b240 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_MainOverload_NoOp#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_MainOverload_NoOp#LambdaHandler.g.verified.cs @@ -25,3 +25,20 @@ public InterceptsLocationAttribute(int version, string data) } } } + +namespace MinimalLambda.Generated +{ + using System; + using System.CodeDom.Compiler; + using System.Runtime.CompilerServices; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_NoOutput#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_NoOutput#LambdaHandler.g.verified.cs index c470cab5..33970eac 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_NoOutput#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_NoOutput#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Action)handler; + var castHandler = Utilities.Cast(handler, void () => throw null!); application.Handle(InvocationDelegate); @@ -61,4 +62,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnGenericObject#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnGenericObject#LambdaHandler.g.verified.cs index 650e7f57..2caaa6b6 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnGenericObject#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnGenericObject#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func>)handler; + var castHandler = Utilities.Cast(handler, global::Response () => throw null!); application.Handle(InvocationDelegate); @@ -71,4 +72,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnNullablePrimitive#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnNullablePrimitive#LambdaHandler.g.verified.cs index ac7589f6..5ea10459 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnNullablePrimitive#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnNullablePrimitive#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func)handler; + var castHandler = Utilities.Cast(handler, int? () => throw null!); application.Handle(InvocationDelegate); @@ -71,4 +72,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnString#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnString#LambdaHandler.g.verified.cs index 9637f4e8..9f7c3a9d 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnString#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NoInput_ReturnString#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func)handler; + var castHandler = Utilities.Cast(handler, string () => throw null!); application.Handle(InvocationDelegate); @@ -71,4 +72,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnExplicitNullable#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnExplicitNullable#LambdaHandler.g.verified.cs index 333f4a3c..4a7d5bf1 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnExplicitNullable#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnExplicitNullable#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func)handler; + var castHandler = Utilities.Cast(handler, string? (int? arg0, global::IService arg1) => throw null!); application.Handle(InvocationDelegate); @@ -80,4 +81,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnImplicitNullable#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnImplicitNullable#LambdaHandler.g.verified.cs index eca587c8..458120d1 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnImplicitNullable#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_NullableInput_ReturnImplicitNullable#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func)handler; + var castHandler = Utilities.Cast(handler, string? (string? arg0, global::IService arg1) => throw null!); application.Handle(InvocationDelegate); @@ -80,4 +81,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitTask#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitTask#LambdaHandler.g.verified.cs index a1202122..2e6a84af 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitTask#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitTask#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func)handler; + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task () => throw null!); application.Handle(InvocationDelegate); @@ -60,4 +61,9 @@ async Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitType#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitType#LambdaHandler.g.verified.cs index 8f84dfd7..210b0189 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitType#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/ExpressionLambdaVerifyTests.Test_ExpressionLambda_ReturnExplicitType#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func)handler; + var castHandler = Utilities.Cast(handler, global::IService (string arg0) => throw null!); application.Handle(InvocationDelegate); @@ -78,4 +79,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_FloatingPointTypes#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_FloatingPointTypes#LambdaHandler.g.verified.cs index 338267ac..d9a3dc09 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_FloatingPointTypes#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_FloatingPointTypes#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Action)handler; + var castHandler = Utilities.Cast(handler, void (global::IService arg0, global::IService arg1) => throw null!); application.Handle(InvocationDelegate); @@ -69,4 +70,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_IntAndLongKeys#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_IntAndLongKeys#LambdaHandler.g.verified.cs index a7f082ac..a13640ae 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_IntAndLongKeys#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_IntAndLongKeys#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Action)handler; + var castHandler = Utilities.Cast(handler, void (global::IService arg0, global::IService arg1) => throw null!); application.Handle(InvocationDelegate); @@ -69,4 +70,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_OtherTypes#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_OtherTypes#LambdaHandler.g.verified.cs index e8c9e8dd..f85cfd33 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_OtherTypes#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_OtherTypes#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Action)handler; + var castHandler = Utilities.Cast(handler, void (global::IService arg0, global::IService arg1, global::IService arg2, global::IService arg3) => throw null!); application.Handle(InvocationDelegate); @@ -73,4 +74,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_SmallIntegerTypes#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_SmallIntegerTypes#LambdaHandler.g.verified.cs index 3afbd2d3..504f7e0a 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_SmallIntegerTypes#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_SmallIntegerTypes#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Action)handler; + var castHandler = Utilities.Cast(handler, void (global::IService arg0, global::IService arg1, global::IService arg2) => throw null!); application.Handle(InvocationDelegate); @@ -71,4 +72,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_StringAndEnumKeys#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_StringAndEnumKeys#LambdaHandler.g.verified.cs index 29562dd2..297c71c7 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_StringAndEnumKeys#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_StringAndEnumKeys#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Action)handler; + var castHandler = Utilities.Cast(handler, void (global::IService arg0, global::IService arg1, global::IService arg2) => throw null!); application.Handle(InvocationDelegate); @@ -71,4 +72,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_UnsignedIntegerTypes#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_UnsignedIntegerTypes#LambdaHandler.g.verified.cs index ab31a1b0..ffe5e30d 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_UnsignedIntegerTypes#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/KeyedServiceVerifyTests.Test_KeyedService_UnsignedIntegerTypes#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Action)handler; + var castHandler = Utilities.Cast(handler, void (global::IService arg0, global::IService arg1, global::IService arg2) => throw null!); application.Handle(InvocationDelegate); @@ -71,4 +72,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_AsyncVoid#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_AsyncVoid#LambdaHandler.g.verified.cs index 1b268c2b..9cc48423 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_AsyncVoid#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_AsyncVoid#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Action)handler; + var castHandler = Utilities.Cast(handler, void () => throw null!); application.Handle(InvocationDelegate); @@ -61,4 +62,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_Async_ReturnTaskString#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_Async_ReturnTaskString#LambdaHandler.g.verified.cs index 607c88dd..3eca0a20 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_Async_ReturnTaskString#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_Async_ReturnTaskString#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func>)handler; + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task () => throw null!); application.Handle(InvocationDelegate); @@ -70,4 +71,9 @@ async Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_InputDiKeyedServices#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_InputDiKeyedServices#LambdaHandler.g.verified.cs index fc7d06fe..d3693a09 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_InputDiKeyedServices#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_InputDiKeyedServices#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func)handler; + var castHandler = Utilities.Cast(handler, string (string arg0, global::Amazon.Lambda.Core.ILambdaContext arg1, global::IService arg2) => throw null!); application.Handle(InvocationDelegate); @@ -86,4 +87,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast#LambdaHandler.g.verified.cs index 8f0f5d1d..9b9f49bd 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func)handler; + var castHandler = Utilities.Cast(handler, int () => throw null!); application.Handle(InvocationDelegate); @@ -71,4 +72,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast_Static#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast_Static#LambdaHandler.g.verified.cs index b09c941a..b2b3b69d 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast_Static#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_BlockBody_TypeCast_Static#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func)handler; + var castHandler = Utilities.Cast(handler, int () => throw null!); application.Handle(InvocationDelegate); @@ -71,4 +72,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_NoInput_NoOutput#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_NoInput_NoOutput#LambdaHandler.g.verified.cs index 539c0454..1f04e62f 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_NoInput_NoOutput#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_NoInput_NoOutput#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Action)handler; + var castHandler = Utilities.Cast(handler, void () => throw null!); application.Handle(InvocationDelegate); @@ -61,4 +62,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTask#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTask#LambdaHandler.g.verified.cs index 3d471640..a591863b 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTask#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTask#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func)handler; + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task () => throw null!); application.Handle(InvocationDelegate); @@ -60,4 +61,9 @@ async Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTaskString#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTaskString#LambdaHandler.g.verified.cs index 18d5e82a..513ea52f 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTaskString#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_ReturnTaskString#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func>)handler; + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task () => throw null!); application.Handle(InvocationDelegate); @@ -70,4 +71,9 @@ async Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_TypeCast_ExtraParentheses#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_TypeCast_ExtraParentheses#LambdaHandler.g.verified.cs index 1cd2ae85..d09f2e0e 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_TypeCast_ExtraParentheses#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/MethodHandlerVerifyTests.Test_MethodHandler_TypeCast_ExtraParentheses#LambdaHandler.g.verified.cs @@ -31,10 +31,11 @@ namespace MinimalLambda.Generated using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; + using System.Threading; using System.Threading.Tasks; - using MinimalLambda.Builder; - using MinimalLambda; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] file static class GeneratedLambdaInvocationBuilderExtensions @@ -48,7 +49,7 @@ internal static ILambdaInvocationBuilder MapHandlerInterceptor0( Delegate handler ) { - var castHandler = (global::System.Func)handler; + var castHandler = Utilities.Cast(handler, int () => throw null!); application.Handle(InvocationDelegate); @@ -71,4 +72,9 @@ Task InvocationDelegate(ILambdaInvocationContext context) } } } -} + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_BaseMethodCall#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_BaseMethodCall#LambdaHandler.g.verified.cs index a80f8bfe..3292b240 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_BaseMethodCall#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_BaseMethodCall#LambdaHandler.g.verified.cs @@ -25,3 +25,20 @@ public InterceptsLocationAttribute(int version, string data) } } } + +namespace MinimalLambda.Generated +{ + using System; + using System.CodeDom.Compiler; + using System.Runtime.CompilerServices; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_ExplicitReturnTypeAsync#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_ExplicitReturnTypeAsync#LambdaHandler.g.verified.cs index 3916e9aa..1f07f280 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_ExplicitReturnTypeAsync#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_ExplicitReturnTypeAsync#LambdaHandler.g.verified.cs @@ -34,6 +34,7 @@ namespace MinimalLambda.Generated using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] @@ -45,7 +46,7 @@ internal static ILambdaOnInitBuilder OnInitInterceptor0( Delegate handler ) { - var castHandler = Cast(handler, global::System.Threading.Tasks.Task () => throw null!); + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task () => throw null!); return application.OnInit(OnInit); @@ -55,7 +56,9 @@ Task OnInit(ILambdaLifecycleContext context) return response; } } - - private static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; } } \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_AsyncAndDi#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_AsyncAndDi#LambdaHandler.g.verified.cs index e02e2153..eeb5e49b 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_AsyncAndDi#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_AsyncAndDi#LambdaHandler.g.verified.cs @@ -34,6 +34,7 @@ namespace MinimalLambda.Generated using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] @@ -45,7 +46,7 @@ internal static ILambdaOnInitBuilder OnInitInterceptor0( Delegate handler ) { - var castHandler = Cast(handler, global::System.Threading.Tasks.Task (global::IService arg0) => throw null!); + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task (global::IService arg0) => throw null!); return application.OnInit(OnInit); @@ -57,7 +58,9 @@ Task OnInit(ILambdaLifecycleContext context) return response; } } - - private static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; } } \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_AsyncAndDiAndReturnUnexpectedType#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_AsyncAndDiAndReturnUnexpectedType#LambdaHandler.g.verified.cs index 6b3c3800..832a58c5 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_AsyncAndDiAndReturnUnexpectedType#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_AsyncAndDiAndReturnUnexpectedType#LambdaHandler.g.verified.cs @@ -34,6 +34,7 @@ namespace MinimalLambda.Generated using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] @@ -45,7 +46,7 @@ internal static ILambdaOnInitBuilder OnInitInterceptor0( Delegate handler ) { - var castHandler = Cast(handler, global::System.Threading.Tasks.Task (global::IService arg0) => throw null!); + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task (global::IService arg0) => throw null!); return application.OnInit(OnInit); @@ -57,7 +58,9 @@ async Task OnInit(ILambdaLifecycleContext context) return true; } } - - private static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; } } \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_NoDi#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_NoDi#LambdaHandler.g.verified.cs index 059d0efa..4ae6095d 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_NoDi#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MethodHandler_NoDi#LambdaHandler.g.verified.cs @@ -34,6 +34,7 @@ namespace MinimalLambda.Generated using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] @@ -45,7 +46,7 @@ internal static ILambdaOnInitBuilder OnInitInterceptor0( Delegate handler ) { - var castHandler = Cast(handler, global::System.Threading.Tasks.Task () => throw null!); + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task () => throw null!); return application.OnInit(OnInit); @@ -55,7 +56,9 @@ Task OnInit(ILambdaLifecycleContext context) return response; } } - - private static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; } } \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MultipleCalls#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MultipleCalls#LambdaHandler.g.verified.cs index 88ccff0f..b9d19caa 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MultipleCalls#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_MultipleCalls#LambdaHandler.g.verified.cs @@ -34,6 +34,7 @@ namespace MinimalLambda.Generated using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] @@ -45,7 +46,7 @@ internal static ILambdaOnInitBuilder OnInitInterceptor0( Delegate handler ) { - var castHandler = Cast(handler, global::System.Threading.Tasks.Task () => throw null!); + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task () => throw null!); return application.OnInit(OnInit); @@ -62,7 +63,7 @@ internal static ILambdaOnInitBuilder OnInitInterceptor1( Delegate handler ) { - var castHandler = Cast(handler, global::System.Threading.Tasks.Task (string? arg0, global::IService? arg1) => throw null!); + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task (string? arg0, global::IService? arg1) => throw null!); return application.OnInit(OnInit); @@ -83,7 +84,7 @@ internal static ILambdaOnInitBuilder OnInitInterceptor2( Delegate handler ) { - var castHandler = Cast(handler, global::System.Threading.Tasks.Task (string arg0, int arg1) => throw null!); + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task (string arg0, int arg1) => throw null!); return application.OnInit(OnInit); @@ -97,7 +98,9 @@ Task OnInit(ILambdaLifecycleContext context) return response; } } - - private static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; } } \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_NoOutput#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_NoOutput#LambdaHandler.g.verified.cs index 5d5f90b4..f210e9e1 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_NoOutput#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_NoOutput#LambdaHandler.g.verified.cs @@ -34,6 +34,7 @@ namespace MinimalLambda.Generated using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] @@ -45,7 +46,7 @@ internal static ILambdaOnInitBuilder OnInitInterceptor0( Delegate handler ) { - var castHandler = Cast(handler, void () => throw null!); + var castHandler = Utilities.Cast(handler, void () => throw null!); return application.OnInit(OnInit); @@ -55,7 +56,9 @@ Task OnInit(ILambdaLifecycleContext context) return Task.FromResult(true); } } - - private static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; } } \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnAsyncBool#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnAsyncBool#LambdaHandler.g.verified.cs index 160a2e50..0c39c041 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnAsyncBool#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnAsyncBool#LambdaHandler.g.verified.cs @@ -34,6 +34,7 @@ namespace MinimalLambda.Generated using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] @@ -45,7 +46,7 @@ internal static ILambdaOnInitBuilder OnInitInterceptor0( Delegate handler ) { - var castHandler = Cast(handler, global::System.Threading.Tasks.Task () => throw null!); + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task () => throw null!); return application.OnInit(OnInit); @@ -55,7 +56,9 @@ Task OnInit(ILambdaLifecycleContext context) return response; } } - - private static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; } } \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnBool#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnBool#LambdaHandler.g.verified.cs index bad28be5..f9e7737d 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnBool#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnBool#LambdaHandler.g.verified.cs @@ -34,6 +34,7 @@ namespace MinimalLambda.Generated using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] @@ -45,7 +46,7 @@ internal static ILambdaOnInitBuilder OnInitInterceptor0( Delegate handler ) { - var castHandler = Cast(handler, bool () => throw null!); + var castHandler = Utilities.Cast(handler, bool () => throw null!); return application.OnInit(OnInit); @@ -55,7 +56,9 @@ Task OnInit(ILambdaLifecycleContext context) return Task.FromResult(response); } } - - private static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; } } \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedType#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedType#LambdaHandler.g.verified.cs index b518ceb4..fbfcb9c8 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedType#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedType#LambdaHandler.g.verified.cs @@ -34,6 +34,7 @@ namespace MinimalLambda.Generated using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] @@ -45,7 +46,7 @@ internal static ILambdaOnInitBuilder OnInitInterceptor0( Delegate handler ) { - var castHandler = Cast(handler, string () => throw null!); + var castHandler = Utilities.Cast(handler, string () => throw null!); return application.OnInit(OnInit); @@ -55,7 +56,9 @@ Task OnInit(ILambdaLifecycleContext context) return Task.FromResult(true); } } - - private static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; } } \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedTypeAsync#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedTypeAsync#LambdaHandler.g.verified.cs index 9264f56b..77c03a6a 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedTypeAsync#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedTypeAsync#LambdaHandler.g.verified.cs @@ -34,6 +34,7 @@ namespace MinimalLambda.Generated using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] @@ -45,7 +46,7 @@ internal static ILambdaOnInitBuilder OnInitInterceptor0( Delegate handler ) { - var castHandler = Cast(handler, global::System.Threading.Tasks.Task () => throw null!); + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task () => throw null!); return application.OnInit(OnInit); @@ -55,7 +56,9 @@ async Task OnInit(ILambdaLifecycleContext context) return true; } } - - private static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; } } \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedTypeTask#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedTypeTask#LambdaHandler.g.verified.cs index eb832568..330cf8ff 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedTypeTask#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnNotExpectedTypeTask#LambdaHandler.g.verified.cs @@ -34,6 +34,7 @@ namespace MinimalLambda.Generated using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] @@ -45,7 +46,7 @@ internal static ILambdaOnInitBuilder OnInitInterceptor0( Delegate handler ) { - var castHandler = Cast(handler, global::System.Threading.Tasks.Task () => throw null!); + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task () => throw null!); return application.OnInit(OnInit); @@ -55,7 +56,9 @@ async Task OnInit(ILambdaLifecycleContext context) return true; } } - - private static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; } } \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnTaskBool#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnTaskBool#LambdaHandler.g.verified.cs index 38cfdad4..d4346a84 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnTaskBool#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NoInput_ReturnTaskBool#LambdaHandler.g.verified.cs @@ -34,6 +34,7 @@ namespace MinimalLambda.Generated using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] @@ -45,7 +46,7 @@ internal static ILambdaOnInitBuilder OnInitInterceptor0( Delegate handler ) { - var castHandler = Cast(handler, global::System.Threading.Tasks.Task () => throw null!); + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task () => throw null!); return application.OnInit(OnInit); @@ -55,7 +56,9 @@ Task OnInit(ILambdaLifecycleContext context) return response; } } - - private static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; } } \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NullableValueAndReferenceInputs#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NullableValueAndReferenceInputs#LambdaHandler.g.verified.cs index ff69dd98..b479edfe 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NullableValueAndReferenceInputs#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_NullableValueAndReferenceInputs#LambdaHandler.g.verified.cs @@ -34,6 +34,7 @@ namespace MinimalLambda.Generated using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] @@ -45,7 +46,7 @@ internal static ILambdaOnInitBuilder OnInitInterceptor0( Delegate handler ) { - var castHandler = Cast(handler, global::System.Threading.Tasks.Task (string? arg0, global::IService? arg1 = default) => throw null!); + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task (string? arg0, global::IService? arg1 = default) => throw null!); return application.OnInit(OnInit); @@ -59,7 +60,9 @@ Task OnInit(ILambdaLifecycleContext context) return response; } } - - private static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; } } \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_OneOfEachPossibleKindOfInput#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_OneOfEachPossibleKindOfInput#LambdaHandler.g.verified.cs index d46fb21d..aa5232f2 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_OneOfEachPossibleKindOfInput#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_OneOfEachPossibleKindOfInput#LambdaHandler.g.verified.cs @@ -34,6 +34,7 @@ namespace MinimalLambda.Generated using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] @@ -45,7 +46,7 @@ internal static ILambdaOnInitBuilder OnInitInterceptor0( Delegate handler ) { - var castHandler = Cast(handler, global::System.Threading.Tasks.Task (global::System.Threading.CancellationToken arg0, global::IService arg1, global::IService? arg2, global::IService arg3, global::IService? arg4) => throw null!); + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task (global::System.Threading.CancellationToken arg0, global::IService arg1, global::IService? arg2, global::IService arg3, global::IService? arg4) => throw null!); return application.OnInit(OnInit); @@ -69,7 +70,9 @@ Task OnInit(ILambdaLifecycleContext context) return response; } } - - private static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; } } \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_PrimitiveInput#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_PrimitiveInput#LambdaHandler.g.verified.cs index 4cfbb8af..63fbaed7 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_PrimitiveInput#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnInitVerifyTests.Test_OnInit_PrimitiveInput#LambdaHandler.g.verified.cs @@ -34,6 +34,7 @@ namespace MinimalLambda.Generated using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] @@ -45,7 +46,7 @@ internal static ILambdaOnInitBuilder OnInitInterceptor0( Delegate handler ) { - var castHandler = Cast(handler, global::System.Threading.Tasks.Task (string arg0, int arg1) => throw null!); + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task (string arg0, int arg1) => throw null!); return application.OnInit(OnInit); @@ -59,7 +60,9 @@ Task OnInit(ILambdaLifecycleContext context) return response; } } - - private static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; } } \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_BaseMethodCall#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_BaseMethodCall#LambdaHandler.g.verified.cs index a80f8bfe..3292b240 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_BaseMethodCall#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_BaseMethodCall#LambdaHandler.g.verified.cs @@ -25,3 +25,20 @@ public InterceptsLocationAttribute(int version, string data) } } } + +namespace MinimalLambda.Generated +{ + using System; + using System.CodeDom.Compiler; + using System.Runtime.CompilerServices; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; + using MinimalLambda.Builder; + + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } +} \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_BlockLambda_ReturnsImplicitVoid#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_BlockLambda_ReturnsImplicitVoid#LambdaHandler.g.verified.cs index e1ca9637..8360f6b0 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_BlockLambda_ReturnsImplicitVoid#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_BlockLambda_ReturnsImplicitVoid#LambdaHandler.g.verified.cs @@ -34,6 +34,7 @@ namespace MinimalLambda.Generated using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] @@ -45,7 +46,7 @@ internal static ILambdaOnShutdownBuilder OnShutdownInterceptor0( Delegate handler ) { - var castHandler = Cast(handler, void () => throw null!); + var castHandler = Utilities.Cast(handler, void () => throw null!); return application.OnShutdown(OnShutdown); @@ -55,7 +56,9 @@ Task OnShutdown(ILambdaLifecycleContext context) return Task.CompletedTask; } } - - private static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; } } \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_MultipleCalls#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_MultipleCalls#LambdaHandler.g.verified.cs index 43510c7f..3689ed3d 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_MultipleCalls#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_MultipleCalls#LambdaHandler.g.verified.cs @@ -34,6 +34,7 @@ namespace MinimalLambda.Generated using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] @@ -45,7 +46,7 @@ internal static ILambdaOnShutdownBuilder OnShutdownInterceptor0( Delegate handler ) { - var castHandler = Cast(handler, global::System.Threading.Tasks.Task () => throw null!); + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task () => throw null!); return application.OnShutdown(OnShutdown); @@ -62,7 +63,7 @@ internal static ILambdaOnShutdownBuilder OnShutdownInterceptor1( Delegate handler ) { - var castHandler = Cast(handler, global::System.Threading.Tasks.Task (string? arg0, global::IService? arg1) => throw null!); + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task (string? arg0, global::IService? arg1) => throw null!); return application.OnShutdown(OnShutdown); @@ -83,7 +84,7 @@ internal static ILambdaOnShutdownBuilder OnShutdownInterceptor2( Delegate handler ) { - var castHandler = Cast(handler, global::System.Threading.Tasks.Task (string arg0, int arg1) => throw null!); + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task (string arg0, int arg1) => throw null!); return application.OnShutdown(OnShutdown); @@ -97,7 +98,9 @@ Task OnShutdown(ILambdaLifecycleContext context) return response; } } - - private static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; } } \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput#LambdaHandler.g.verified.cs index c432fdb9..d55b8e3a 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput#LambdaHandler.g.verified.cs @@ -34,6 +34,7 @@ namespace MinimalLambda.Generated using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] @@ -45,7 +46,7 @@ internal static ILambdaOnShutdownBuilder OnShutdownInterceptor0( Delegate handler ) { - var castHandler = Cast(handler, global::System.Threading.Tasks.Task () => throw null!); + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task () => throw null!); return application.OnShutdown(OnShutdown); @@ -55,7 +56,9 @@ Task OnShutdown(ILambdaLifecycleContext context) return response; } } - - private static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; } } \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedType#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedType#LambdaHandler.g.verified.cs index 63388d28..c57b77a5 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedType#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedType#LambdaHandler.g.verified.cs @@ -34,6 +34,7 @@ namespace MinimalLambda.Generated using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] @@ -45,7 +46,7 @@ internal static ILambdaOnShutdownBuilder OnShutdownInterceptor0( Delegate handler ) { - var castHandler = Cast(handler, string () => throw null!); + var castHandler = Utilities.Cast(handler, string () => throw null!); return application.OnShutdown(OnShutdown); @@ -55,7 +56,9 @@ Task OnShutdown(ILambdaLifecycleContext context) return Task.CompletedTask; } } - - private static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; } } \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedTypeAsync#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedTypeAsync#LambdaHandler.g.verified.cs index 25554d6a..ec03e258 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedTypeAsync#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedTypeAsync#LambdaHandler.g.verified.cs @@ -34,6 +34,7 @@ namespace MinimalLambda.Generated using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] @@ -45,7 +46,7 @@ internal static ILambdaOnShutdownBuilder OnShutdownInterceptor0( Delegate handler ) { - var castHandler = Cast(handler, global::System.Threading.Tasks.Task () => throw null!); + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task () => throw null!); return application.OnShutdown(OnShutdown); @@ -54,7 +55,9 @@ async Task OnShutdown(ILambdaLifecycleContext context) await castHandler.Invoke(); } } - - private static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; } } \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedTypeTask#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedTypeTask#LambdaHandler.g.verified.cs index 8b42a3b8..c914ce1f 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedTypeTask#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NoInput_ReturnUnexpectedTypeTask#LambdaHandler.g.verified.cs @@ -34,6 +34,7 @@ namespace MinimalLambda.Generated using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] @@ -45,7 +46,7 @@ internal static ILambdaOnShutdownBuilder OnShutdownInterceptor0( Delegate handler ) { - var castHandler = Cast(handler, global::System.Threading.Tasks.Task () => throw null!); + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task () => throw null!); return application.OnShutdown(OnShutdown); @@ -54,7 +55,9 @@ async Task OnShutdown(ILambdaLifecycleContext context) await castHandler.Invoke(); } } - - private static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; } } \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NullableValueAndReferenceInputs#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NullableValueAndReferenceInputs#LambdaHandler.g.verified.cs index a73d512a..1568003d 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NullableValueAndReferenceInputs#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_NullableValueAndReferenceInputs#LambdaHandler.g.verified.cs @@ -34,6 +34,7 @@ namespace MinimalLambda.Generated using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] @@ -45,7 +46,7 @@ internal static ILambdaOnShutdownBuilder OnShutdownInterceptor0( Delegate handler ) { - var castHandler = Cast(handler, global::System.Threading.Tasks.Task (string? arg0, global::IService? arg1) => throw null!); + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task (string? arg0, global::IService? arg1) => throw null!); return application.OnShutdown(OnShutdown); @@ -59,7 +60,9 @@ Task OnShutdown(ILambdaLifecycleContext context) return response; } } - - private static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; } } \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_OneOfEachPossibleKindOfInput#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_OneOfEachPossibleKindOfInput#LambdaHandler.g.verified.cs index ad12af6c..9aabda42 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_OneOfEachPossibleKindOfInput#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_OneOfEachPossibleKindOfInput#LambdaHandler.g.verified.cs @@ -34,6 +34,7 @@ namespace MinimalLambda.Generated using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] @@ -45,7 +46,7 @@ internal static ILambdaOnShutdownBuilder OnShutdownInterceptor0( Delegate handler ) { - var castHandler = Cast(handler, global::System.Threading.Tasks.Task (global::System.Threading.CancellationToken arg0, global::IService arg1, global::IService? arg2, global::IService arg3, global::IService? arg4) => throw null!); + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task (global::System.Threading.CancellationToken arg0, global::IService arg1, global::IService? arg2, global::IService arg3, global::IService? arg4) => throw null!); return application.OnShutdown(OnShutdown); @@ -69,7 +70,9 @@ Task OnShutdown(ILambdaLifecycleContext context) return response; } } - - private static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; } } \ No newline at end of file diff --git a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_PrimitiveInput#LambdaHandler.g.verified.cs b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_PrimitiveInput#LambdaHandler.g.verified.cs index c50d3b1c..b5caa984 100644 --- a/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_PrimitiveInput#LambdaHandler.g.verified.cs +++ b/tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/OnShutdownVerifyTests.Test_OnShutdown_PrimitiveInput#LambdaHandler.g.verified.cs @@ -34,6 +34,7 @@ namespace MinimalLambda.Generated using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; + using MinimalLambda; using MinimalLambda.Builder; [GeneratedCode("MinimalLambda.SourceGenerators", "0.0.0")] @@ -45,7 +46,7 @@ internal static ILambdaOnShutdownBuilder OnShutdownInterceptor0( Delegate handler ) { - var castHandler = Cast(handler, global::System.Threading.Tasks.Task (string arg0, int arg1) => throw null!); + var castHandler = Utilities.Cast(handler, global::System.Threading.Tasks.Task (string arg0, int arg1) => throw null!); return application.OnShutdown(OnShutdown); @@ -59,7 +60,9 @@ Task OnShutdown(ILambdaLifecycleContext context) return response; } } - - private static T Cast(Delegate d, T _) where T : Delegate => (T)d; + } + file static class Utilities + { + internal static T Cast(Delegate d, T _) where T : Delegate => (T)d; } } \ No newline at end of file diff --git a/tests/MinimalLambda.UnitTests/Builder/LambdaOnInitBuilderTests.cs b/tests/MinimalLambda.UnitTests/Builder/LambdaOnInitBuilderTests.cs index e642fccb..7cbf71d8 100644 --- a/tests/MinimalLambda.UnitTests/Builder/LambdaOnInitBuilderTests.cs +++ b/tests/MinimalLambda.UnitTests/Builder/LambdaOnInitBuilderTests.cs @@ -287,7 +287,7 @@ public async Task Build_WithHandlerReturnsFalse_ReturnsFalse() // Act var buildFunc = builder.Build(); - var result = await buildFunc(CancellationToken.None); + var result = await buildFunc!(CancellationToken.None); // Assert result.Should().BeFalse(); @@ -337,7 +337,7 @@ public async Task Build_WithMultipleHandlers_AllExecuted() // Act var buildFunc = builder.Build(); - var result = await buildFunc(CancellationToken.None); + var result = await buildFunc!(CancellationToken.None); // Assert result.Should().BeTrue(); @@ -373,7 +373,7 @@ public async Task Build_WithAnyHandlerReturningFalse_ReturnsFalse() // Act var buildFunc = builder.Build(); - var result = await buildFunc(CancellationToken.None); + var result = await buildFunc!(CancellationToken.None); // Assert result.Should().BeFalse(); @@ -403,7 +403,7 @@ public async Task Build_WhenHandlerThrowsException_ThrowsAggregateException() // Act var buildFunc = builder.Build(); - Func act = () => buildFunc(CancellationToken.None); + Func act = () => buildFunc!(CancellationToken.None); // Assert await act.Should().ThrowAsync(); @@ -437,7 +437,7 @@ public async Task Build_WithMultipleFailures_AggregatesAllErrors() // Act var buildFunc = builder.Build(); - Func act = () => buildFunc(CancellationToken.None); + Func act = () => buildFunc!(CancellationToken.None); // Assert await act.Should().ThrowAsync(); @@ -472,7 +472,7 @@ ILambdaLifecycleContextFactory contextFactory // Act var buildFunc = builder.Build(); - var act = () => buildFunc(CancellationToken.None); + var act = () => buildFunc!(CancellationToken.None); // Assert await act.Should().ThrowAsync(); @@ -509,7 +509,7 @@ ILambdaLifecycleContextFactory contextFactory // Act var buildFunc = builder.Build(); - await buildFunc(CancellationToken.None); + await buildFunc!(CancellationToken.None); // Assert scopeUsed.Should().BeTrue(); diff --git a/tests/MinimalLambda.UnitTests/Builder/OnInit/OutputFormattingLambdaApplicationExtensionsTests.cs b/tests/MinimalLambda.UnitTests/Builder/OnInit/OutputFormattingLambdaApplicationExtensionsTests.cs index 23639c55..7c049064 100644 --- a/tests/MinimalLambda.UnitTests/Builder/OnInit/OutputFormattingLambdaApplicationExtensionsTests.cs +++ b/tests/MinimalLambda.UnitTests/Builder/OnInit/OutputFormattingLambdaApplicationExtensionsTests.cs @@ -75,7 +75,7 @@ public async Task OnInitClearLambdaOutputFormatting_InitHandlerSucceeds() // Act var builder = (ILambdaOnInitBuilder)app; var buildResult = builder.Build(); - var result = await buildResult(CancellationToken.None); + var result = await buildResult!(CancellationToken.None); // Assert result.Should().BeTrue();