Skip to content
Merged
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
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ trim_trailing_whitespace = true

[*.xml]
indent_size = 4
max_line_length = 120

[*HostFactoryResolver.cs]
ij_formatter_enabled = false
Expand Down
15 changes: 12 additions & 3 deletions .github/workflows/main-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
mkdir -p ~/.sonar/scanner
dotnet tool update dotnet-sonarscanner --tool-path ~/.sonar/scanner

- name: Build and analyze with SonarQube
- name: Start SonarQube
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
Expand All @@ -78,12 +78,21 @@ jobs:
/d:sonar.exclusions="**/bin/**,**/obj/**,tests/MinimalLambda.SourceGenerators.UnitTests/Snapshots/**,**/coverage/**,**/.nuget/**,**/packages/**,src/MinimalLambda.Testing/HostFactoryResolver.cs" \
/d:sonar.coverage.exclusions="**/*" \
/d:sonar.token="$SONAR_TOKEN"
dotnet build --no-restore --configuration Release /p:TreatWarningsAsErrors=true
~/.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="$SONAR_TOKEN"

- name: Build
run: dotnet build --no-restore --configuration Release /p:TreatWarningsAsErrors=true

- name: Run tests
run: dotnet test --no-build --configuration Release --verbosity normal --collect:"XPlat Code Coverage" --results-directory ./coverage

- name: Stop SonarQube
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ~/.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="$SONAR_TOKEN"

- name: Validate AOT Compatability
run: task build:aot-check

- name: Upload coverage reports
uses: codecov/codecov-action@v5
with:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/pr-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ jobs:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ~/.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="$SONAR_TOKEN"

- name: Validate AOT Compatability
run: task build:aot-check

- name: Upload coverage reports
uses: codecov/codecov-action@v5
with:
Expand Down
9 changes: 9 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,13 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
<IsAotCompatible>true</IsAotCompatible>
<EnableAotAnalyzer>true</EnableAotAnalyzer>
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
</PropertyGroup>

<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
</Project>
15 changes: 15 additions & 0 deletions MinimalLambda.sln
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MinimalLambda.Envelopes", "
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MinimalLambda.Example.ClassMiddleware", "examples\MinimalLambda.Example.ClassMiddleware\MinimalLambda.Example.ClassMiddleware.csproj", "{69785FC6-B746-4104-8157-1618B80B0A4C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AotCompatibility.TestApp", "src\AotCompatibility.TestApp\AotCompatibility.TestApp.csproj", "{A8B77486-5A06-4A02-B1F0-EB8E2669394F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -463,6 +465,18 @@ Global
{69785FC6-B746-4104-8157-1618B80B0A4C}.Release|x64.Build.0 = Release|Any CPU
{69785FC6-B746-4104-8157-1618B80B0A4C}.Release|x86.ActiveCfg = Release|Any CPU
{69785FC6-B746-4104-8157-1618B80B0A4C}.Release|x86.Build.0 = Release|Any CPU
{A8B77486-5A06-4A02-B1F0-EB8E2669394F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A8B77486-5A06-4A02-B1F0-EB8E2669394F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A8B77486-5A06-4A02-B1F0-EB8E2669394F}.Debug|x64.ActiveCfg = Debug|Any CPU
{A8B77486-5A06-4A02-B1F0-EB8E2669394F}.Debug|x64.Build.0 = Debug|Any CPU
{A8B77486-5A06-4A02-B1F0-EB8E2669394F}.Debug|x86.ActiveCfg = Debug|Any CPU
{A8B77486-5A06-4A02-B1F0-EB8E2669394F}.Debug|x86.Build.0 = Debug|Any CPU
{A8B77486-5A06-4A02-B1F0-EB8E2669394F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A8B77486-5A06-4A02-B1F0-EB8E2669394F}.Release|Any CPU.Build.0 = Release|Any CPU
{A8B77486-5A06-4A02-B1F0-EB8E2669394F}.Release|x64.ActiveCfg = Release|Any CPU
{A8B77486-5A06-4A02-B1F0-EB8E2669394F}.Release|x64.Build.0 = Release|Any CPU
{A8B77486-5A06-4A02-B1F0-EB8E2669394F}.Release|x86.ActiveCfg = Release|Any CPU
{A8B77486-5A06-4A02-B1F0-EB8E2669394F}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -501,5 +515,6 @@ Global
{7E7B3004-C6C4-4A8C-8610-2A1CB61F834A} = {D9109C8A-AFA8-49C8-A19C-381500902B4D}
{190CC9C7-007F-48C5-867D-03B911D53397} = {1C3C52D9-2936-4A0C-A9C8-F330F22B8359}
{69785FC6-B746-4104-8157-1618B80B0A4C} = {B36A84DF-456D-A817-6EDD-3EC3E7F6E11F}
{A8B77486-5A06-4A02-B1F0-EB8E2669394F} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
EndGlobalSection
EndGlobal
40 changes: 40 additions & 0 deletions src/AotCompatibility.TestApp/AotCompatibility.TestApp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
ο»Ώ<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<LangVersion>preview</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishAot>true</PublishAot>
<TrimmerSingleWarn>false</TrimmerSingleWarn>
<SelfContained>true</SelfContained>
<WarningsAsErrors>IL2026;IL2087;IL2091;IL3050;IL3051</WarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<EnvelopeRootAssembly Include="MinimalLambda.Envelopes.Alb" />
<EnvelopeRootAssembly Include="MinimalLambda.Envelopes.ApiGateway" />
<EnvelopeRootAssembly Include="MinimalLambda.Envelopes.CloudWatchLogs" />
<EnvelopeRootAssembly Include="MinimalLambda.Envelopes.Kafka" />
<EnvelopeRootAssembly Include="MinimalLambda.Envelopes.KinesisFirehose" />
<EnvelopeRootAssembly Include="MinimalLambda.Envelopes.Kinesis" />
<EnvelopeRootAssembly Include="MinimalLambda.Envelopes.Sns" />
<EnvelopeRootAssembly Include="MinimalLambda.Envelopes.Sqs" />
<EnvelopeRootAssembly Include="MinimalLambda.Envelopes" />
<CoreRootAssembly Include="MinimalLambda.Abstractions" />
<CoreRootAssembly Include="MinimalLambda.OpenTelemetry" />
<CoreRootAssembly Include="MinimalLambda" />
</ItemGroup>
<ItemGroup>
<TrimmerRootAssembly Include="@(EnvelopeRootAssembly)" />
<TrimmerRootAssembly Include="@(CoreRootAssembly)" />
<TrimmerRootAssembly
Update="@(EnvelopeRootAssembly)"
Path="$(MSBuildThisFileDirectory)..\..\src\Envelopes\%(Identity)\%(Identity).csproj"
/>
<TrimmerRootAssembly
Update="@(CoreRootAssembly)"
Path="$(MSBuildThisFileDirectory)..\..\src\%(Identity)\%(Identity).csproj"
/>
<ProjectReference Include="@(TrimmerRootAssembly->'%(Path)')" />
</ItemGroup>
</Project>
3 changes: 3 additions & 0 deletions src/AotCompatibility.TestApp/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ο»Ώ// See https://aka.ms/new-console-template for more information

Console.WriteLine("Hello, World!");
11 changes: 11 additions & 0 deletions src/Envelopes/MinimalLambda.Envelopes.Alb/AlbRequestEnvelope.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
using MinimalLambda.Options;

Expand All @@ -13,6 +14,16 @@ public sealed class AlbRequestEnvelope<T> : AlbRequestEnvelopeBase<T>
{
/// <inheritdoc cref="IRequestEnvelope" />
/// <remarks>This implementation deserializes the request body from JSON.</remarks>
[UnconditionalSuppressMessage(
"Aot",
"IL3050:RequiresDynamicCode",
Justification = "Safe when EnvelopeOptions.JsonOptions includes source-generated context for T"
)]
[UnconditionalSuppressMessage(
"Aot",
"IL2026:RequiresUnreferencedCode",
Justification = "Safe when EnvelopeOptions.JsonOptions includes source-generated context for T"
)]
public override void ExtractPayload(EnvelopeOptions options) =>
BodyContent = JsonSerializer.Deserialize<T>(Body, options.JsonOptions);
}
11 changes: 11 additions & 0 deletions src/Envelopes/MinimalLambda.Envelopes.Alb/AlbResponseEnvelope.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
using MinimalLambda.Options;

Expand All @@ -13,6 +14,16 @@ public sealed class AlbResponseEnvelope<T> : AlbResponseEnvelopeBase<T>
{
/// <inheritdoc cref="IResponseEnvelope" />
/// <remarks>This implementation serializes the response body to JSON.</remarks>
[UnconditionalSuppressMessage(
"Aot",
"IL3050:RequiresDynamicCode",
Justification = "Safe when EnvelopeOptions.JsonOptions includes source-generated context for T"
)]
[UnconditionalSuppressMessage(
"Aot",
"IL2026:RequiresUnreferencedCode",
Justification = "Safe when EnvelopeOptions.JsonOptions includes source-generated context for T"
)]
public override void PackPayload(EnvelopeOptions options) =>
Body = JsonSerializer.Serialize(BodyContent, options.JsonOptions);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ο»Ώusing System.Text.Json;
ο»Ώusing System.Diagnostics.CodeAnalysis;
using System.Text.Json;
using MinimalLambda.Options;

namespace MinimalLambda.Envelopes.ApiGateway;
Expand All @@ -13,6 +14,16 @@ public sealed class ApiGatewayRequestEnvelope<T> : ApiGatewayRequestEnvelopeBase
{
/// <inheritdoc cref="IRequestEnvelope" />
/// <remarks>This implementation deserializes the request body from JSON.</remarks>
[UnconditionalSuppressMessage(
"Aot",
"IL3050:RequiresDynamicCode",
Justification = "Safe when EnvelopeOptions.JsonOptions includes source-generated context for T"
)]
[UnconditionalSuppressMessage(
"Aot",
"IL2026:RequiresUnreferencedCode",
Justification = "Safe when EnvelopeOptions.JsonOptions includes source-generated context for T"
)]
public override void ExtractPayload(EnvelopeOptions options) =>
BodyContent = JsonSerializer.Deserialize<T>(Body, options.JsonOptions);
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
using MinimalLambda.Options;

Expand All @@ -13,6 +14,16 @@ public sealed class ApiGatewayResponseEnvelope<T> : ApiGatewayResponseEnvelopeBa
{
/// <inheritdoc cref="IResponseEnvelope" />
/// <remarks>This implementation serializes the response body to JSON.</remarks>
[UnconditionalSuppressMessage(
"Aot",
"IL3050:RequiresDynamicCode",
Justification = "Safe when EnvelopeOptions.JsonOptions includes source-generated context for T"
)]
[UnconditionalSuppressMessage(
"Aot",
"IL2026:RequiresUnreferencedCode",
Justification = "Safe when EnvelopeOptions.JsonOptions includes source-generated context for T"
)]
public override void PackPayload(EnvelopeOptions options) =>
Body = JsonSerializer.Serialize(BodyContent, options.JsonOptions);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ο»Ώusing System.Text.Json;
ο»Ώusing System.Diagnostics.CodeAnalysis;
using System.Text.Json;
using MinimalLambda.Options;

namespace MinimalLambda.Envelopes.ApiGateway;
Expand All @@ -13,6 +14,16 @@ public sealed class ApiGatewayV2RequestEnvelope<T> : ApiGatewayV2RequestEnvelope
{
/// <inheritdoc cref="IRequestEnvelope" />
/// <remarks>This implementation deserializes the request body from JSON.</remarks>
[UnconditionalSuppressMessage(
"Aot",
"IL3050:RequiresDynamicCode",
Justification = "Safe when EnvelopeOptions.JsonOptions includes source-generated context for T"
)]
[UnconditionalSuppressMessage(
"Aot",
"IL2026:RequiresUnreferencedCode",
Justification = "Safe when EnvelopeOptions.JsonOptions includes source-generated context for T"
)]
public override void ExtractPayload(EnvelopeOptions options) =>
BodyContent = JsonSerializer.Deserialize<T>(Body, options.JsonOptions);
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
using MinimalLambda.Options;

Expand All @@ -13,6 +14,16 @@ public sealed class ApiGatewayV2ResponseEnvelope<T> : ApiGatewayV2ResponseEnvelo
{
/// <inheritdoc cref="IResponseEnvelope" />
/// <remarks>This implementation serializes the response body to JSON.</remarks>
[UnconditionalSuppressMessage(
"Aot",
"IL3050:RequiresDynamicCode",
Justification = "Safe when EnvelopeOptions.JsonOptions includes source-generated context for T"
)]
[UnconditionalSuppressMessage(
"Aot",
"IL2026:RequiresUnreferencedCode",
Justification = "Safe when EnvelopeOptions.JsonOptions includes source-generated context for T"
)]
public override void PackPayload(EnvelopeOptions options) =>
Body = JsonSerializer.Serialize(BodyContent, options.JsonOptions);
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
using System.Text.Json.Serialization;
using Amazon.Lambda.CloudWatchLogsEvents;
Expand All @@ -19,6 +20,16 @@ public abstract class CloudWatchLogsEnvelopeBase<T> : CloudWatchLogsEvent, IRequ
public AwsLogsEnvelope? AwslogsContent { get; set; }

/// <inheritdoc />
[UnconditionalSuppressMessage(
"Aot",
"IL3050:RequiresDynamicCode",
Justification = "Safe when EnvelopeOptions.JsonOptions includes source-generated context for T"
)]
[UnconditionalSuppressMessage(
"Aot",
"IL2026:RequiresUnreferencedCode",
Justification = "Safe when EnvelopeOptions.JsonOptions includes source-generated context for T"
)]
public virtual void ExtractPayload(EnvelopeOptions options)
{
var decodedData = Awslogs.DecodeData();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
using MinimalLambda.Options;

Expand Down Expand Up @@ -26,6 +27,16 @@ public sealed class CloudWatchLogsEnvelope<T> : CloudWatchLogsEnvelopeBase<T>
/// This implementation deserializes the base64-decoded and decompressed CloudWatch Logs data
/// from JSON.
/// </remarks>
[UnconditionalSuppressMessage(
"Aot",
"IL3050:RequiresDynamicCode",
Justification = "Safe when EnvelopeOptions.JsonOptions includes source-generated context for T"
)]
[UnconditionalSuppressMessage(
"Aot",
"IL2026:RequiresUnreferencedCode",
Justification = "Safe when EnvelopeOptions.JsonOptions includes source-generated context for T"
)]
public override void ExtractPayload(EnvelopeOptions options)
{
base.ExtractPayload(options);
Expand Down
11 changes: 11 additions & 0 deletions src/Envelopes/MinimalLambda.Envelopes.Kafka/KafkaEnvelope.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Text;
using System.Text.Json;
using MinimalLambda.Options;
Expand All @@ -14,6 +15,16 @@ public sealed class KafkaEnvelope<T> : KafkaEnvelopeBase<T>
{
/// <inheritdoc cref="IRequestEnvelope" />
/// <remarks>This implementation deserializes each base64-encoded value stream from JSON.</remarks>
[UnconditionalSuppressMessage(
"Aot",
"IL3050:RequiresDynamicCode",
Justification = "Safe when EnvelopeOptions.JsonOptions includes source-generated context for T"
)]
[UnconditionalSuppressMessage(
"Aot",
"IL2026:RequiresUnreferencedCode",
Justification = "Safe when EnvelopeOptions.JsonOptions includes source-generated context for T"
)]
public override void ExtractPayload(EnvelopeOptions options)
{
foreach (var topic in Records)
Expand Down
11 changes: 11 additions & 0 deletions src/Envelopes/MinimalLambda.Envelopes.Kinesis/KinesisEnvelope.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Text;
using System.Text.Json;
using MinimalLambda.Options;
Expand All @@ -14,6 +15,16 @@ public sealed class KinesisEnvelope<T> : KinesisEnvelopeBase<T>
{
/// <inheritdoc cref="IRequestEnvelope" />
/// <remarks>This implementation deserializes each base64-encoded data stream from JSON.</remarks>
[UnconditionalSuppressMessage(
"Aot",
"IL3050:RequiresDynamicCode",
Justification = "Safe when EnvelopeOptions.JsonOptions includes source-generated context for T"
)]
[UnconditionalSuppressMessage(
"Aot",
"IL2026:RequiresUnreferencedCode",
Justification = "Safe when EnvelopeOptions.JsonOptions includes source-generated context for T"
)]
public override void ExtractPayload(EnvelopeOptions options)
{
foreach (var record in Records)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
using MinimalLambda.Options;

Expand All @@ -13,6 +14,16 @@ public sealed class KinesisFirehoseEventEnvelope<T> : KinesisFirehoseEventEnvelo
{
/// <inheritdoc cref="IRequestEnvelope" />
/// <remarks>This implementation deserializes each base64-encoded Firehose data record from JSON.</remarks>
[UnconditionalSuppressMessage(
"Aot",
"IL3050:RequiresDynamicCode",
Justification = "Safe when EnvelopeOptions.JsonOptions includes source-generated context for T"
)]
[UnconditionalSuppressMessage(
"Aot",
"IL2026:RequiresUnreferencedCode",
Justification = "Safe when EnvelopeOptions.JsonOptions includes source-generated context for T"
)]
public override void ExtractPayload(EnvelopeOptions options)
{
foreach (var record in Records)
Expand Down
Loading
Loading