Skip to content

Commit e9d0d74

Browse files
Merge branch 'dev'
2 parents 64a47bb + ee1a65e commit e9d0d74

35 files changed

Lines changed: 1186 additions & 107 deletions

File tree

.autover/changes/9cf844c3-1a90-46ec-9430-93724dcb4512.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

.autover/changes/a119819e-ba57-424d-a0be-d941eea599f9.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## Release 2026-04-14
2+
3+
### Amazon.Lambda.TestTool.BlazorTester (0.17.1)
4+
* Minor fixes to improve the testability of the package
5+
### Amazon.Lambda.RuntimeSupport (1.14.3)
6+
* Minor fixes to improve the testability of the package
7+
### Amazon.Lambda.Annotations (1.13.0)
8+
* Added [FunctionUrl] attribute for configuring Lambda functions with Function URL endpoints, including optional CORS support
9+
110
## Release 2026-04-13 #2
211

312
### Amazon.Lambda.Annotations (1.12.0)

Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Amazon.Lambda.Annotations.SourceGenerator.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
2121
<IncludeBuildOutput>false</IncludeBuildOutput>
2222

23-
<Version>1.12.0</Version>
23+
<Version>1.13.0</Version>
2424
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
2525
</PropertyGroup>
2626

Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Models/Attributes/AttributeModelBuilder.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
14
using System;
25
using Amazon.Lambda.Annotations.ALB;
36
using Amazon.Lambda.Annotations.APIGateway;
@@ -101,6 +104,15 @@ public static AttributeModel Build(AttributeData att, GeneratorExecutionContext
101104
Type = TypeModelBuilder.Build(att.AttributeClass, context)
102105
};
103106
}
107+
else if (att.AttributeClass.Equals(context.Compilation.GetTypeByMetadataName(TypeFullNames.FunctionUrlAttribute), SymbolEqualityComparer.Default))
108+
{
109+
var data = FunctionUrlAttributeBuilder.Build(att);
110+
model = new AttributeModel<FunctionUrlAttribute>
111+
{
112+
Data = data,
113+
Type = TypeModelBuilder.Build(att.AttributeClass, context)
114+
};
115+
}
104116
else if (att.AttributeClass.Equals(context.Compilation.GetTypeByMetadataName(TypeFullNames.HttpApiAuthorizerAttribute), SymbolEqualityComparer.Default))
105117
{
106118
var data = HttpApiAuthorizerAttributeBuilder.Build(att);
@@ -166,4 +178,4 @@ public static AttributeModel Build(AttributeData att, GeneratorExecutionContext
166178
return model;
167179
}
168180
}
169-
}
181+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
using System.Linq;
5+
using Amazon.Lambda.Annotations.APIGateway;
6+
using Microsoft.CodeAnalysis;
7+
8+
namespace Amazon.Lambda.Annotations.SourceGenerator.Models.Attributes
9+
{
10+
public static class FunctionUrlAttributeBuilder
11+
{
12+
public static FunctionUrlAttribute Build(AttributeData att)
13+
{
14+
var authType = att.NamedArguments.FirstOrDefault(arg => arg.Key == "AuthType").Value.Value;
15+
16+
var data = new FunctionUrlAttribute
17+
{
18+
AuthType = authType == null ? FunctionUrlAuthType.NONE : (FunctionUrlAuthType)authType
19+
};
20+
21+
var allowOrigins = att.NamedArguments.FirstOrDefault(arg => arg.Key == "AllowOrigins").Value;
22+
if (!allowOrigins.IsNull)
23+
data.AllowOrigins = allowOrigins.Values.Select(v => v.Value as string).ToArray();
24+
25+
var allowMethods = att.NamedArguments.FirstOrDefault(arg => arg.Key == "AllowMethods").Value;
26+
if (!allowMethods.IsNull)
27+
data.AllowMethods = allowMethods.Values.Select(v => (LambdaHttpMethod)(int)v.Value).ToArray();
28+
29+
var allowHeaders = att.NamedArguments.FirstOrDefault(arg => arg.Key == "AllowHeaders").Value;
30+
if (!allowHeaders.IsNull)
31+
data.AllowHeaders = allowHeaders.Values.Select(v => v.Value as string).ToArray();
32+
33+
var exposeHeaders = att.NamedArguments.FirstOrDefault(arg => arg.Key == "ExposeHeaders").Value;
34+
if (!exposeHeaders.IsNull)
35+
data.ExposeHeaders = exposeHeaders.Values.Select(v => v.Value as string).ToArray();
36+
37+
var allowCredentials = att.NamedArguments.FirstOrDefault(arg => arg.Key == "AllowCredentials").Value.Value;
38+
if (allowCredentials != null)
39+
data.AllowCredentials = (bool)allowCredentials;
40+
41+
var maxAge = att.NamedArguments.FirstOrDefault(arg => arg.Key == "MaxAge").Value.Value;
42+
if (maxAge != null)
43+
data.MaxAge = (int)maxAge;
44+
45+
return data;
46+
}
47+
}
48+
}

Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Models/EventTypeBuilder.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
14
using System;
25
using System.Collections.Generic;
36
using System.Linq;
@@ -18,7 +21,8 @@ public static HashSet<EventType> Build(IMethodSymbol lambdaMethodSymbol,
1821
foreach (var attribute in lambdaMethodSymbol.GetAttributes())
1922
{
2023
if (attribute.AttributeClass.ToDisplayString() == TypeFullNames.RestApiAttribute
21-
|| attribute.AttributeClass.ToDisplayString() == TypeFullNames.HttpApiAttribute)
24+
|| attribute.AttributeClass.ToDisplayString() == TypeFullNames.HttpApiAttribute
25+
|| attribute.AttributeClass.ToDisplayString() == TypeFullNames.FunctionUrlAttribute)
2226
{
2327
events.Add(EventType.API);
2428
}

Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Models/GeneratedMethodModelBuilder.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
14
using System;
25
using System.Collections.Generic;
36
using System.Linq;
@@ -144,6 +147,14 @@ private static TypeModel BuildResponseType(IMethodSymbol lambdaMethodSymbol,
144147
context.Compilation.GetTypeByMetadataName(TypeFullNames.ApplicationLoadBalancerResponse);
145148
return TypeModelBuilder.Build(symbol, context);
146149
}
150+
else if (lambdaMethodSymbol.HasAttribute(context, TypeFullNames.FunctionUrlAttribute))
151+
{
152+
// Function URLs use the same payload format as HTTP API v2
153+
var symbol = lambdaMethodModel.ReturnsVoidOrGenericTask ?
154+
task.Construct(context.Compilation.GetTypeByMetadataName(TypeFullNames.APIGatewayHttpApiV2ProxyResponse)):
155+
context.Compilation.GetTypeByMetadataName(TypeFullNames.APIGatewayHttpApiV2ProxyResponse);
156+
return TypeModelBuilder.Build(symbol, context);
157+
}
147158
else
148159
{
149160
return lambdaMethodModel.ReturnType;
@@ -304,6 +315,20 @@ private static IList<ParameterModel> BuildParameters(IMethodSymbol lambdaMethodS
304315
parameters.Add(requestParameter);
305316
parameters.Add(contextParameter);
306317
}
318+
else if (lambdaMethodSymbol.HasAttribute(context, TypeFullNames.FunctionUrlAttribute))
319+
{
320+
// Function URLs use the same payload format as HTTP API v2
321+
var symbol = context.Compilation.GetTypeByMetadataName(TypeFullNames.APIGatewayHttpApiV2ProxyRequest);
322+
var type = TypeModelBuilder.Build(symbol, context);
323+
var requestParameter = new ParameterModel
324+
{
325+
Name = "__request__",
326+
Type = type,
327+
Documentation = "The Function URL request object that will be processed by the Lambda function handler."
328+
};
329+
parameters.Add(requestParameter);
330+
parameters.Add(contextParameter);
331+
}
307332
else
308333
{
309334
// Lambda method with no event attribute are plain lambda functions, therefore, generated method will have

Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/SyntaxReceiver.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
using System;
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
using System;
25
using System.Collections.Generic;
36
using System.Linq;
47
using Amazon.Lambda.Annotations.SourceGenerator.FileIO;
@@ -21,6 +24,7 @@ internal class SyntaxReceiver : ISyntaxContextReceiver
2124
{ "RestApiAuthorizerAttribute", "RestApiAuthorizer" },
2225
{ "HttpApiAttribute", "HttpApi" },
2326
{ "RestApiAttribute", "RestApi" },
27+
{ "FunctionUrlAttribute", "FunctionUrl" },
2428
{ "SQSEventAttribute", "SQSEvent" },
2529
{ "ALBApiAttribute", "ALBApi" },
2630
{ "S3EventAttribute", "S3Event" }
@@ -122,4 +126,4 @@ public void OnVisitSyntaxNode(GeneratorSyntaxContext context)
122126
}
123127
}
124128
}
125-
}
129+
}

Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/TypeFullNames.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
14
using System.Collections.Generic;
25

36
namespace Amazon.Lambda.Annotations.SourceGenerator
@@ -34,6 +37,9 @@ public static class TypeFullNames
3437
public const string FromRouteAttribute = "Amazon.Lambda.Annotations.APIGateway.FromRouteAttribute";
3538
public const string FromCustomAuthorizerAttribute = "Amazon.Lambda.Annotations.APIGateway.FromCustomAuthorizerAttribute";
3639

40+
public const string FunctionUrlAttribute = "Amazon.Lambda.Annotations.APIGateway.FunctionUrlAttribute";
41+
public const string FunctionUrlAuthType = "Amazon.Lambda.Annotations.APIGateway.FunctionUrlAuthType";
42+
3743
public const string HttpApiAuthorizerAttribute = "Amazon.Lambda.Annotations.APIGateway.HttpApiAuthorizerAttribute";
3844
public const string RestApiAuthorizerAttribute = "Amazon.Lambda.Annotations.APIGateway.RestApiAuthorizerAttribute";
3945

@@ -82,9 +88,10 @@ public static class TypeFullNames
8288
{
8389
RestApiAttribute,
8490
HttpApiAttribute,
91+
FunctionUrlAttribute,
8592
SQSEventAttribute,
8693
ALBApiAttribute,
8794
S3EventAttribute
8895
};
8996
}
90-
}
97+
}

0 commit comments

Comments
 (0)