diff --git a/Polly.sln b/Polly.sln index bf30ece2e28..7bb28d106d3 100644 --- a/Polly.sln +++ b/Polly.sln @@ -58,6 +58,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Polly.Testing.Tests", "test EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Snippets", "src\Snippets\Snippets.csproj", "{D812B941-79B0-4E1E-BB70-4FAE345B5234}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Polly.AotTest", "test\Polly.AotTest\Polly.AotTest.csproj", "{84091007-CFA5-4852-AC41-0171DF039C4E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -120,6 +122,10 @@ Global {D812B941-79B0-4E1E-BB70-4FAE345B5234}.Debug|Any CPU.Build.0 = Debug|Any CPU {D812B941-79B0-4E1E-BB70-4FAE345B5234}.Release|Any CPU.ActiveCfg = Release|Any CPU {D812B941-79B0-4E1E-BB70-4FAE345B5234}.Release|Any CPU.Build.0 = Release|Any CPU + {84091007-CFA5-4852-AC41-0171DF039C4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {84091007-CFA5-4852-AC41-0171DF039C4E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {84091007-CFA5-4852-AC41-0171DF039C4E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {84091007-CFA5-4852-AC41-0171DF039C4E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -140,6 +146,7 @@ Global {9AD2D6AD-56E4-49D6-B6F1-EE975D5760B9} = {B7BF406B-B06F-4025-83E6-7219C53196A6} {D333B5CE-982D-4C11-BDAF-4217AA02306E} = {A6CC41B9-E0B9-44F8-916B-3E4A78DA3BFB} {D812B941-79B0-4E1E-BB70-4FAE345B5234} = {B7BF406B-B06F-4025-83E6-7219C53196A6} + {84091007-CFA5-4852-AC41-0171DF039C4E} = {A6CC41B9-E0B9-44F8-916B-3E4A78DA3BFB} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {2E5D54CD-770A-4345-B585-1848FC2EA6F4} diff --git a/build.cake b/build.cake index d69a2a96628..013c4260812 100644 --- a/build.cake +++ b/build.cake @@ -75,9 +75,9 @@ Task("__Clean") CleanDirectories(cleanDirectories); - foreach(var path in cleanDirectories) { EnsureDirectoryExists(path); } + foreach (var path in cleanDirectories) { EnsureDirectoryExists(path); } - foreach(var path in solutionPaths) + foreach (var path in solutionPaths) { Information("Cleaning {0}", path); @@ -93,7 +93,7 @@ Task("__Clean") Task("__RestoreNuGetPackages") .Does(() => { - foreach(var solution in solutions) + foreach (var solution in solutions) { Information("Restoring NuGet Packages for {0}", solution); DotNetRestore(solution.ToString()); @@ -103,7 +103,7 @@ Task("__RestoreNuGetPackages") Task("__BuildSolutions") .Does(() => { - foreach(var solution in solutions) + foreach (var solution in solutions) { Information("Building {0}", solution); @@ -125,6 +125,23 @@ Task("__BuildSolutions") } }); +Task("__ValidateAot") + .Does(() => +{ + var aotProject = MakeAbsolute(File("./test/Polly.AotTest/Polly.AotTest.csproj")); + var settings = new DotNetPublishSettings + { + Configuration = configuration, + Verbosity = DotNetVerbosity.Minimal, + MSBuildSettings = new DotNetMSBuildSettings + { + TreatAllWarningsAs = MSBuildTreatAllWarningsAs.Error, + }, + }; + + DotNetPublish(aotProject.ToString(), settings); +}); + Task("__RunTests") .Does(() => { @@ -137,7 +154,7 @@ Task("__RunTests") var projects = GetFiles("./test/**/*.csproj"); - foreach(var proj in projects) + foreach (var proj in projects) { DotNetTest(proj.FullPath, new DotNetTestSettings { @@ -252,6 +269,7 @@ Task("Build") .IsDependentOn("__RestoreNuGetPackages") .IsDependentOn("__ValidateDocs") .IsDependentOn("__BuildSolutions") + .IsDependentOn("__ValidateAot") .IsDependentOn("__RunTests") .IsDependentOn("__RunMutationTests") .IsDependentOn("__CreateNuGetPackages"); diff --git a/src/Polly.Core/Polly.Core.csproj b/src/Polly.Core/Polly.Core.csproj index c2d35333fa3..44afc806652 100644 --- a/src/Polly.Core/Polly.Core.csproj +++ b/src/Polly.Core/Polly.Core.csproj @@ -20,6 +20,7 @@ + diff --git a/test/Polly.AotTest/Polly.AotTest.csproj b/test/Polly.AotTest/Polly.AotTest.csproj new file mode 100644 index 00000000000..0f8b6725774 --- /dev/null +++ b/test/Polly.AotTest/Polly.AotTest.csproj @@ -0,0 +1,19 @@ + + + enable + Exe + true + true + net7.0 + + + + + + + + + + + + diff --git a/test/Polly.AotTest/Program.cs b/test/Polly.AotTest/Program.cs new file mode 100644 index 00000000000..b5a43fd1ef8 --- /dev/null +++ b/test/Polly.AotTest/Program.cs @@ -0,0 +1,8 @@ +using Polly.Utils.Pipeline; + +// See https://github.com/App-vNext/Polly/issues/1732#issuecomment-1782466692. +// This code is needed as a workaround until https://github.com/dotnet/runtime/issues/94131 is resolved. +var pipeline = CompositeComponent.Create(new[] { PipelineComponent.Empty, PipelineComponent.Empty }, null!, null!); +await pipeline.ExecuteCore((state, context) => default, default!, default); + +Console.WriteLine("Hello Polly!");