Skip to content

Commit edaec83

Browse files
committed
test(source-generators): add multi-targeting support and conditional durable execution references
- Updated tests to support multi-targeting for .NET 8.0, 9.0, 10.0, and 11.0 frameworks. - Added conditional compilation for `DurableExecution` references targeting .NET 10.0 and newer. - Adjusted project file to define `TargetFrameworks` and conditionally include durable references. - Expanded GitHub Actions workflow to test against all targeted frameworks.
1 parent 7134d2f commit edaec83

7 files changed

Lines changed: 18 additions & 2 deletions

File tree

.github/workflows/pr-quality.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ jobs:
5353
dotnet test tests/MinimalLambda.UnitTests/MinimalLambda.UnitTests.csproj --framework net8.0 --configuration Release --no-build --results-directory ./coverage --coverage --coverage-output-format cobertura --no-progress --no-ansi
5454
dotnet test tests/MinimalLambda.Envelopes.UnitTests/MinimalLambda.Envelopes.UnitTests.csproj --framework net8.0 --configuration Release --no-build --results-directory ./coverage --coverage --coverage-output-format cobertura --no-progress --no-ansi
5555
dotnet test tests/MinimalLambda.SourceGenerators.UnitTests/MinimalLambda.SourceGenerators.UnitTests.csproj --framework net8.0 --configuration Release --no-build --results-directory ./coverage --coverage --coverage-output-format cobertura --no-progress --no-ansi
56+
dotnet test tests/MinimalLambda.SourceGenerators.UnitTests/MinimalLambda.SourceGenerators.UnitTests.csproj --framework net9.0 --configuration Release --no-build --results-directory ./coverage --coverage --coverage-output-format cobertura --no-progress --no-ansi
57+
dotnet test tests/MinimalLambda.SourceGenerators.UnitTests/MinimalLambda.SourceGenerators.UnitTests.csproj --framework net10.0 --configuration Release --no-build --results-directory ./coverage --coverage --coverage-output-format cobertura --no-progress --no-ansi
58+
dotnet test tests/MinimalLambda.SourceGenerators.UnitTests/MinimalLambda.SourceGenerators.UnitTests.csproj --framework net11.0 --configuration Release --no-build --results-directory ./coverage --coverage --coverage-output-format cobertura --no-progress --no-ansi
5659
dotnet test tests/MinimalLambda.OpenTelemetry.UnitTests/MinimalLambda.OpenTelemetry.UnitTests.csproj --framework net9.0 --configuration Release --no-build --results-directory ./coverage --coverage --coverage-output-format cobertura --no-progress --no-ansi
5760
5861
- name: Upload coverage reports to Codecov

tests/MinimalLambda.SourceGenerators.UnitTests/DurableHandlerDiagnosticTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if NET10_0_OR_GREATER
12
using AwesomeAssertions;
23
using Microsoft.CodeAnalysis;
34
using MinimalLambda.SourceGenerators.Models;
@@ -604,3 +605,4 @@ private static Diagnostic[] Generate(string source)
604605
return driver.GetRunResult().Diagnostics.ToArray();
605606
}
606607
}
608+
#endif

tests/MinimalLambda.SourceGenerators.UnitTests/DurableHandlerDiscoveryTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if NET10_0_OR_GREATER
12
using AwesomeAssertions;
23
using Microsoft.CodeAnalysis;
34
using Microsoft.CodeAnalysis.CSharp.Syntax;
@@ -184,3 +185,4 @@ private static InvocationExpressionSyntax FindInvocation(
184185
.Single(invocation =>
185186
invocation.Expression.ToString().EndsWith(methodName, StringComparison.Ordinal));
186187
}
188+
#endif

tests/MinimalLambda.SourceGenerators.UnitTests/DurableHandlerEmitterTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if NET10_0_OR_GREATER
12
using AwesomeAssertions;
23
using Microsoft.CodeAnalysis;
34

@@ -363,3 +364,4 @@ private static string GetDurableSource(GeneratorDriverRunResult result) =>
363364
.SourceText
364365
.ToString();
365366
}
367+
#endif

tests/MinimalLambda.SourceGenerators.UnitTests/DurableSerializerDiagnosticTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if NET10_0_OR_GREATER
12
using AwesomeAssertions;
23

34
namespace MinimalLambda.SourceGenerators.UnitTests;
@@ -467,3 +468,4 @@ private static Microsoft.CodeAnalysis.Diagnostic[] Generate(string source)
467468
return driver.GetRunResult().Diagnostics.ToArray();
468469
}
469470
}
471+
#endif

tests/MinimalLambda.SourceGenerators.UnitTests/GeneratorTestHelpers.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using System.Diagnostics.CodeAnalysis;
22
using System.Text.RegularExpressions;
33
using Amazon.Lambda.Core;
4+
#if NET10_0_OR_GREATER
45
using Amazon.Lambda.DurableExecution;
6+
#endif
57
using Amazon.Lambda.RuntimeSupport;
68
using Amazon.Lambda.Serialization.SystemTextJson;
79
using AwesomeAssertions;
@@ -160,6 +162,7 @@ .. Net80.References.All.ToList(),
160162
MetadataReference.CreateFromFile(typeof(ILambdaInvocationContext).Assembly.Location),
161163
];
162164

165+
#if NET10_0_OR_GREATER
163166
if (includeDurableReferences)
164167
{
165168
references.Add(
@@ -169,6 +172,7 @@ .. Net80.References.All.ToList(),
169172
references.Add(
170173
MetadataReference.CreateFromFile(typeof(IDurableContext).Assembly.Location));
171174
}
175+
#endif
172176

173177
var compilationOptions = new CSharpCompilationOptions(
174178
OutputKind.ConsoleApplication,

tests/MinimalLambda.SourceGenerators.UnitTests/MinimalLambda.SourceGenerators.UnitTests.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net10.0</TargetFramework>
3+
<TargetFrameworks>net8.0;net9.0;net10.0;net11.0</TargetFrameworks>
44
<LangVersion>latest</LangVersion>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
@@ -38,7 +38,8 @@
3838
<ItemGroup>
3939
<ProjectReference Include="..\..\src\MinimalLambda\MinimalLambda.csproj" />
4040
<ProjectReference
41-
Include="..\..\src\MinimalLambda.DurableExecution\MinimalLambda.DurableExecution.csproj" />
41+
Include="..\..\src\MinimalLambda.DurableExecution\MinimalLambda.DurableExecution.csproj"
42+
Condition="'$(TargetFramework)' == 'net10.0' Or '$(TargetFramework)' == 'net11.0'" />
4243
<ProjectReference
4344
Include="..\..\src\MinimalLambda.SourceGenerators\MinimalLambda.SourceGenerators.csproj" />
4445
</ItemGroup>

0 commit comments

Comments
 (0)