From 1a77291dbc86c98ad64baa58c5720abd87003367 Mon Sep 17 00:00:00 2001 From: Ankit Sinha Date: Wed, 28 Jun 2017 02:03:44 +0530 Subject: [PATCH 1/6] Added PolicyRegistry Feature (#231) * Added IPolicyRegistry interface * Implemented IPolicyRegistry interface as DefaultPolicyRegistry using Dictionary as backend store * Changed the implementation to use ConcurrentDictionary * Polly now targets .NETStandard 1.1 * Pcl.Specs now targets PCL Profile 111. * Renamed folder and csproj from Polly.NetStandard10 to Polly.NetStandard11 * Updated Cake script to reflect folder and csproj renaming to NetStandard11 * Added unit test cases for DefaultPolicyRegistry * Added a test to check adding policy with duplicate key through indexer should overwrite. * Add and Retrieve through indexer are now separate tests * Added tests to check - Exception thrown when retrieving when key does not exist - Exception thrown when key is null while adding, removing and retriving policy. * Added test to check if exception is thrown when key is null which using ContainsKey --- build.cake | 8 +- .../Polly.NetStandard11.csproj} | 0 .../Properties/AssemblyInfo.cs | 0 .../project.json | 2 +- src/Polly.Pcl.Specs/Polly.Pcl.Specs.csproj | 10 +- src/Polly.Pcl.Specs/packages.config | 16 +- src/Polly.Shared/Polly.Shared.projitems | 2 + .../Registry/DefaultPolicyRegistry.cs | 82 +++++++ src/Polly.Shared/Registry/IPolicyRegistry.cs | 69 ++++++ .../Polly.SharedSpecs.projitems | 1 + .../Registry/DefaultPolicyRegistrySpecs.cs | 223 ++++++++++++++++++ src/Polly.sln | 16 +- 12 files changed, 403 insertions(+), 26 deletions(-) rename src/{Polly.NetStandard10/Polly.NetStandard10.csproj => Polly.NetStandard11/Polly.NetStandard11.csproj} (100%) rename src/{Polly.NetStandard10 => Polly.NetStandard11}/Properties/AssemblyInfo.cs (100%) rename src/{Polly.NetStandard10 => Polly.NetStandard11}/project.json (80%) create mode 100644 src/Polly.Shared/Registry/DefaultPolicyRegistry.cs create mode 100644 src/Polly.Shared/Registry/IPolicyRegistry.cs create mode 100644 src/Polly.SharedSpecs/Registry/DefaultPolicyRegistrySpecs.cs diff --git a/build.cake b/build.cake index dde3bc5ad13..a7286210bd7 100644 --- a/build.cake +++ b/build.cake @@ -49,7 +49,7 @@ var snkFile = srcDir + File(keyName); var projectToNugetFolderMap = new Dictionary() { { "Net45" , new [] {"net45"} }, - { "NetStandard10", new [] {"netstandard1.0"} }, + { "NetStandard11", new [] {"netstandard1.1"} }, }; var net40AsyncProjectToNugetFolderMap = new Dictionary() { @@ -141,11 +141,11 @@ Task("__UpdateDotNetStandardAssemblyVersionNumber") // NOTE: TEMPORARY fix only, while GitVersionTask does not support .Net Standard assemblies. See https://github.com/App-vNext/Polly/issues/176. // This build Task can be removed when GitVersionTask supports .Net Standard assemblies. var assemblySemVer = gitVersionOutput["AssemblySemVer"].ToString(); - Information("Updating NetStandard10 AssemblyVersion to {0}", assemblySemVer); - var replacedFiles = ReplaceRegexInFiles("./src/Polly.NetStandard10/Properties/AssemblyInfo.cs", "AssemblyVersion[(]\".*\"[)]", "AssemblyVersion(\"" + assemblySemVer +"\")"); + Information("Updating NetStandard11 AssemblyVersion to {0}", assemblySemVer); + var replacedFiles = ReplaceRegexInFiles("./src/Polly.NetStandard11/Properties/AssemblyInfo.cs", "AssemblyVersion[(]\".*\"[)]", "AssemblyVersion(\"" + assemblySemVer +"\")"); if (!replacedFiles.Any()) { - Information("NetStandard1.0 AssemblyVersion could not be updated."); + Information("NetStandard1.1 AssemblyVersion could not be updated."); } }); diff --git a/src/Polly.NetStandard10/Polly.NetStandard10.csproj b/src/Polly.NetStandard11/Polly.NetStandard11.csproj similarity index 100% rename from src/Polly.NetStandard10/Polly.NetStandard10.csproj rename to src/Polly.NetStandard11/Polly.NetStandard11.csproj diff --git a/src/Polly.NetStandard10/Properties/AssemblyInfo.cs b/src/Polly.NetStandard11/Properties/AssemblyInfo.cs similarity index 100% rename from src/Polly.NetStandard10/Properties/AssemblyInfo.cs rename to src/Polly.NetStandard11/Properties/AssemblyInfo.cs diff --git a/src/Polly.NetStandard10/project.json b/src/Polly.NetStandard11/project.json similarity index 80% rename from src/Polly.NetStandard10/project.json rename to src/Polly.NetStandard11/project.json index df51d04336a..a5bea354690 100644 --- a/src/Polly.NetStandard10/project.json +++ b/src/Polly.NetStandard11/project.json @@ -4,6 +4,6 @@ "NETStandard.Library": "1.6.1" }, "frameworks": { - "netstandard1.0": {} + "netstandard1.1": {} } } \ No newline at end of file diff --git a/src/Polly.Pcl.Specs/Polly.Pcl.Specs.csproj b/src/Polly.Pcl.Specs/Polly.Pcl.Specs.csproj index 96930ecd2f6..54b2ac7170c 100644 --- a/src/Polly.Pcl.Specs/Polly.Pcl.Specs.csproj +++ b/src/Polly.Pcl.Specs/Polly.Pcl.Specs.csproj @@ -14,7 +14,7 @@ en-US 512 {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Profile259 + Profile111 v4.5 @@ -72,21 +72,21 @@ - + {5017174e-dac5-4408-ab15-1f902f40c612} - Polly.NetStandard10 + Polly.NetStandard11 + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + - -