From 9349e6bc15c643dc27e38623f96755667f817f59 Mon Sep 17 00:00:00 2001 From: Philip Pittle Date: Tue, 12 Nov 2024 13:50:12 -0800 Subject: [PATCH] Update lambda annotations to eagerly build Function Handler type --- .../c4272e98-0b59-409c-a060-d5c061495801.json | 11 ++++ .../Templates/FieldsAndConstructor.cs | 52 ++++++++++++------- .../Templates/FieldsAndConstructor.tt | 4 ++ ...nctions_AsyncStartupToLower_Generated.g.cs | 4 ++ ...nctions_AsyncStartupToUpper_Generated.g.cs | 4 ++ ...terExecutable_SayHelloAsync_Generated.g.cs | 4 ++ .../GreeterExecutable_SayHello_Generated.g.cs | 4 ++ .../SimpleCalculator_Add_Generated.g.cs | 4 ++ ...impleCalculator_DivideAsync_Generated.g.cs | 4 ++ .../SimpleCalculator_Multiply_Generated.g.cs | 4 ++ .../SimpleCalculator_Pi_Generated.g.cs | 4 ++ .../SimpleCalculator_Random_Generated.g.cs | 4 ++ .../SimpleCalculator_Randoms_Generated.g.cs | 4 ++ .../SimpleCalculator_Subtract_Generated.g.cs | 4 ++ 14 files changed, 93 insertions(+), 18 deletions(-) create mode 100644 .autover/changes/c4272e98-0b59-409c-a060-d5c061495801.json diff --git a/.autover/changes/c4272e98-0b59-409c-a060-d5c061495801.json b/.autover/changes/c4272e98-0b59-409c-a060-d5c061495801.json new file mode 100644 index 000000000..3f130ec5e --- /dev/null +++ b/.autover/changes/c4272e98-0b59-409c-a060-d5c061495801.json @@ -0,0 +1,11 @@ +{ + "Projects": [ + { + "Name": "Amazon.Lambda.Annotations", + "Type": "Minor", + "ChangelogMessages": [ + "Eagerly build Function Handler inside the Generated class\u0027s constructor" + ] + } + ] +} \ No newline at end of file diff --git a/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/FieldsAndConstructor.cs b/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/FieldsAndConstructor.cs index aa63be57b..7354994e9 100644 --- a/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/FieldsAndConstructor.cs +++ b/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/FieldsAndConstructor.cs @@ -19,7 +19,7 @@ namespace Amazon.Lambda.Annotations.SourceGenerator.Templates /// Class to produce the template output /// - #line 1 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" + #line 1 "C:\projects\aws\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")] public partial class FieldsAndConstructor : FieldsAndConstructorBase { @@ -30,7 +30,7 @@ public partial class FieldsAndConstructor : FieldsAndConstructorBase public virtual string TransformText() { - #line 7 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" + #line 7 "C:\projects\aws\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" if (_model.LambdaMethod.UsingDependencyInjection) { @@ -40,7 +40,7 @@ public virtual string TransformText() #line hidden this.Write(" private readonly ServiceProvider serviceProvider;\r\n"); - #line 12 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" + #line 12 "C:\projects\aws\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" } else @@ -51,28 +51,28 @@ public virtual string TransformText() #line hidden this.Write(" private readonly "); - #line 17 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" + #line 17 "C:\projects\aws\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" this.Write(this.ToStringHelper.ToStringWithCulture(_model.LambdaMethod.ContainingType.Name)); #line default #line hidden this.Write(" "); - #line 17 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" + #line 17 "C:\projects\aws\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" this.Write(this.ToStringHelper.ToStringWithCulture(_model.LambdaMethod.ContainingType.Name.ToCamelCase())); #line default #line hidden this.Write(";\r\n private readonly "); - #line 18 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" + #line 18 "C:\projects\aws\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" this.Write(this.ToStringHelper.ToStringWithCulture(_model.SerializerInfo.SerializerName)); #line default #line hidden this.Write(" serializer;\r\n"); - #line 19 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" + #line 19 "C:\projects\aws\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" } @@ -87,14 +87,14 @@ public virtual string TransformText() /// public "); - #line 28 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" + #line 28 "C:\projects\aws\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" this.Write(this.ToStringHelper.ToStringWithCulture(_model.GeneratedMethod.ContainingType.Name)); #line default #line hidden this.Write("()\r\n {\r\n SetExecutionEnvironment();\r\n"); - #line 31 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" + #line 31 "C:\projects\aws\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" if (_model.LambdaMethod.UsingDependencyInjection) { @@ -108,29 +108,45 @@ public virtual string TransformText() // To use a different lifetime, specify the lifetime in Startup.ConfigureServices(IServiceCollection) method. services.AddSingleton<"); - #line 39 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" + #line 39 "C:\projects\aws\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" this.Write(this.ToStringHelper.ToStringWithCulture(_model.LambdaMethod.ContainingType.Name)); #line default #line hidden this.Write(">();\r\n services.AddSingleton<"); - #line 40 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" + #line 40 "C:\projects\aws\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" this.Write(this.ToStringHelper.ToStringWithCulture(_model.SerializerInfo.SerializerName)); #line default #line hidden this.Write(">();\r\n\r\n var startup = new "); - #line 42 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" + #line 42 "C:\projects\aws\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" this.Write(this.ToStringHelper.ToStringWithCulture(_model.StartupType.FullName)); #line default #line hidden this.Write("();\r\n startup.ConfigureServices(services);\r\n serviceProvide" + - "r = services.BuildServiceProvider();\r\n"); + "r = services.BuildServiceProvider();\r\n\r\n // Intentionally eagerly bui" + + "ld "); - #line 45 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" + #line 46 "C:\projects\aws\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(_model.LambdaMethod.ContainingType.Name)); + + #line default + #line hidden + this.Write(" and its dependencies.\r\n // This causes time spent in the Constructor " + + "to appear on INIT_REPORTs\r\n _ = serviceProvider.GetRequiredService<"); + + #line 48 "C:\projects\aws\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(_model.LambdaMethod.ContainingType.Name)); + + #line default + #line hidden + this.Write(">();\r\n"); + + #line 49 "C:\projects\aws\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" } else @@ -141,28 +157,28 @@ public virtual string TransformText() #line hidden this.Write(" "); - #line 50 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" + #line 54 "C:\projects\aws\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" this.Write(this.ToStringHelper.ToStringWithCulture(_model.LambdaMethod.ContainingType.Name.ToCamelCase())); #line default #line hidden this.Write(" = new "); - #line 50 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" + #line 54 "C:\projects\aws\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" this.Write(this.ToStringHelper.ToStringWithCulture(_model.LambdaMethod.ContainingType.Name)); #line default #line hidden this.Write("();\r\n serializer = new "); - #line 51 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" + #line 55 "C:\projects\aws\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" this.Write(this.ToStringHelper.ToStringWithCulture(_model.SerializerInfo.SerializerName)); #line default #line hidden this.Write("();\r\n"); - #line 52 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" + #line 56 "C:\projects\aws\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\FieldsAndConstructor.tt" } diff --git a/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/FieldsAndConstructor.tt b/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/FieldsAndConstructor.tt index 6c4fd3d43..5260488cd 100644 --- a/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/FieldsAndConstructor.tt +++ b/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/FieldsAndConstructor.tt @@ -42,6 +42,10 @@ var startup = new <#= _model.StartupType.FullName #>(); startup.ConfigureServices(services); serviceProvider = services.BuildServiceProvider(); + + // Intentionally eagerly build <#= _model.LambdaMethod.ContainingType.Name #> and its dependencies. + // This causes time spent in the Constructor to appear on INIT_REPORTs + _ = serviceProvider.GetRequiredService<<#= _model.LambdaMethod.ContainingType.Name #>>(); <# } else diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/Functions_AsyncStartupToLower_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/Functions_AsyncStartupToLower_Generated.g.cs index 607b48f34..aea875bce 100644 --- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/Functions_AsyncStartupToLower_Generated.g.cs +++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/Functions_AsyncStartupToLower_Generated.g.cs @@ -33,6 +33,10 @@ public FunctionsZipOutput_ToLower_Generated() var startup = new TestServerlessApp.Startup(); startup.ConfigureServices(services); serviceProvider = services.BuildServiceProvider(); + + // Intentionally eagerly build FunctionsZipOutput and its dependencies. + // This causes time spent in the Constructor to appear on INIT_REPORTs + _ = serviceProvider.GetRequiredService(); } /// diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/Functions_AsyncStartupToUpper_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/Functions_AsyncStartupToUpper_Generated.g.cs index 57558f8cd..262e73c20 100644 --- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/Functions_AsyncStartupToUpper_Generated.g.cs +++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/Functions_AsyncStartupToUpper_Generated.g.cs @@ -33,6 +33,10 @@ public Functions_ToUpper_Generated() var startup = new TestServerlessApp.Startup(); startup.ConfigureServices(services); serviceProvider = services.BuildServiceProvider(); + + // Intentionally eagerly build Functions and its dependencies. + // This causes time spent in the Constructor to appear on INIT_REPORTs + _ = serviceProvider.GetRequiredService(); } /// diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/GreeterExecutable_SayHelloAsync_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/GreeterExecutable_SayHelloAsync_Generated.g.cs index eb0d018b1..86b3fb361 100644 --- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/GreeterExecutable_SayHelloAsync_Generated.g.cs +++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/GreeterExecutable_SayHelloAsync_Generated.g.cs @@ -33,6 +33,10 @@ public Greeter_SayHelloAsync_Generated() var startup = new TestServerlessApp.Startup(); startup.ConfigureServices(services); serviceProvider = services.BuildServiceProvider(); + + // Intentionally eagerly build Greeter and its dependencies. + // This causes time spent in the Constructor to appear on INIT_REPORTs + _ = serviceProvider.GetRequiredService(); } /// diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/GreeterExecutable_SayHello_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/GreeterExecutable_SayHello_Generated.g.cs index fb6c65fe9..8fff6bab0 100644 --- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/GreeterExecutable_SayHello_Generated.g.cs +++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/GreeterExecutable_SayHello_Generated.g.cs @@ -33,6 +33,10 @@ public Greeter_SayHello_Generated() var startup = new TestServerlessApp.Startup(); startup.ConfigureServices(services); serviceProvider = services.BuildServiceProvider(); + + // Intentionally eagerly build Greeter and its dependencies. + // This causes time spent in the Constructor to appear on INIT_REPORTs + _ = serviceProvider.GetRequiredService(); } /// diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Add_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Add_Generated.g.cs index 317fe5235..f6ee0f02e 100644 --- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Add_Generated.g.cs +++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Add_Generated.g.cs @@ -33,6 +33,10 @@ public SimpleCalculator_Add_Generated() var startup = new TestServerlessApp.Startup(); startup.ConfigureServices(services); serviceProvider = services.BuildServiceProvider(); + + // Intentionally eagerly build SimpleCalculator and its dependencies. + // This causes time spent in the Constructor to appear on INIT_REPORTs + _ = serviceProvider.GetRequiredService(); } /// diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_DivideAsync_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_DivideAsync_Generated.g.cs index 87cc91533..fb79b1c8f 100644 --- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_DivideAsync_Generated.g.cs +++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_DivideAsync_Generated.g.cs @@ -33,6 +33,10 @@ public SimpleCalculator_DivideAsync_Generated() var startup = new TestServerlessApp.Startup(); startup.ConfigureServices(services); serviceProvider = services.BuildServiceProvider(); + + // Intentionally eagerly build SimpleCalculator and its dependencies. + // This causes time spent in the Constructor to appear on INIT_REPORTs + _ = serviceProvider.GetRequiredService(); } /// diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Multiply_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Multiply_Generated.g.cs index 7f6faadba..2d7a8ae2f 100644 --- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Multiply_Generated.g.cs +++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Multiply_Generated.g.cs @@ -33,6 +33,10 @@ public SimpleCalculator_Multiply_Generated() var startup = new TestServerlessApp.Startup(); startup.ConfigureServices(services); serviceProvider = services.BuildServiceProvider(); + + // Intentionally eagerly build SimpleCalculator and its dependencies. + // This causes time spent in the Constructor to appear on INIT_REPORTs + _ = serviceProvider.GetRequiredService(); } /// diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Pi_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Pi_Generated.g.cs index 65bafd80f..1b4f12e48 100644 --- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Pi_Generated.g.cs +++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Pi_Generated.g.cs @@ -33,6 +33,10 @@ public SimpleCalculator_Pi_Generated() var startup = new TestServerlessApp.Startup(); startup.ConfigureServices(services); serviceProvider = services.BuildServiceProvider(); + + // Intentionally eagerly build SimpleCalculator and its dependencies. + // This causes time spent in the Constructor to appear on INIT_REPORTs + _ = serviceProvider.GetRequiredService(); } /// diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Random_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Random_Generated.g.cs index 2d424ad5d..c30d90954 100644 --- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Random_Generated.g.cs +++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Random_Generated.g.cs @@ -33,6 +33,10 @@ public SimpleCalculator_Random_Generated() var startup = new TestServerlessApp.Startup(); startup.ConfigureServices(services); serviceProvider = services.BuildServiceProvider(); + + // Intentionally eagerly build SimpleCalculator and its dependencies. + // This causes time spent in the Constructor to appear on INIT_REPORTs + _ = serviceProvider.GetRequiredService(); } /// diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Randoms_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Randoms_Generated.g.cs index f3309e7d9..c1d34b07a 100644 --- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Randoms_Generated.g.cs +++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Randoms_Generated.g.cs @@ -33,6 +33,10 @@ public SimpleCalculator_Randoms_Generated() var startup = new TestServerlessApp.Startup(); startup.ConfigureServices(services); serviceProvider = services.BuildServiceProvider(); + + // Intentionally eagerly build SimpleCalculator and its dependencies. + // This causes time spent in the Constructor to appear on INIT_REPORTs + _ = serviceProvider.GetRequiredService(); } /// diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Subtract_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Subtract_Generated.g.cs index eb4cc8737..0d863ea58 100644 --- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Subtract_Generated.g.cs +++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Subtract_Generated.g.cs @@ -33,6 +33,10 @@ public SimpleCalculator_Subtract_Generated() var startup = new TestServerlessApp.Startup(); startup.ConfigureServices(services); serviceProvider = services.BuildServiceProvider(); + + // Intentionally eagerly build SimpleCalculator and its dependencies. + // This causes time spent in the Constructor to appear on INIT_REPORTs + _ = serviceProvider.GetRequiredService(); } ///