From f42260ec36466a15e643c6ffb70edeff5e3a1a2e Mon Sep 17 00:00:00 2001 From: reisenberger Date: Fri, 27 May 2016 19:27:17 +0100 Subject: [PATCH] Bring in initial Net40 Async work (#5) * Add Polly.Net40Async project for async support - Polly.NET40Async references Nuget package Microsoft.Bcl.Async - Add conditional compiler constant SUPPORTS_ASYNC_40 --- src/Polly.Net40Async/Polly.Net40Async.csproj | 83 +++++++++++++++++++ .../Properties/AssemblyInfo.cs | 36 ++++++++ src/Polly.Net40Async/packages.config | 6 ++ src/Polly.Shared/Utilities/SystemClock.cs | 8 ++ src/Polly.sln | 9 +- 5 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 src/Polly.Net40Async/Polly.Net40Async.csproj create mode 100644 src/Polly.Net40Async/Properties/AssemblyInfo.cs create mode 100644 src/Polly.Net40Async/packages.config diff --git a/src/Polly.Net40Async/Polly.Net40Async.csproj b/src/Polly.Net40Async/Polly.Net40Async.csproj new file mode 100644 index 0000000000..d6a20ed967 --- /dev/null +++ b/src/Polly.Net40Async/Polly.Net40Async.csproj @@ -0,0 +1,83 @@ + + + + + Debug + AnyCPU + {D6A676C2-982D-42D1-AD21-FA53582A1C31} + Library + Properties + Polly.Net40Async + Polly.Net40Async + v4.0 + 512 + + + true + full + false + bin\Debug\ + TRACE;DEBUG;SUPPORTS_ASYNC;SUPPORTS_ASYNC_40 + prompt + 4 + bin\Debug\Polly.XML + true + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll + True + + + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll + True + + + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll + True + + + + + ..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.IO.dll + True + + + + ..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.Runtime.dll + True + + + ..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.Threading.Tasks.dll + True + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Polly.Net40Async/Properties/AssemblyInfo.cs b/src/Polly.Net40Async/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..10f4c4f527 --- /dev/null +++ b/src/Polly.Net40Async/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Polly.Net40Async")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Polly.Net40Async")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("d6a676c2-982d-42d1-ad21-fa53582a1c31")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Polly.Net40Async/packages.config b/src/Polly.Net40Async/packages.config new file mode 100644 index 0000000000..fd0874c230 --- /dev/null +++ b/src/Polly.Net40Async/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/Polly.Shared/Utilities/SystemClock.cs b/src/Polly.Shared/Utilities/SystemClock.cs index 2fe0c828bd..5d1894c740 100644 --- a/src/Polly.Shared/Utilities/SystemClock.cs +++ b/src/Polly.Shared/Utilities/SystemClock.cs @@ -30,7 +30,11 @@ public static class SystemClock /// Allows the setting of a custom async Sleep implementation for testing. /// By default this will be a call to /// +#if SUPPORTS_ASYNC_40 + public static Func SleepAsync = TaskEx.Delay; +#else public static Func SleepAsync = Task.Delay; +#endif #endif /// /// Allows the setting of a custom DateTime.UtcNow implementation for testing. @@ -50,7 +54,11 @@ public static void Reset() Sleep = timeSpan => new ManualResetEvent(false).WaitOne(timeSpan); #endif #if SUPPORTS_ASYNC +#if SUPPORTS_ASYNC_40 + SleepAsync = TaskEx.Delay; +#else SleepAsync = Task.Delay; +#endif #endif UtcNow = () => DateTime.UtcNow; } diff --git a/src/Polly.sln b/src/Polly.sln index cfabd9b47a..ecc522ab15 100644 --- a/src/Polly.sln +++ b/src/Polly.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.23107.0 +VisualStudioVersion = 14.0.25123.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{79FE9DBE-1155-4F78-A41F-FE95DEFA19DD}" ProjectSection(SolutionItems) = preProject @@ -25,10 +25,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Polly.Net45.Specs", "Polly. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Polly.Pcl.Specs", "Polly.Pcl.Specs\Polly.Pcl.Specs.csproj", "{4AB46D16-0806-4F51-8677-D849BA87CB05}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Polly.Net40Async", "Polly.Net40Async\Polly.Net40Async.csproj", "{D6A676C2-982D-42D1-AD21-FA53582A1C31}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution Polly.Shared\Polly.Shared.projitems*{ddf727ec-6496-44f9-abd3-2ee4562ae685}*SharedItemsImports = 4 Polly.SharedSpecs\Polly.SharedSpecs.projitems*{4ab46d16-0806-4f51-8677-d849ba87cb05}*SharedItemsImports = 4 + Polly.Shared\Polly.Shared.projitems*{d6a676c2-982d-42d1-ad21-fa53582a1c31}*SharedItemsImports = 4 Polly.Shared\Polly.Shared.projitems*{29265540-f724-4324-9321-643a0fcb133f}*SharedItemsImports = 4 Polly.Shared\Polly.Shared.projitems*{23fa87f9-c77d-4c67-a0b0-2901de51b3ff}*SharedItemsImports = 13 Polly.Shared\Polly.Shared.projitems*{905cf38a-be90-4234-bf15-2fcfd1973a9c}*SharedItemsImports = 4 @@ -65,6 +68,10 @@ Global {4AB46D16-0806-4F51-8677-D849BA87CB05}.Debug|Any CPU.Build.0 = Debug|Any CPU {4AB46D16-0806-4F51-8677-D849BA87CB05}.Release|Any CPU.ActiveCfg = Release|Any CPU {4AB46D16-0806-4F51-8677-D849BA87CB05}.Release|Any CPU.Build.0 = Release|Any CPU + {D6A676C2-982D-42D1-AD21-FA53582A1C31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D6A676C2-982D-42D1-AD21-FA53582A1C31}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D6A676C2-982D-42D1-AD21-FA53582A1C31}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D6A676C2-982D-42D1-AD21-FA53582A1C31}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE