Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .autover/changes/annotations-generated-code.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"Projects": [
{
"Name": "Amazon.Lambda.Annotations",
"Type": "Patch",
"ChangelogMessages": [
"Mark generated Lambda handler and executable bootstrap code for coverage and analysis tools."
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public partial class ExecutableAssembly : ExecutableAssemblyBase
/// </summary>
public virtual string TransformText()
{
this.Write("// <auto-generated/>\r\n\r\nusing System;\r\nusing System.Linq;\r\nusing System.Collectio" +
this.Write(GeneratedCodeMetadata.Header);
this.Write("using System;\r\nusing System.Linq;\r\nusing System.Collectio" +
"ns.Generic;\r\nusing System.Text;\r\nusing System.Threading.Tasks;\r\nusing System.IO;" +
"\r\nusing Amazon.Lambda.Core;\r\n\r\nnamespace ");

Expand All @@ -42,14 +43,17 @@ public virtual string TransformText()

#line default
#line hidden
this.Write(@";

public class GeneratedProgram
this.Write(";\r\n\r\n");
this.Write(GeneratedCodeMetadata.Attribute + "\r\n");
this.Write(GeneratedCodeMetadata.ExcludeFromCoverage + "\r\n");
this.Write(@"public class GeneratedProgram
{
/// <summary>
/// This is responsible for inspecting the 'ANNOTATIONS_HANDLER' environment variable and invoking the appropriate Lambda function handler.
/// </summary>
public static async Task Main(string[] args)
");
this.Write(" " + GeneratedCodeMetadata.Attribute + "\r\n");
this.Write(@" public static async Task Main(string[] args)
{

switch (Environment.GetEnvironmentVariable(""ANNOTATIONS_HANDLER""))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
<#@ import namespace="Amazon.Lambda.Annotations.SourceGenerator.Validation" #>
<#@ import namespace="Amazon.Lambda.Annotations.SourceGenerator.Models" #>
<#@ import namespace="Amazon.Lambda.Annotations.SourceGenerator.Models.Attributes" #>
// <auto-generated/>

<# this.Write(GeneratedCodeMetadata.Header); #>
using System;
using System.Linq;
using System.Collections.Generic;
Expand All @@ -20,11 +19,14 @@ using Amazon.Lambda.Core;

namespace <#= this._containingNamespace #>;

<#= GeneratedCodeMetadata.Attribute #>
<#= GeneratedCodeMetadata.ExcludeFromCoverage #>
public class GeneratedProgram
{
/// <summary>
/// This is responsible for inspecting the 'ANNOTATIONS_HANDLER' environment variable and invoking the appropriate Lambda function handler.
/// </summary>
<#= GeneratedCodeMetadata.Attribute #>
public static async Task Main(string[] args)
{

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

namespace Amazon.Lambda.Annotations.SourceGenerator.Templates
{
internal static class GeneratedCodeMetadata
{
private static readonly System.Reflection.AssemblyName GeneratorAssembly = typeof(Generator).Assembly.GetName();

internal const string ExcludeFromCoverage = "[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]";

internal static readonly string Attribute =
$"[global::System.CodeDom.Compiler.GeneratedCode(\"{GeneratorAssembly.Name}\", \"{GeneratorAssembly.Version}\")]";

internal static readonly string Header =
"// <auto-generated>\r\n" +
$"// This code was generated by {GeneratorAssembly.Name} {GeneratorAssembly.Version}.\r\n" +
"//\r\n" +
"// Changes to this file may cause incorrect behavior and will be lost if\r\n" +
"// the code is regenerated.\r\n" +
"// </auto-generated>\r\n\r\n";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public partial class LambdaFunctionTemplate : LambdaFunctionTemplateBase
/// </summary>
public virtual string TransformText()
{
this.Write("// <auto-generated/>\r\n\r\n");
this.Write(GeneratedCodeMetadata.Header);

#line 14 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\LambdaFunctionTemplate.tt"

Expand Down Expand Up @@ -94,6 +94,8 @@ public virtual string TransformText()

#line default
#line hidden
this.Write(" " + GeneratedCodeMetadata.Attribute + "\r\n");
this.Write(" " + GeneratedCodeMetadata.ExcludeFromCoverage + "\r\n");
this.Write(" public class ");

#line 33 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\LambdaFunctionTemplate.tt"
Expand Down Expand Up @@ -137,6 +139,7 @@ public virtual string TransformText()

#line default
#line hidden
this.Write(" " + GeneratedCodeMetadata.Attribute + "\r\n");
this.Write(" public ");

#line 41 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\LambdaFunctionTemplate.tt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
<#@ import namespace="Amazon.Lambda.Annotations.SourceGenerator.Models.Attributes" #>
<#@ import namespace="Microsoft.CodeAnalysis" #>
<#@ import namespace="Amazon.Lambda.Annotations.SourceGenerator.Validation" #>
// <auto-generated/>

<# this.Write(GeneratedCodeMetadata.Header); #>
<#
foreach (var ns in _model.GeneratedMethod.Usings)
{
Expand All @@ -31,6 +30,8 @@ namespace <#= _model.LambdaMethod.ContainingNamespace #>
<#
}
#>
<#= GeneratedCodeMetadata.Attribute #>
<#= GeneratedCodeMetadata.ExcludeFromCoverage #>
public class <#= _model.GeneratedMethod.ContainingType.Name #>
{
<#
Expand All @@ -47,6 +48,7 @@ this.Write(new FieldsAndConstructor(_model).TransformText());
<#
}
#>
<#= GeneratedCodeMetadata.Attribute #>
public <#= _model.LambdaMethod.ReturnsVoidOrGenericTask ? "async " : "" #><#= _model.GeneratedMethod.ReturnType.FullName #> <#= _model.LambdaMethod.Name #>(<#= _model.GeneratedMethod.Parameters.Any() ? string.Join(", ", _model.GeneratedMethod.Parameters.Select(p => $"{p.Type.FullName} {p.Name}")) : "Stream stream" #>)
{
<#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
// <auto-generated/>
// <auto-generated>
// This code was generated by Amazon.Lambda.Annotations.SourceGenerator {ANNOTATIONS_ASSEMBLY_VERSION}.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>

using System;
using System.Linq;
Expand All @@ -13,6 +18,8 @@ namespace TestServerlessApp.ALBEventExamples
/// <summary>
/// The generated Lambda function handler for <see cref="TestServerlessApp.ALBEventExamples.ValidALBEvents"/>.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCode("Amazon.Lambda.Annotations.SourceGenerator", "{ANNOTATIONS_ASSEMBLY_VERSION}")]
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public class ValidALBEvents_HandleRequest_Generated
{
private readonly ValidALBEvents validALBEvents;
Expand All @@ -36,6 +43,7 @@ public ValidALBEvents_HandleRequest_Generated()
/// <param name="__request__">The ALB request object that will be processed by the Lambda function handler.</param>
/// <param name="__context__">The ILambdaContext that provides methods for logging and describing the Lambda environment.</param>
/// <returns>Result of the Lambda function execution</returns>
[global::System.CodeDom.Compiler.GeneratedCode("Amazon.Lambda.Annotations.SourceGenerator", "{ANNOTATIONS_ASSEMBLY_VERSION}")]
public async System.Threading.Tasks.Task<Amazon.Lambda.ApplicationLoadBalancerEvents.ApplicationLoadBalancerResponse> HandleRequest(Amazon.Lambda.ApplicationLoadBalancerEvents.ApplicationLoadBalancerRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
{
var response = await validALBEvents.HandleRequest(__request__, __context__);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
// <auto-generated/>
// <auto-generated>
// This code was generated by Amazon.Lambda.Annotations.SourceGenerator {ANNOTATIONS_ASSEMBLY_VERSION}.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>

using System;
using System.Linq;
Expand All @@ -13,6 +18,8 @@ namespace TestServerlessApp.ALBEventExamples
/// <summary>
/// The generated Lambda function handler for <see cref="TestServerlessApp.ALBEventExamples.ValidALBEvents"/>.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCode("Amazon.Lambda.Annotations.SourceGenerator", "{ANNOTATIONS_ASSEMBLY_VERSION}")]
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public class ValidALBEvents_Hello_Generated
{
private readonly ValidALBEvents validALBEvents;
Expand All @@ -36,6 +43,7 @@ public ValidALBEvents_Hello_Generated()
/// <param name="__request__">The ALB request object that will be processed by the Lambda function handler.</param>
/// <param name="__context__">The ILambdaContext that provides methods for logging and describing the Lambda environment.</param>
/// <returns>Result of the Lambda function execution</returns>
[global::System.CodeDom.Compiler.GeneratedCode("Amazon.Lambda.Annotations.SourceGenerator", "{ANNOTATIONS_ASSEMBLY_VERSION}")]
public Amazon.Lambda.ApplicationLoadBalancerEvents.ApplicationLoadBalancerResponse Hello(Amazon.Lambda.ApplicationLoadBalancerEvents.ApplicationLoadBalancerRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
{
var response = validALBEvents.Hello(__request__, __context__);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
// <auto-generated/>
// <auto-generated>
// This code was generated by Amazon.Lambda.Annotations.SourceGenerator {ANNOTATIONS_ASSEMBLY_VERSION}.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>

using System;
using System.Linq;
Expand All @@ -13,6 +18,8 @@ namespace TestServerlessApp
/// <summary>
/// The generated Lambda function handler for <see cref="TestServerlessApp.AuthNameFallback"/>.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCode("Amazon.Lambda.Annotations.SourceGenerator", "{ANNOTATIONS_ASSEMBLY_VERSION}")]
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public class AuthNameFallback_GetUserId_Generated
{
private readonly AuthNameFallback authNameFallback;
Expand All @@ -36,6 +43,7 @@ public AuthNameFallback_GetUserId_Generated()
/// <param name="__request__">The API Gateway request object that will be processed by the Lambda function handler.</param>
/// <param name="__context__">The ILambdaContext that provides methods for logging and describing the Lambda environment.</param>
/// <returns>Result of the Lambda function execution</returns>
[global::System.CodeDom.Compiler.GeneratedCode("Amazon.Lambda.Annotations.SourceGenerator", "{ANNOTATIONS_ASSEMBLY_VERSION}")]
public async System.Threading.Tasks.Task<Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyResponse> GetUserId(Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
{
var validationErrors = new List<string>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
// <auto-generated/>
// <auto-generated>
// This code was generated by Amazon.Lambda.Annotations.SourceGenerator {ANNOTATIONS_ASSEMBLY_VERSION}.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>

using System;
using System.Linq;
Expand All @@ -13,6 +18,8 @@ namespace TestCustomAuthorizerApp
/// <summary>
/// The generated Lambda function handler for <see cref="TestCustomAuthorizerApp.AuthorizerFunction"/>.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCode("Amazon.Lambda.Annotations.SourceGenerator", "{ANNOTATIONS_ASSEMBLY_VERSION}")]
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public class AuthorizerFunction_HttpApiAuthorizeV1_Generated
{
private readonly AuthorizerFunction authorizerFunction;
Expand All @@ -36,6 +43,7 @@ public AuthorizerFunction_HttpApiAuthorizeV1_Generated()
/// <param name="__request__">The API Gateway authorizer request object that will be processed by the Lambda function handler.</param>
/// <param name="__context__">The ILambdaContext that provides methods for logging and describing the Lambda environment.</param>
/// <returns>Result of the Lambda function execution</returns>
[global::System.CodeDom.Compiler.GeneratedCode("Amazon.Lambda.Annotations.SourceGenerator", "{ANNOTATIONS_ASSEMBLY_VERSION}")]
public Amazon.Lambda.APIGatewayEvents.APIGatewayCustomAuthorizerResponse HttpApiAuthorizeV1(Amazon.Lambda.APIGatewayEvents.APIGatewayCustomAuthorizerRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
{
var response = authorizerFunction.HttpApiAuthorizeV1(__request__, __context__);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
// <auto-generated/>
// <auto-generated>
// This code was generated by Amazon.Lambda.Annotations.SourceGenerator {ANNOTATIONS_ASSEMBLY_VERSION}.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>

using System;
using System.Linq;
Expand All @@ -13,6 +18,8 @@ namespace TestCustomAuthorizerApp
/// <summary>
/// The generated Lambda function handler for <see cref="TestCustomAuthorizerApp.AuthorizerFunction"/>.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCode("Amazon.Lambda.Annotations.SourceGenerator", "{ANNOTATIONS_ASSEMBLY_VERSION}")]
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public class AuthorizerFunction_HttpApiAuthorize_Generated
{
private readonly AuthorizerFunction authorizerFunction;
Expand All @@ -36,6 +43,7 @@ public AuthorizerFunction_HttpApiAuthorize_Generated()
/// <param name="__request__">The API Gateway authorizer request object that will be processed by the Lambda function handler.</param>
/// <param name="__context__">The ILambdaContext that provides methods for logging and describing the Lambda environment.</param>
/// <returns>Result of the Lambda function execution</returns>
[global::System.CodeDom.Compiler.GeneratedCode("Amazon.Lambda.Annotations.SourceGenerator", "{ANNOTATIONS_ASSEMBLY_VERSION}")]
public Amazon.Lambda.APIGatewayEvents.APIGatewayCustomAuthorizerV2SimpleResponse HttpApiAuthorize(Amazon.Lambda.APIGatewayEvents.APIGatewayCustomAuthorizerV2Request __request__, Amazon.Lambda.Core.ILambdaContext __context__)
{
var response = authorizerFunction.HttpApiAuthorize(__request__, __context__);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
// <auto-generated/>
// <auto-generated>
// This code was generated by Amazon.Lambda.Annotations.SourceGenerator {ANNOTATIONS_ASSEMBLY_VERSION}.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>

using System;
using System.Linq;
Expand All @@ -13,6 +18,8 @@ namespace TestCustomAuthorizerApp
/// <summary>
/// The generated Lambda function handler for <see cref="TestCustomAuthorizerApp.AuthorizerFunction"/>.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCode("Amazon.Lambda.Annotations.SourceGenerator", "{ANNOTATIONS_ASSEMBLY_VERSION}")]
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public class AuthorizerFunction_RestApiAuthorize_Generated
{
private readonly AuthorizerFunction authorizerFunction;
Expand All @@ -36,6 +43,7 @@ public AuthorizerFunction_RestApiAuthorize_Generated()
/// <param name="__request__">The API Gateway authorizer request object that will be processed by the Lambda function handler.</param>
/// <param name="__context__">The ILambdaContext that provides methods for logging and describing the Lambda environment.</param>
/// <returns>Result of the Lambda function execution</returns>
[global::System.CodeDom.Compiler.GeneratedCode("Amazon.Lambda.Annotations.SourceGenerator", "{ANNOTATIONS_ASSEMBLY_VERSION}")]
public Amazon.Lambda.APIGatewayEvents.APIGatewayCustomAuthorizerResponse RestApiAuthorize(Amazon.Lambda.APIGatewayEvents.APIGatewayCustomAuthorizerRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
{
var response = authorizerFunction.RestApiAuthorize(__request__, __context__);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
// <auto-generated/>
// <auto-generated>
// This code was generated by Amazon.Lambda.Annotations.SourceGenerator {ANNOTATIONS_ASSEMBLY_VERSION}.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>

using System;
using System.Linq;
Expand All @@ -14,6 +19,8 @@ namespace TestCustomAuthorizerApp
/// <summary>
/// The generated Lambda function handler for <see cref="TestCustomAuthorizerApp.AuthorizerFunction"/>.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCode("Amazon.Lambda.Annotations.SourceGenerator", "{ANNOTATIONS_ASSEMBLY_VERSION}")]
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public class AuthorizerFunction_SimpleHttpApiAuthorize_Generated
{
private readonly AuthorizerFunction authorizerFunction;
Expand All @@ -37,6 +44,7 @@ public AuthorizerFunction_SimpleHttpApiAuthorize_Generated()
/// <param name="__request__">The API Gateway authorizer request object that will be processed by the Lambda function handler.</param>
/// <param name="__context__">The ILambdaContext that provides methods for logging and describing the Lambda environment.</param>
/// <returns>Result of the Lambda function execution</returns>
[global::System.CodeDom.Compiler.GeneratedCode("Amazon.Lambda.Annotations.SourceGenerator", "{ANNOTATIONS_ASSEMBLY_VERSION}")]
public System.IO.Stream SimpleHttpApiAuthorize(Amazon.Lambda.APIGatewayEvents.APIGatewayCustomAuthorizerV2Request __request__, Amazon.Lambda.Core.ILambdaContext __context__)
{
var __bindingFailed__ = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
// <auto-generated/>
// <auto-generated>
// This code was generated by Amazon.Lambda.Annotations.SourceGenerator {ANNOTATIONS_ASSEMBLY_VERSION}.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>

using System;
using System.Linq;
Expand All @@ -14,6 +19,8 @@ namespace TestCustomAuthorizerApp
/// <summary>
/// The generated Lambda function handler for <see cref="TestCustomAuthorizerApp.AuthorizerFunction"/>.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCode("Amazon.Lambda.Annotations.SourceGenerator", "{ANNOTATIONS_ASSEMBLY_VERSION}")]
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public class AuthorizerFunction_SimpleRestApiAuthorize_Generated
{
private readonly AuthorizerFunction authorizerFunction;
Expand All @@ -37,6 +44,7 @@ public AuthorizerFunction_SimpleRestApiAuthorize_Generated()
/// <param name="__request__">The API Gateway authorizer request object that will be processed by the Lambda function handler.</param>
/// <param name="__context__">The ILambdaContext that provides methods for logging and describing the Lambda environment.</param>
/// <returns>Result of the Lambda function execution</returns>
[global::System.CodeDom.Compiler.GeneratedCode("Amazon.Lambda.Annotations.SourceGenerator", "{ANNOTATIONS_ASSEMBLY_VERSION}")]
public System.IO.Stream SimpleRestApiAuthorize(Amazon.Lambda.APIGatewayEvents.APIGatewayCustomAuthorizerRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
{
var __bindingFailed__ = false;
Expand Down
Loading