Skip to content

Commit 64a47bb

Browse files
Merge branch 'dev'
2 parents cb78042 + 49d8839 commit 64a47bb

40 files changed

Lines changed: 1211 additions & 42 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"Projects": [
3+
{
4+
"Name": "Amazon.Lambda.TestTool.BlazorTester",
5+
"Type": "Patch",
6+
"ChangelogMessages": [
7+
"Minor fixes to improve the testability of the package"
8+
]
9+
}
10+
]
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"Projects": [
3+
{
4+
"Name": "Amazon.Lambda.RuntimeSupport",
5+
"Type": "Patch",
6+
"ChangelogMessages": [
7+
"Minor fixes to improve the testability of the package"
8+
]
9+
}
10+
]
11+
}

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Release 2026-04-13 #2
2+
3+
### Amazon.Lambda.Annotations (1.12.0)
4+
* treat warnings as errors and fix unshipped.md
5+
* Added [S3Event] annotation attribute for declaratively configuring S3 event-triggered Lambda functions with support for bucket reference, event types, key prefix/suffix filters, and enabled state.
6+
17
## Release 2026-04-08
28

39
### Amazon.Lambda.Annotations (1.11.0)

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

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

23-
<Version>1.11.0</Version>
23+
<Version>1.12.0</Version>
24+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
2425
</PropertyGroup>
2526

2627
<!-- Delay setting the package id till after resolving dependencies to avoid ambigious errors. -->

Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Diagnostics/AnalyzerReleases.Unshipped.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ AWSLambda0132 | AWSLambdaCSharpGenerator | Error | Invalid ALBApiAttribute
2020
AWSLambda0133 | AWSLambdaCSharpGenerator | Error | ALB Listener Reference Not Found
2121
AWSLambda0134 | AWSLambdaCSharpGenerator | Error | FromRoute not supported on ALB functions
2222
AWSLambda0135 | AWSLambdaCSharpGenerator | Error | Unmapped parameter on ALB function
23+
AWSLambda0136 | AWSLambdaCSharpGenerator | Error | Invalid S3EventAttribute

Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Diagnostics/DiagnosticDescriptors.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,5 +274,12 @@ public static class DiagnosticDescriptors
274274
category: "AWSLambdaCSharpGenerator",
275275
DiagnosticSeverity.Error,
276276
isEnabledByDefault: true);
277+
278+
public static readonly DiagnosticDescriptor InvalidS3EventAttribute = new DiagnosticDescriptor(id: "AWSLambda0136",
279+
title: "Invalid S3EventAttribute",
280+
messageFormat: "Invalid S3EventAttribute encountered: {0}",
281+
category: "AWSLambdaCSharpGenerator",
282+
DiagnosticSeverity.Error,
283+
isEnabledByDefault: true);
277284
}
278285
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using Amazon.Lambda.Annotations.ALB;
33
using Amazon.Lambda.Annotations.APIGateway;
4+
using Amazon.Lambda.Annotations.S3;
45
using Amazon.Lambda.Annotations.SQS;
56
using Microsoft.CodeAnalysis;
67

@@ -91,6 +92,15 @@ public static AttributeModel Build(AttributeData att, GeneratorExecutionContext
9192
Type = TypeModelBuilder.Build(att.AttributeClass, context)
9293
};
9394
}
95+
else if (att.AttributeClass.Equals(context.Compilation.GetTypeByMetadataName(TypeFullNames.S3EventAttribute), SymbolEqualityComparer.Default))
96+
{
97+
var data = S3EventAttributeBuilder.Build(att);
98+
model = new AttributeModel<S3EventAttribute>
99+
{
100+
Data = data,
101+
Type = TypeModelBuilder.Build(att.AttributeClass, context)
102+
};
103+
}
94104
else if (att.AttributeClass.Equals(context.Compilation.GetTypeByMetadataName(TypeFullNames.HttpApiAuthorizerAttribute), SymbolEqualityComparer.Default))
95105
{
96106
var data = HttpApiAuthorizerAttributeBuilder.Build(att);
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
using Amazon.Lambda.Annotations.S3;
5+
using Microsoft.CodeAnalysis;
6+
using System;
7+
8+
namespace Amazon.Lambda.Annotations.SourceGenerator.Models.Attributes
9+
{
10+
public class S3EventAttributeBuilder
11+
{
12+
public static S3EventAttribute Build(AttributeData att)
13+
{
14+
if (att.ConstructorArguments.Length != 1)
15+
throw new NotSupportedException($"{TypeFullNames.S3EventAttribute} must have constructor with 1 argument.");
16+
17+
var bucket = att.ConstructorArguments[0].Value as string;
18+
var data = new S3EventAttribute(bucket);
19+
20+
foreach (var pair in att.NamedArguments)
21+
{
22+
if (pair.Key == nameof(data.ResourceName) && pair.Value.Value is string resourceName)
23+
data.ResourceName = resourceName;
24+
else if (pair.Key == nameof(data.Events) && pair.Value.Value is string events)
25+
data.Events = events;
26+
else if (pair.Key == nameof(data.FilterPrefix) && pair.Value.Value is string filterPrefix)
27+
data.FilterPrefix = filterPrefix;
28+
else if (pair.Key == nameof(data.FilterSuffix) && pair.Value.Value is string filterSuffix)
29+
data.FilterSuffix = filterSuffix;
30+
else if (pair.Key == nameof(data.Enabled) && pair.Value.Value is bool enabled)
31+
data.Enabled = enabled;
32+
}
33+
34+
return data;
35+
}
36+
}
37+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ public static HashSet<EventType> Build(IMethodSymbol lambdaMethodSymbol,
2626
{
2727
events.Add(EventType.SQS);
2828
}
29+
else if (attribute.AttributeClass.ToDisplayString() == TypeFullNames.S3EventAttribute)
30+
{
31+
events.Add(EventType.S3);
32+
}
2933
else if (attribute.AttributeClass.ToDisplayString() == TypeFullNames.HttpApiAuthorizerAttribute
3034
|| attribute.AttributeClass.ToDisplayString() == TypeFullNames.RestApiAuthorizerAttribute)
3135
{

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ internal class SyntaxReceiver : ISyntaxContextReceiver
2222
{ "HttpApiAttribute", "HttpApi" },
2323
{ "RestApiAttribute", "RestApi" },
2424
{ "SQSEventAttribute", "SQSEvent" },
25-
{ "ALBApiAttribute", "ALBApi" }
25+
{ "ALBApiAttribute", "ALBApi" },
26+
{ "S3EventAttribute", "S3Event" }
2627
};
2728

2829
public List<MethodDeclarationSyntax> LambdaMethods { get; } = new List<MethodDeclarationSyntax>();

0 commit comments

Comments
 (0)