From 8f753716a7590e846a9a9900c7c9fe27c1748659 Mon Sep 17 00:00:00 2001 From: Sean Farrow Date: Mon, 21 May 2018 10:29:42 +0100 Subject: [PATCH 01/12] Add projects stargeting .net standard 2.0. --- ...istributedCache.NetStandard20.Specs.csproj | 35 ++++++++++++++++++ .../Properties/AssemblyInfo.cs | 5 +++ ...ing.IDistributedCache.NetStandard20.csproj | 37 +++++++++++++++++++ .../Properties/AssemblyInfo.cs | 9 +++++ src/Polly.Caching.IDistributedCache.sln | 35 +++++++++--------- 5 files changed, 103 insertions(+), 18 deletions(-) create mode 100644 src/Polly.Caching.IDistributedCache.NetStandard20.Specs/Polly.Caching.IDistributedCache.NetStandard20.Specs.csproj create mode 100644 src/Polly.Caching.IDistributedCache.NetStandard20.Specs/Properties/AssemblyInfo.cs create mode 100644 src/Polly.Caching.IDistributedCache.NetStandard20/Polly.Caching.IDistributedCache.NetStandard20.csproj create mode 100644 src/Polly.Caching.IDistributedCache.NetStandard20/Properties/AssemblyInfo.cs diff --git a/src/Polly.Caching.IDistributedCache.NetStandard20.Specs/Polly.Caching.IDistributedCache.NetStandard20.Specs.csproj b/src/Polly.Caching.IDistributedCache.NetStandard20.Specs/Polly.Caching.IDistributedCache.NetStandard20.Specs.csproj new file mode 100644 index 0000000..e1936c5 --- /dev/null +++ b/src/Polly.Caching.IDistributedCache.NetStandard20.Specs/Polly.Caching.IDistributedCache.NetStandard20.Specs.csproj @@ -0,0 +1,35 @@ + + + false + Library + netcoreapp2.0 + library + + + full + TRACE;DEBUG;NETCOREAPP1_1;NETCOREAPP1_1;PORTABLE + + + pdbonly + true + TRACE;RELEASE;NETCOREAPP1_1;RELEASE;NETCOREAPP1_1;PORTABLE + + + + + + + + + + + + + Properties\GlobalAssemblyInfo.cs + + + + + + + \ No newline at end of file diff --git a/src/Polly.Caching.IDistributedCache.NetStandard20.Specs/Properties/AssemblyInfo.cs b/src/Polly.Caching.IDistributedCache.NetStandard20.Specs/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..ce432ba --- /dev/null +++ b/src/Polly.Caching.IDistributedCache.NetStandard20.Specs/Properties/AssemblyInfo.cs @@ -0,0 +1,5 @@ +using System.Reflection; +using Xunit; + +[assembly: AssemblyTitle("Polly.Caching.IDistributedCache.NetStandard11.Specs")] +[assembly: CollectionBehavior(DisableTestParallelization = true)] \ No newline at end of file diff --git a/src/Polly.Caching.IDistributedCache.NetStandard20/Polly.Caching.IDistributedCache.NetStandard20.csproj b/src/Polly.Caching.IDistributedCache.NetStandard20/Polly.Caching.IDistributedCache.NetStandard20.csproj new file mode 100644 index 0000000..ed6038b --- /dev/null +++ b/src/Polly.Caching.IDistributedCache.NetStandard20/Polly.Caching.IDistributedCache.NetStandard20.csproj @@ -0,0 +1,37 @@ + + + Polly.Caching.IDistributedCache + ..\Polly.Caching.IDistributedCache.Net45\Polly.Caching.IDistributedCache.snk + TRACE;PORTABLE + en-US + false + true + Polly.Caching.IDistributedCache + netstandard2.0 + 2.0.0 + + + full + true + + + + pdbonly + true + + + + False + + + + + Properties\GlobalAssemblyInfo.cs + + + + + + + + \ No newline at end of file diff --git a/src/Polly.Caching.IDistributedCache.NetStandard20/Properties/AssemblyInfo.cs b/src/Polly.Caching.IDistributedCache.NetStandard20/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d31693c --- /dev/null +++ b/src/Polly.Caching.IDistributedCache.NetStandard20/Properties/AssemblyInfo.cs @@ -0,0 +1,9 @@ +using System; +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: AssemblyTitle("Polly.Caching.IDistributedCache")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: CLSCompliant(false)] // Because Microsoft.Extensions.Caching.Memory.IDistributedCache, on which Polly.Caching.IDistributedCache.NetStandard11 depends, is not CLSCompliant. + +[assembly: InternalsVisibleTo("Polly.Caching.IDistributedCache.NetStandard11.Specs")] \ No newline at end of file diff --git a/src/Polly.Caching.IDistributedCache.sln b/src/Polly.Caching.IDistributedCache.sln index ee6a25b..34b38a1 100644 --- a/src/Polly.Caching.IDistributedCache.sln +++ b/src/Polly.Caching.IDistributedCache.sln @@ -13,9 +13,13 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Polly.Caching.IDistributedC EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Polly.Caching.IDistributedCache.SharedSpecs", "Polly.Caching.IDistributedCache.SharedSpecs\Polly.Caching.IDistributedCache.SharedSpecs.shproj", "{8D537C37-A4A2-4BE1-84BC-34F1AFB51CA8}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Polly.Caching.IDistributedCache.NetStandard11.Specs", "Polly.Caching.IDistributedCache.NetStandard11.Specs\Polly.Caching.IDistributedCache.NetStandard11.Specs.csproj", "{4AB46D16-0806-4F51-8677-D849BA87CB05}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Polly.Caching.IDistributedCache.NetStandard11.Specs", "Polly.Caching.IDistributedCache.NetStandard11.Specs\Polly.Caching.IDistributedCache.NetStandard11.Specs.csproj", "{4AB46D16-0806-4F51-8677-D849BA87CB05}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Polly.Caching.IDistributedCache.NetStandard11", "Polly.Caching.IDistributedCache.NetStandard11\Polly.Caching.IDistributedCache.NetStandard11.csproj", "{5017174E-DAC5-4408-AB15-1F902F40C612}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Polly.Caching.IDistributedCache.NetStandard11", "Polly.Caching.IDistributedCache.NetStandard11\Polly.Caching.IDistributedCache.NetStandard11.csproj", "{5017174E-DAC5-4408-AB15-1F902F40C612}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Polly.Caching.IDistributedCache.NetStandard20", "Polly.Caching.IDistributedCache.NetStandard20\Polly.Caching.IDistributedCache.NetStandard20.csproj", "{BEB48D73-7C49-49AD-A53E-EBE7897833D7}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Polly.Caching.IDistributedCache.NetStandard20.Specs", "Polly.Caching.IDistributedCache.NetStandard20.Specs\Polly.Caching.IDistributedCache.NetStandard20.Specs.csproj", "{2D38A483-3D6D-4B50-BE51-DBFFB960EF69}" EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution @@ -29,32 +33,27 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {29265540-F724-4324-9321-643A0FCB133F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {29265540-F724-4324-9321-643A0FCB133F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {29265540-F724-4324-9321-643A0FCB133F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {29265540-F724-4324-9321-643A0FCB133F}.Release|Any CPU.Build.0 = Release|Any CPU - {5F2BD87D-A7ED-433D-B7E3-F3072D07C1DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5F2BD87D-A7ED-433D-B7E3-F3072D07C1DC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5F2BD87D-A7ED-433D-B7E3-F3072D07C1DC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5F2BD87D-A7ED-433D-B7E3-F3072D07C1DC}.Release|Any CPU.Build.0 = Release|Any CPU {4AB46D16-0806-4F51-8677-D849BA87CB05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {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 {5017174E-DAC5-4408-AB15-1F902F40C612}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5017174E-DAC5-4408-AB15-1F902F40C612}.Debug|Any CPU.Build.0 = Debug|Any CPU {5017174E-DAC5-4408-AB15-1F902F40C612}.Release|Any CPU.ActiveCfg = Release|Any CPU {5017174E-DAC5-4408-AB15-1F902F40C612}.Release|Any CPU.Build.0 = Release|Any CPU - {65062661-9E19-4FC6-859C-8B7811553E13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {65062661-9E19-4FC6-859C-8B7811553E13}.Debug|Any CPU.Build.0 = Debug|Any CPU - {65062661-9E19-4FC6-859C-8B7811553E13}.Release|Any CPU.ActiveCfg = Release|Any CPU - {65062661-9E19-4FC6-859C-8B7811553E13}.Release|Any CPU.Build.0 = Release|Any CPU + {BEB48D73-7C49-49AD-A53E-EBE7897833D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BEB48D73-7C49-49AD-A53E-EBE7897833D7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BEB48D73-7C49-49AD-A53E-EBE7897833D7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BEB48D73-7C49-49AD-A53E-EBE7897833D7}.Release|Any CPU.Build.0 = Release|Any CPU + {2D38A483-3D6D-4B50-BE51-DBFFB960EF69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2D38A483-3D6D-4B50-BE51-DBFFB960EF69}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2D38A483-3D6D-4B50-BE51-DBFFB960EF69}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2D38A483-3D6D-4B50-BE51-DBFFB960EF69}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B79F0C1F-1732-4033-8D25-C26DAD98B10D} + EndGlobalSection EndGlobal From 76735b41c35e7541c989cfeef444315dee17701e Mon Sep 17 00:00:00 2001 From: Sean Farrow Date: Mon, 21 May 2018 11:02:31 +0100 Subject: [PATCH 02/12] Update the Microsoft.Extensions.Caching.Abstractions package to v2.0.2 for the project targeting .net standard 2.0 and ensure all tests compile and pass. --- ...ing.IDistributedCache.NetStandard20.csproj | 2 +- ...IDistributedCacheByteArrayProviderSpecs.cs | 48 ++++++++++++++--- ...ardIDistributedCacheStringProviderSpecs.cs | 54 +++++++++++++++---- 3 files changed, 84 insertions(+), 20 deletions(-) diff --git a/src/Polly.Caching.IDistributedCache.NetStandard20/Polly.Caching.IDistributedCache.NetStandard20.csproj b/src/Polly.Caching.IDistributedCache.NetStandard20/Polly.Caching.IDistributedCache.NetStandard20.csproj index ed6038b..bde5efa 100644 --- a/src/Polly.Caching.IDistributedCache.NetStandard20/Polly.Caching.IDistributedCache.NetStandard20.csproj +++ b/src/Polly.Caching.IDistributedCache.NetStandard20/Polly.Caching.IDistributedCache.NetStandard20.csproj @@ -30,7 +30,7 @@ - + diff --git a/src/Polly.Caching.IDistributedCache.SharedSpecs/NetStandardIDistributedCacheByteArrayProviderSpecs.cs b/src/Polly.Caching.IDistributedCache.SharedSpecs/NetStandardIDistributedCacheByteArrayProviderSpecs.cs index 08e9878..201e137 100644 --- a/src/Polly.Caching.IDistributedCache.SharedSpecs/NetStandardIDistributedCacheByteArrayProviderSpecs.cs +++ b/src/Polly.Caching.IDistributedCache.SharedSpecs/NetStandardIDistributedCacheByteArrayProviderSpecs.cs @@ -118,12 +118,20 @@ public async Task GetAsync_should_return_instance_previously_stored_in_cache() Mock mockDistributedCache = new Mock(); string key = "anything"; var cachedValue = new byte[] { 0 }; - mockDistributedCache.Setup(idc => idc.GetAsync(It.Is(k => k == key))).Returns(Task.FromResult(cachedValue)).Verifiable(); + mockDistributedCache.Setup(idc => idc.GetAsync(It.Is(k => k == key) +#if NETCOREAPP2_0 +, It.IsAny() +#endif + )).Returns(Task.FromResult(cachedValue)); IAsyncCacheProvider provider = mockDistributedCache.Object.AsAsyncCacheProvider(); byte[] got = await provider.GetAsync(key, CancellationToken.None, false); - mockDistributedCache.Verify(v => v.GetAsync(key), Times.Once); + mockDistributedCache.Verify(v => v.GetAsync(key +#if NETCOREAPP2_0 +, It.IsAny() +#endif + ), Times.Once); got.Should().BeSameAs(cachedValue); } @@ -133,13 +141,21 @@ public async Task GetAsync_should_return_null_on_unknown_key() Mock mockDistributedCache = new Mock(); string key = "anything"; var cachedValue = new byte[] { 0 }; - mockDistributedCache.Setup(idc => idc.GetAsync(It.Is(k => k == key))).Returns(Task.FromResult(cachedValue)).Verifiable(); + mockDistributedCache.Setup(idc => idc.GetAsync(It.Is(k => k == key) +#if NETCOREAPP2_0 +, It.IsAny() +#endif + )).Returns(Task.FromResult(cachedValue)); IAsyncCacheProvider provider = mockDistributedCache.Object.AsAsyncCacheProvider(); string someOtherKey = Guid.NewGuid().ToString(); byte[] got = await provider.GetAsync(someOtherKey, CancellationToken.None, false); - mockDistributedCache.Verify(v => v.GetAsync(someOtherKey), Times.Once); + mockDistributedCache.Verify(v => v.GetAsync(someOtherKey +#if NETCOREAPP2_0 +, It.IsAny() +#endif + ), Times.Once); got.Should().BeNull(); } @@ -167,14 +183,22 @@ public async Task PutAsync_should_put_item_using_passed_nonsliding_ttl() IAsyncCacheProvider provider = mockDistributedCache.Object.AsAsyncCacheProvider(); - mockDistributedCache.Setup(idc => idc.SetAsync(It.Is(k => k == key), It.Is(v => v == valueToCache), It.IsAny())).Returns(Task.CompletedTask).Verifiable(); + mockDistributedCache.Setup(idc => idc.SetAsync(It.Is(k => k == key), It.Is(v => v == valueToCache), It.IsAny() +#if NETCOREAPP2_0 +, It.IsAny() +#endif + )).Returns(Task.CompletedTask).Verifiable(); TimeSpan timespan = TimeSpan.FromSeconds(10); Ttl ttl = new Ttl(timespan, false); await provider.PutAsync(key, valueToCache, ttl, CancellationToken.None, false); - mockDistributedCache.Verify(idc => idc.SetAsync(key, valueToCache, It.Is(o => o.AbsoluteExpirationRelativeToNow == timespan))); + mockDistributedCache.Verify(idc => idc.SetAsync(key, valueToCache, It.Is(o => o.AbsoluteExpirationRelativeToNow == timespan) +#if NETCOREAPP2_0 +, It.IsAny() +#endif + )); } [Fact] @@ -186,13 +210,21 @@ public async Task PutAsync_should_put_item_using_passed_sliding_ttl() IAsyncCacheProvider provider = mockDistributedCache.Object.AsAsyncCacheProvider(); - mockDistributedCache.Setup(idc => idc.SetAsync(It.Is(k => k == key), It.Is(v => v == valueToCache), It.IsAny())).Returns(Task.CompletedTask).Verifiable(); + mockDistributedCache.Setup(idc => idc.SetAsync(It.Is(k => k == key), It.Is(v => v == valueToCache), It.IsAny() +#if NETCOREAPP2_0 +, It.IsAny() +#endif + )).Returns(Task.CompletedTask).Verifiable(); TimeSpan timespan = TimeSpan.FromSeconds(10); Ttl ttl = new Ttl(timespan, true); await provider.PutAsync(key, valueToCache, ttl, CancellationToken.None, false); - mockDistributedCache.Verify(idc => idc.SetAsync(key, valueToCache, It.Is(o => o.SlidingExpiration == timespan))); + mockDistributedCache.Verify(idc => idc.SetAsync(key, valueToCache, It.Is(o => o.SlidingExpiration == timespan) +#if NETCOREAPP2_0 +, It.IsAny() +#endif + )); } [Fact] diff --git a/src/Polly.Caching.IDistributedCache.SharedSpecs/NetStandardIDistributedCacheStringProviderSpecs.cs b/src/Polly.Caching.IDistributedCache.SharedSpecs/NetStandardIDistributedCacheStringProviderSpecs.cs index accd651..b910c8d 100644 --- a/src/Polly.Caching.IDistributedCache.SharedSpecs/NetStandardIDistributedCacheStringProviderSpecs.cs +++ b/src/Polly.Caching.IDistributedCache.SharedSpecs/NetStandardIDistributedCacheStringProviderSpecs.cs @@ -114,12 +114,20 @@ public async Task GetAsync_should_return_instance_previously_stored_in_cache() { Mock mockDistributedCache = new Mock(); string key = "anything"; - mockDistributedCache.Setup(idc => idc.GetAsync(It.Is(k => k == key))).Returns(Task.FromResult(new byte[0] { })).Verifiable(); // Because GetStringAsync() is an extension method, we cannot mock it. We mock GetAsync() instead. + mockDistributedCache.Setup(idc => idc.GetAsync(It.Is(k => k == key) +#if NETCOREAPP2_0 +, It.IsAny() +#endif + )).Returns(Task.FromResult(new byte[0] { })).Verifiable(); // Because GetStringAsync() is an extension method, we cannot mock it. We mock GetAsync() instead. IAsyncCacheProvider provider = mockDistributedCache.Object.AsAsyncCacheProvider(); string got = await provider.GetAsync(key, CancellationToken.None, false); - mockDistributedCache.Verify(v => v.GetAsync(key), Times.Once); + mockDistributedCache.Verify(v => v.GetAsync(key +#if NETCOREAPP2_0 +, It.IsAny() +#endif + ), Times.Once); } [Fact] @@ -127,13 +135,21 @@ public async Task GetAsync_should_return_null_on_unknown_key() { Mock mockDistributedCache = new Mock(); string key = "anything"; - mockDistributedCache.Setup(idc => idc.GetAsync(It.Is(k => k == key))).Returns(Task.FromResult(new byte[0] { })).Verifiable(); // Because GetStringAsync() is an extension method, we cannot mock it. We mock GetAsync() instead. + mockDistributedCache.Setup(idc => idc.GetAsync(It.Is(k => k == key) +#if NETCOREAPP2_0 +, It.IsAny() +#endif + )).Returns(Task.FromResult(new byte[0] { })); // Because GetStringAsync() is an extension method, we cannot mock it. We mock GetAsync() instead. IAsyncCacheProvider provider = mockDistributedCache.Object.AsAsyncCacheProvider(); string someOtherKey = Guid.NewGuid().ToString(); string got = await provider.GetAsync(someOtherKey, CancellationToken.None, false); - mockDistributedCache.Verify(v => v.GetAsync(someOtherKey), Times.Once); + mockDistributedCache.Verify(v => v.GetAsync(someOtherKey +#if NETCOREAPP2_0 +, It.IsAny() +#endif + ), Times.Once); got.Should().BeNull(); } @@ -148,9 +164,9 @@ public void GetAsync_should_throw_for_cancellation() action.ShouldThrow(); } - #endregion +#endregion - #region Put +#region Put [Fact] public async Task PutAsync_should_put_item_using_passed_nonsliding_ttl() @@ -161,14 +177,22 @@ public async Task PutAsync_should_put_item_using_passed_nonsliding_ttl() IAsyncCacheProvider provider = mockDistributedCache.Object.AsAsyncCacheProvider(); - mockDistributedCache.Setup(idc => idc.SetAsync(It.Is(k => k == key), It.IsAny(), It.IsAny())).Returns(Task.CompletedTask).Verifiable(); // Because SetStringAsync() is an extension method, we cannot mock it. We mock SetAsync() instead. + mockDistributedCache.Setup(idc => idc.SetAsync(It.Is(k => k == key), It.IsAny(), It.IsAny() +#if NETCOREAPP2_0 +, It.IsAny() +#endif + )).Returns(Task.CompletedTask).Verifiable(); // Because SetStringAsync() is an extension method, we cannot mock it. We mock SetAsync() instead. TimeSpan timespan = TimeSpan.FromSeconds(10); Ttl ttl = new Ttl(timespan, false); await provider.PutAsync(key, valueToCache, ttl, CancellationToken.None, false); - mockDistributedCache.Verify(idc => idc.SetAsync(key, It.IsAny(), It.Is(o => o.AbsoluteExpirationRelativeToNow == timespan))); + mockDistributedCache.Verify(idc => idc.SetAsync(key, It.IsAny(), It.Is(o => o.AbsoluteExpirationRelativeToNow == timespan) +#if NETCOREAPP2_0 +, It.IsAny() +#endif + )); } [Fact] @@ -180,13 +204,21 @@ public async Task PutAsync_should_put_item_using_passed_sliding_ttl() IAsyncCacheProvider provider = mockDistributedCache.Object.AsAsyncCacheProvider(); - mockDistributedCache.Setup(idc => idc.SetAsync(It.Is(k => k == key), It.IsAny(), It.IsAny())).Returns(Task.CompletedTask).Verifiable(); // Because SetStringAsync() is an extension method, we cannot mock it. We mock SetAsync() instead. + mockDistributedCache.Setup(idc => idc.SetAsync(It.Is(k => k == key), It.IsAny(), It.IsAny() +#if NETCOREAPP2_0 +, It.IsAny() +#endif + )).Returns(Task.CompletedTask); // Because SetStringAsync() is an extension method, we cannot mock it. We mock SetAsync() instead. TimeSpan timespan = TimeSpan.FromSeconds(10); Ttl ttl = new Ttl(timespan, true); await provider.PutAsync(key, valueToCache, ttl, CancellationToken.None, false); - mockDistributedCache.Verify(idc => idc.SetAsync(key, It.IsAny(), It.Is(o => o.SlidingExpiration == timespan))); + mockDistributedCache.Verify(idc => idc.SetAsync(key, It.IsAny(), It.Is(o => o.SlidingExpiration == timespan) +#if NETCOREAPP2_0 +, It.IsAny() +#endif +)); } [Fact] @@ -203,7 +235,7 @@ public void PutAsync_should_throw_for_cancellation() Func action = () => provider.PutAsync(key, valueToCache, ttl, new CancellationToken(true), false); action.ShouldThrow(); } - #endregion +#endregion } } \ No newline at end of file From 54bd7a770f9adeb180bbc368ebe0a66f5385f5e0 Mon Sep 17 00:00:00 2001 From: Sean Farrow Date: Tue, 22 May 2018 06:32:15 +0100 Subject: [PATCH 03/12] Rename all the projects to conform to the new agreed naming scheme for caching projects. --- src/GlobalAssemblyInfo.cs | 4 +- ...ng.Distributed.NetStandard11.Specs.csproj} | 4 +- .../Properties/AssemblyInfo.cs | 2 +- ....Caching.Distributed.NetStandard11.csproj} | 8 +-- .../Properties/AssemblyInfo.cs | 4 +- ...ng.Distributed.NetStandard20.Specs.csproj} | 4 +- .../Properties/AssemblyInfo.cs | 2 +- ....Caching.Distributed.NetStandard20.csproj} | 8 +-- .../Properties/AssemblyInfo.cs | 4 +- .../CacheProviderHelper.cs | 2 +- ...ndardIDistributedCacheByteArrayProvider.cs | 2 +- .../NetStandardIDistributedCacheProvider.cs | 2 +- ...StandardIDistributedCacheStringProvider.cs | 2 +- ...olly.Caching.Distributed.Shared.projitems} | 2 +- .../Polly.Caching.Distributed.Shared.shproj} | 2 +- .../TtlHelper.cs | 2 +- .../TtlStrategyHelper.cs | 2 +- .../CacheProviderHelperTests.cs | 4 +- ...IDistributedCacheByteArrayProviderSpecs.cs | 4 +- ...ardIDistributedCacheStringProviderSpecs.cs | 2 +- ...Caching.Distributed.SharedSpecs.projitems} | 2 +- ...ly.Caching.Distributed.SharedSpecs.shproj} | 2 +- .../TtlStrategyHelperTests.cs | 2 +- ...uspec => Polly.Caching.Distributed.nuspec} | 0 src/Polly.Caching.Distributed.sln | 57 ++++++++++++++++++ src/Polly.Caching.IDistributedCache.sln | 59 ------------------- 26 files changed, 93 insertions(+), 95 deletions(-) rename src/{Polly.Caching.IDistributedCache.NetStandard11.Specs/Polly.Caching.IDistributedCache.NetStandard11.Specs.csproj => Polly.Caching.Distributed.NetStandard11.Specs/Polly.Caching.Distributed.NetStandard11.Specs.csproj} (83%) rename src/{Polly.Caching.IDistributedCache.NetStandard20.Specs => Polly.Caching.Distributed.NetStandard11.Specs}/Properties/AssemblyInfo.cs (56%) rename src/{Polly.Caching.IDistributedCache.NetStandard11/Polly.Caching.IDistributedCache.NetStandard11.csproj => Polly.Caching.Distributed.NetStandard11/Polly.Caching.Distributed.NetStandard11.csproj} (79%) rename src/{Polly.Caching.IDistributedCache.NetStandard20 => Polly.Caching.Distributed.NetStandard11}/Properties/AssemblyInfo.cs (67%) rename src/{Polly.Caching.IDistributedCache.NetStandard20.Specs/Polly.Caching.IDistributedCache.NetStandard20.Specs.csproj => Polly.Caching.Distributed.NetStandard20.Specs/Polly.Caching.Distributed.NetStandard20.Specs.csproj} (83%) rename src/{Polly.Caching.IDistributedCache.NetStandard11.Specs => Polly.Caching.Distributed.NetStandard20.Specs}/Properties/AssemblyInfo.cs (56%) rename src/{Polly.Caching.IDistributedCache.NetStandard20/Polly.Caching.IDistributedCache.NetStandard20.csproj => Polly.Caching.Distributed.NetStandard20/Polly.Caching.Distributed.NetStandard20.csproj} (79%) rename src/{Polly.Caching.IDistributedCache.NetStandard11 => Polly.Caching.Distributed.NetStandard20}/Properties/AssemblyInfo.cs (67%) rename src/{Polly.Caching.IDistributedCache.Shared => Polly.Caching.Distributed.Shared}/CacheProviderHelper.cs (98%) rename src/{Polly.Caching.IDistributedCache.Shared => Polly.Caching.Distributed.Shared}/NetStandardIDistributedCacheByteArrayProvider.cs (99%) rename src/{Polly.Caching.IDistributedCache.Shared => Polly.Caching.Distributed.Shared}/NetStandardIDistributedCacheProvider.cs (99%) rename src/{Polly.Caching.IDistributedCache.Shared => Polly.Caching.Distributed.Shared}/NetStandardIDistributedCacheStringProvider.cs (99%) rename src/{Polly.Caching.IDistributedCache.Shared/Polly.Caching.IDistributedCache.Shared.projitems => Polly.Caching.Distributed.Shared/Polly.Caching.Distributed.Shared.projitems} (92%) rename src/{Polly.Caching.IDistributedCache.Shared/Polly.Caching.IDistributedCache.Shared.shproj => Polly.Caching.Distributed.Shared/Polly.Caching.Distributed.Shared.shproj} (92%) rename src/{Polly.Caching.IDistributedCache.Shared => Polly.Caching.Distributed.Shared}/TtlHelper.cs (91%) rename src/{Polly.Caching.IDistributedCache.Shared => Polly.Caching.Distributed.Shared}/TtlStrategyHelper.cs (97%) rename src/{Polly.Caching.IDistributedCache.SharedSpecs => Polly.Caching.Distributed.SharedSpecs}/CacheProviderHelperTests.cs (96%) rename src/{Polly.Caching.IDistributedCache.SharedSpecs => Polly.Caching.Distributed.SharedSpecs}/NetStandardIDistributedCacheByteArrayProviderSpecs.cs (99%) rename src/{Polly.Caching.IDistributedCache.SharedSpecs => Polly.Caching.Distributed.SharedSpecs}/NetStandardIDistributedCacheStringProviderSpecs.cs (99%) rename src/{Polly.Caching.IDistributedCache.SharedSpecs/Polly.Caching.IDistributedCache.SharedSpecs.projitems => Polly.Caching.Distributed.SharedSpecs/Polly.Caching.Distributed.SharedSpecs.projitems} (90%) rename src/{Polly.Caching.IDistributedCache.SharedSpecs/Polly.Caching.IDistributedCache.SharedSpecs.shproj => Polly.Caching.Distributed.SharedSpecs/Polly.Caching.Distributed.SharedSpecs.shproj} (91%) rename src/{Polly.Caching.IDistributedCache.SharedSpecs => Polly.Caching.Distributed.SharedSpecs}/TtlStrategyHelperTests.cs (98%) rename src/{Polly.Caching.IDistributedCache.nuspec => Polly.Caching.Distributed.nuspec} (100%) create mode 100644 src/Polly.Caching.Distributed.sln delete mode 100644 src/Polly.Caching.IDistributedCache.sln diff --git a/src/GlobalAssemblyInfo.cs b/src/GlobalAssemblyInfo.cs index 0682e1e..ca500b5 100644 --- a/src/GlobalAssemblyInfo.cs +++ b/src/GlobalAssemblyInfo.cs @@ -1,8 +1,8 @@ using System.Reflection; -[assembly: AssemblyProduct("Polly.Caching.IDistributedCache")] +[assembly: AssemblyProduct("Polly.Caching.Distributed")] [assembly: AssemblyCompany("App vNext")] -[assembly: AssemblyDescription("Polly.Caching.IDistributedCache is a IDistributedCache plug-in for the Polly CachePolicy. Polly is a library that allows developers to express resilience and transient fault handling policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner.")] +[assembly: AssemblyDescription("Polly.Caching.Distributed is a IDistributedCache plug-in for the Polly CachePolicy. Polly is a library that allows developers to express resilience and transient fault handling policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner.")] [assembly: AssemblyCopyright("Copyright (c) 2017, App vNext")] #if DEBUG diff --git a/src/Polly.Caching.IDistributedCache.NetStandard11.Specs/Polly.Caching.IDistributedCache.NetStandard11.Specs.csproj b/src/Polly.Caching.Distributed.NetStandard11.Specs/Polly.Caching.Distributed.NetStandard11.Specs.csproj similarity index 83% rename from src/Polly.Caching.IDistributedCache.NetStandard11.Specs/Polly.Caching.IDistributedCache.NetStandard11.Specs.csproj rename to src/Polly.Caching.Distributed.NetStandard11.Specs/Polly.Caching.Distributed.NetStandard11.Specs.csproj index b9d3883..921b49b 100644 --- a/src/Polly.Caching.IDistributedCache.NetStandard11.Specs/Polly.Caching.IDistributedCache.NetStandard11.Specs.csproj +++ b/src/Polly.Caching.Distributed.NetStandard11.Specs/Polly.Caching.Distributed.NetStandard11.Specs.csproj @@ -29,7 +29,7 @@ - + - + \ No newline at end of file diff --git a/src/Polly.Caching.IDistributedCache.NetStandard20.Specs/Properties/AssemblyInfo.cs b/src/Polly.Caching.Distributed.NetStandard11.Specs/Properties/AssemblyInfo.cs similarity index 56% rename from src/Polly.Caching.IDistributedCache.NetStandard20.Specs/Properties/AssemblyInfo.cs rename to src/Polly.Caching.Distributed.NetStandard11.Specs/Properties/AssemblyInfo.cs index ce432ba..51233cb 100644 --- a/src/Polly.Caching.IDistributedCache.NetStandard20.Specs/Properties/AssemblyInfo.cs +++ b/src/Polly.Caching.Distributed.NetStandard11.Specs/Properties/AssemblyInfo.cs @@ -1,5 +1,5 @@ using System.Reflection; using Xunit; -[assembly: AssemblyTitle("Polly.Caching.IDistributedCache.NetStandard11.Specs")] +[assembly: AssemblyTitle("Polly.Caching.Distributed.NetStandard11.Specs")] [assembly: CollectionBehavior(DisableTestParallelization = true)] \ No newline at end of file diff --git a/src/Polly.Caching.IDistributedCache.NetStandard11/Polly.Caching.IDistributedCache.NetStandard11.csproj b/src/Polly.Caching.Distributed.NetStandard11/Polly.Caching.Distributed.NetStandard11.csproj similarity index 79% rename from src/Polly.Caching.IDistributedCache.NetStandard11/Polly.Caching.IDistributedCache.NetStandard11.csproj rename to src/Polly.Caching.Distributed.NetStandard11/Polly.Caching.Distributed.NetStandard11.csproj index 740014f..81b6fa4 100644 --- a/src/Polly.Caching.IDistributedCache.NetStandard11/Polly.Caching.IDistributedCache.NetStandard11.csproj +++ b/src/Polly.Caching.Distributed.NetStandard11/Polly.Caching.Distributed.NetStandard11.csproj @@ -1,12 +1,12 @@  - Polly.Caching.IDistributedCache + Polly.Caching.Distributed ..\Polly.Caching.IDistributedCache.Net45\Polly.Caching.IDistributedCache.snk TRACE;PORTABLE en-US false true - Polly.Caching.IDistributedCache + Polly.Caching.Distributed netstandard1.1 1.6.1 @@ -20,7 +20,7 @@ true - + False @@ -33,5 +33,5 @@ - + \ No newline at end of file diff --git a/src/Polly.Caching.IDistributedCache.NetStandard20/Properties/AssemblyInfo.cs b/src/Polly.Caching.Distributed.NetStandard11/Properties/AssemblyInfo.cs similarity index 67% rename from src/Polly.Caching.IDistributedCache.NetStandard20/Properties/AssemblyInfo.cs rename to src/Polly.Caching.Distributed.NetStandard11/Properties/AssemblyInfo.cs index d31693c..c2736d2 100644 --- a/src/Polly.Caching.IDistributedCache.NetStandard20/Properties/AssemblyInfo.cs +++ b/src/Polly.Caching.Distributed.NetStandard11/Properties/AssemblyInfo.cs @@ -2,8 +2,8 @@ using System.Reflection; using System.Runtime.CompilerServices; -[assembly: AssemblyTitle("Polly.Caching.IDistributedCache")] +[assembly: AssemblyTitle("Polly.Caching.Distributed")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: CLSCompliant(false)] // Because Microsoft.Extensions.Caching.Memory.IDistributedCache, on which Polly.Caching.IDistributedCache.NetStandard11 depends, is not CLSCompliant. -[assembly: InternalsVisibleTo("Polly.Caching.IDistributedCache.NetStandard11.Specs")] \ No newline at end of file +[assembly: InternalsVisibleTo("Polly.Caching.Distributed.NetStandard11.Specs")] \ No newline at end of file diff --git a/src/Polly.Caching.IDistributedCache.NetStandard20.Specs/Polly.Caching.IDistributedCache.NetStandard20.Specs.csproj b/src/Polly.Caching.Distributed.NetStandard20.Specs/Polly.Caching.Distributed.NetStandard20.Specs.csproj similarity index 83% rename from src/Polly.Caching.IDistributedCache.NetStandard20.Specs/Polly.Caching.IDistributedCache.NetStandard20.Specs.csproj rename to src/Polly.Caching.Distributed.NetStandard20.Specs/Polly.Caching.Distributed.NetStandard20.Specs.csproj index e1936c5..e6f49fc 100644 --- a/src/Polly.Caching.IDistributedCache.NetStandard20.Specs/Polly.Caching.IDistributedCache.NetStandard20.Specs.csproj +++ b/src/Polly.Caching.Distributed.NetStandard20.Specs/Polly.Caching.Distributed.NetStandard20.Specs.csproj @@ -29,7 +29,7 @@ - + - + \ No newline at end of file diff --git a/src/Polly.Caching.IDistributedCache.NetStandard11.Specs/Properties/AssemblyInfo.cs b/src/Polly.Caching.Distributed.NetStandard20.Specs/Properties/AssemblyInfo.cs similarity index 56% rename from src/Polly.Caching.IDistributedCache.NetStandard11.Specs/Properties/AssemblyInfo.cs rename to src/Polly.Caching.Distributed.NetStandard20.Specs/Properties/AssemblyInfo.cs index ce432ba..d3cdae6 100644 --- a/src/Polly.Caching.IDistributedCache.NetStandard11.Specs/Properties/AssemblyInfo.cs +++ b/src/Polly.Caching.Distributed.NetStandard20.Specs/Properties/AssemblyInfo.cs @@ -1,5 +1,5 @@ using System.Reflection; using Xunit; -[assembly: AssemblyTitle("Polly.Caching.IDistributedCache.NetStandard11.Specs")] +[assembly: AssemblyTitle("Polly.Caching.Distributed.NetStandard20.Specs")] [assembly: CollectionBehavior(DisableTestParallelization = true)] \ No newline at end of file diff --git a/src/Polly.Caching.IDistributedCache.NetStandard20/Polly.Caching.IDistributedCache.NetStandard20.csproj b/src/Polly.Caching.Distributed.NetStandard20/Polly.Caching.Distributed.NetStandard20.csproj similarity index 79% rename from src/Polly.Caching.IDistributedCache.NetStandard20/Polly.Caching.IDistributedCache.NetStandard20.csproj rename to src/Polly.Caching.Distributed.NetStandard20/Polly.Caching.Distributed.NetStandard20.csproj index bde5efa..6072064 100644 --- a/src/Polly.Caching.IDistributedCache.NetStandard20/Polly.Caching.IDistributedCache.NetStandard20.csproj +++ b/src/Polly.Caching.Distributed.NetStandard20/Polly.Caching.Distributed.NetStandard20.csproj @@ -1,12 +1,12 @@  - Polly.Caching.IDistributedCache + Polly.Caching.Distributed ..\Polly.Caching.IDistributedCache.Net45\Polly.Caching.IDistributedCache.snk TRACE;PORTABLE en-US false true - Polly.Caching.IDistributedCache + Polly.Caching.Distributed netstandard2.0 2.0.0 @@ -20,7 +20,7 @@ true - + False @@ -33,5 +33,5 @@ - + \ No newline at end of file diff --git a/src/Polly.Caching.IDistributedCache.NetStandard11/Properties/AssemblyInfo.cs b/src/Polly.Caching.Distributed.NetStandard20/Properties/AssemblyInfo.cs similarity index 67% rename from src/Polly.Caching.IDistributedCache.NetStandard11/Properties/AssemblyInfo.cs rename to src/Polly.Caching.Distributed.NetStandard20/Properties/AssemblyInfo.cs index d31693c..2847bed 100644 --- a/src/Polly.Caching.IDistributedCache.NetStandard11/Properties/AssemblyInfo.cs +++ b/src/Polly.Caching.Distributed.NetStandard20/Properties/AssemblyInfo.cs @@ -2,8 +2,8 @@ using System.Reflection; using System.Runtime.CompilerServices; -[assembly: AssemblyTitle("Polly.Caching.IDistributedCache")] +[assembly: AssemblyTitle("Polly.Caching.Distributed")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: CLSCompliant(false)] // Because Microsoft.Extensions.Caching.Memory.IDistributedCache, on which Polly.Caching.IDistributedCache.NetStandard11 depends, is not CLSCompliant. -[assembly: InternalsVisibleTo("Polly.Caching.IDistributedCache.NetStandard11.Specs")] \ No newline at end of file +[assembly: InternalsVisibleTo("Polly.Caching.Distributed.NetStandard20.Specs")] \ No newline at end of file diff --git a/src/Polly.Caching.IDistributedCache.Shared/CacheProviderHelper.cs b/src/Polly.Caching.Distributed.Shared/CacheProviderHelper.cs similarity index 98% rename from src/Polly.Caching.IDistributedCache.Shared/CacheProviderHelper.cs rename to src/Polly.Caching.Distributed.Shared/CacheProviderHelper.cs index e1827f2..4b0381e 100644 --- a/src/Polly.Caching.IDistributedCache.Shared/CacheProviderHelper.cs +++ b/src/Polly.Caching.Distributed.Shared/CacheProviderHelper.cs @@ -1,6 +1,6 @@ using System; -namespace Polly.Caching.IDistributedCache +namespace Polly.Caching.Distributed { /// /// Provides helper methods for creating a Polly or implementation from a . diff --git a/src/Polly.Caching.IDistributedCache.Shared/NetStandardIDistributedCacheByteArrayProvider.cs b/src/Polly.Caching.Distributed.Shared/NetStandardIDistributedCacheByteArrayProvider.cs similarity index 99% rename from src/Polly.Caching.IDistributedCache.Shared/NetStandardIDistributedCacheByteArrayProvider.cs rename to src/Polly.Caching.Distributed.Shared/NetStandardIDistributedCacheByteArrayProvider.cs index 8b7cd0a..ce2f54f 100644 --- a/src/Polly.Caching.IDistributedCache.Shared/NetStandardIDistributedCacheByteArrayProvider.cs +++ b/src/Polly.Caching.Distributed.Shared/NetStandardIDistributedCacheByteArrayProvider.cs @@ -2,7 +2,7 @@ using System.Threading; using System.Threading.Tasks; -namespace Polly.Caching.IDistributedCache +namespace Polly.Caching.Distributed { /// /// An implementation of and for Dot Net Core/Standard distributed caching implemented with . TResult is byte[]. diff --git a/src/Polly.Caching.IDistributedCache.Shared/NetStandardIDistributedCacheProvider.cs b/src/Polly.Caching.Distributed.Shared/NetStandardIDistributedCacheProvider.cs similarity index 99% rename from src/Polly.Caching.IDistributedCache.Shared/NetStandardIDistributedCacheProvider.cs rename to src/Polly.Caching.Distributed.Shared/NetStandardIDistributedCacheProvider.cs index 5a483d5..01d87d6 100644 --- a/src/Polly.Caching.IDistributedCache.Shared/NetStandardIDistributedCacheProvider.cs +++ b/src/Polly.Caching.Distributed.Shared/NetStandardIDistributedCacheProvider.cs @@ -3,7 +3,7 @@ using System.Threading; using System.Threading.Tasks; -namespace Polly.Caching.IDistributedCache +namespace Polly.Caching.Distributed { /// /// Abstract base class for implementation of and for Dot Net Core/Standard distributed caching implemented with . diff --git a/src/Polly.Caching.IDistributedCache.Shared/NetStandardIDistributedCacheStringProvider.cs b/src/Polly.Caching.Distributed.Shared/NetStandardIDistributedCacheStringProvider.cs similarity index 99% rename from src/Polly.Caching.IDistributedCache.Shared/NetStandardIDistributedCacheStringProvider.cs rename to src/Polly.Caching.Distributed.Shared/NetStandardIDistributedCacheStringProvider.cs index 890ea3c..9d1fc7a 100644 --- a/src/Polly.Caching.IDistributedCache.Shared/NetStandardIDistributedCacheStringProvider.cs +++ b/src/Polly.Caching.Distributed.Shared/NetStandardIDistributedCacheStringProvider.cs @@ -3,7 +3,7 @@ using System.Threading.Tasks; using Microsoft.Extensions.Caching.Distributed; -namespace Polly.Caching.IDistributedCache +namespace Polly.Caching.Distributed { /// /// An implementation of and for Dot Net Core/Standard distributed caching implemented with . TResult is string. diff --git a/src/Polly.Caching.IDistributedCache.Shared/Polly.Caching.IDistributedCache.Shared.projitems b/src/Polly.Caching.Distributed.Shared/Polly.Caching.Distributed.Shared.projitems similarity index 92% rename from src/Polly.Caching.IDistributedCache.Shared/Polly.Caching.IDistributedCache.Shared.projitems rename to src/Polly.Caching.Distributed.Shared/Polly.Caching.Distributed.Shared.projitems index a41b3d8..add0aea 100644 --- a/src/Polly.Caching.IDistributedCache.Shared/Polly.Caching.IDistributedCache.Shared.projitems +++ b/src/Polly.Caching.Distributed.Shared/Polly.Caching.Distributed.Shared.projitems @@ -6,7 +6,7 @@ 23fa87f9-c77d-4c67-a0b0-2901de51b3ff - Polly.Caching.IDistributedCache + Polly.Caching.Distributed diff --git a/src/Polly.Caching.IDistributedCache.Shared/Polly.Caching.IDistributedCache.Shared.shproj b/src/Polly.Caching.Distributed.Shared/Polly.Caching.Distributed.Shared.shproj similarity index 92% rename from src/Polly.Caching.IDistributedCache.Shared/Polly.Caching.IDistributedCache.Shared.shproj rename to src/Polly.Caching.Distributed.Shared/Polly.Caching.Distributed.Shared.shproj index 8e78613..63ae828 100644 --- a/src/Polly.Caching.IDistributedCache.Shared/Polly.Caching.IDistributedCache.Shared.shproj +++ b/src/Polly.Caching.Distributed.Shared/Polly.Caching.Distributed.Shared.shproj @@ -8,6 +8,6 @@ - + diff --git a/src/Polly.Caching.IDistributedCache.Shared/TtlHelper.cs b/src/Polly.Caching.Distributed.Shared/TtlHelper.cs similarity index 91% rename from src/Polly.Caching.IDistributedCache.Shared/TtlHelper.cs rename to src/Polly.Caching.Distributed.Shared/TtlHelper.cs index 1f1b8e8..88e5cbe 100644 --- a/src/Polly.Caching.IDistributedCache.Shared/TtlHelper.cs +++ b/src/Polly.Caching.Distributed.Shared/TtlHelper.cs @@ -1,6 +1,6 @@ using Microsoft.Extensions.Caching.Distributed; -namespace Polly.Caching.IDistributedCache +namespace Polly.Caching.Distributed { internal static class InternalTtlHelper { diff --git a/src/Polly.Caching.IDistributedCache.Shared/TtlStrategyHelper.cs b/src/Polly.Caching.Distributed.Shared/TtlStrategyHelper.cs similarity index 97% rename from src/Polly.Caching.IDistributedCache.Shared/TtlStrategyHelper.cs rename to src/Polly.Caching.Distributed.Shared/TtlStrategyHelper.cs index 481bf70..382e43a 100644 --- a/src/Polly.Caching.IDistributedCache.Shared/TtlStrategyHelper.cs +++ b/src/Polly.Caching.Distributed.Shared/TtlStrategyHelper.cs @@ -1,7 +1,7 @@ using Microsoft.Extensions.Caching.Distributed; using System; -namespace Polly.Caching.IDistributedCache +namespace Polly.Caching.Distributed { /// /// Provides helper methods for creating a implementation from a . diff --git a/src/Polly.Caching.IDistributedCache.SharedSpecs/CacheProviderHelperTests.cs b/src/Polly.Caching.Distributed.SharedSpecs/CacheProviderHelperTests.cs similarity index 96% rename from src/Polly.Caching.IDistributedCache.SharedSpecs/CacheProviderHelperTests.cs rename to src/Polly.Caching.Distributed.SharedSpecs/CacheProviderHelperTests.cs index 86630ae..44850f8 100644 --- a/src/Polly.Caching.IDistributedCache.SharedSpecs/CacheProviderHelperTests.cs +++ b/src/Polly.Caching.Distributed.SharedSpecs/CacheProviderHelperTests.cs @@ -1,10 +1,10 @@ using System; using FluentAssertions; using Moq; -using Polly.Caching.IDistributedCache; +using Polly.Caching.Distributed; using Xunit; -namespace Polly.Specs.Caching.IDistributedCache +namespace Polly.Specs.Caching.Distributed { public class CacheProviderHelperTests { diff --git a/src/Polly.Caching.IDistributedCache.SharedSpecs/NetStandardIDistributedCacheByteArrayProviderSpecs.cs b/src/Polly.Caching.Distributed.SharedSpecs/NetStandardIDistributedCacheByteArrayProviderSpecs.cs similarity index 99% rename from src/Polly.Caching.IDistributedCache.SharedSpecs/NetStandardIDistributedCacheByteArrayProviderSpecs.cs rename to src/Polly.Caching.Distributed.SharedSpecs/NetStandardIDistributedCacheByteArrayProviderSpecs.cs index 201e137..789be93 100644 --- a/src/Polly.Caching.IDistributedCache.SharedSpecs/NetStandardIDistributedCacheByteArrayProviderSpecs.cs +++ b/src/Polly.Caching.Distributed.SharedSpecs/NetStandardIDistributedCacheByteArrayProviderSpecs.cs @@ -5,10 +5,10 @@ using Microsoft.Extensions.Caching.Distributed; using Moq; using Polly.Caching; -using Polly.Caching.IDistributedCache; +using Polly.Caching.Distributed; using Xunit; -namespace Polly.Specs.Caching.IDistributedCache +namespace Polly.Specs.Caching.Distributed { public class NetStandardIDistributedCacheByteArrayProviderSpecs { diff --git a/src/Polly.Caching.IDistributedCache.SharedSpecs/NetStandardIDistributedCacheStringProviderSpecs.cs b/src/Polly.Caching.Distributed.SharedSpecs/NetStandardIDistributedCacheStringProviderSpecs.cs similarity index 99% rename from src/Polly.Caching.IDistributedCache.SharedSpecs/NetStandardIDistributedCacheStringProviderSpecs.cs rename to src/Polly.Caching.Distributed.SharedSpecs/NetStandardIDistributedCacheStringProviderSpecs.cs index b910c8d..7a7005d 100644 --- a/src/Polly.Caching.IDistributedCache.SharedSpecs/NetStandardIDistributedCacheStringProviderSpecs.cs +++ b/src/Polly.Caching.Distributed.SharedSpecs/NetStandardIDistributedCacheStringProviderSpecs.cs @@ -5,7 +5,7 @@ using Microsoft.Extensions.Caching.Distributed; using Moq; using Polly.Caching; -using Polly.Caching.IDistributedCache; +using Polly.Caching.Distributed; using Xunit; namespace Polly.Specs.Caching.IDistributedCache diff --git a/src/Polly.Caching.IDistributedCache.SharedSpecs/Polly.Caching.IDistributedCache.SharedSpecs.projitems b/src/Polly.Caching.Distributed.SharedSpecs/Polly.Caching.Distributed.SharedSpecs.projitems similarity index 90% rename from src/Polly.Caching.IDistributedCache.SharedSpecs/Polly.Caching.IDistributedCache.SharedSpecs.projitems rename to src/Polly.Caching.Distributed.SharedSpecs/Polly.Caching.Distributed.SharedSpecs.projitems index 986798e..92fa99e 100644 --- a/src/Polly.Caching.IDistributedCache.SharedSpecs/Polly.Caching.IDistributedCache.SharedSpecs.projitems +++ b/src/Polly.Caching.Distributed.SharedSpecs/Polly.Caching.Distributed.SharedSpecs.projitems @@ -6,7 +6,7 @@ 8d537c37-a4a2-4be1-84bc-34f1afb51ca8 - Polly.Caching.IDistributedCache.Specs + Polly.Caching.Distributed.Specs diff --git a/src/Polly.Caching.IDistributedCache.SharedSpecs/Polly.Caching.IDistributedCache.SharedSpecs.shproj b/src/Polly.Caching.Distributed.SharedSpecs/Polly.Caching.Distributed.SharedSpecs.shproj similarity index 91% rename from src/Polly.Caching.IDistributedCache.SharedSpecs/Polly.Caching.IDistributedCache.SharedSpecs.shproj rename to src/Polly.Caching.Distributed.SharedSpecs/Polly.Caching.Distributed.SharedSpecs.shproj index 5196c0c..3933378 100644 --- a/src/Polly.Caching.IDistributedCache.SharedSpecs/Polly.Caching.IDistributedCache.SharedSpecs.shproj +++ b/src/Polly.Caching.Distributed.SharedSpecs/Polly.Caching.Distributed.SharedSpecs.shproj @@ -8,6 +8,6 @@ - + diff --git a/src/Polly.Caching.IDistributedCache.SharedSpecs/TtlStrategyHelperTests.cs b/src/Polly.Caching.Distributed.SharedSpecs/TtlStrategyHelperTests.cs similarity index 98% rename from src/Polly.Caching.IDistributedCache.SharedSpecs/TtlStrategyHelperTests.cs rename to src/Polly.Caching.Distributed.SharedSpecs/TtlStrategyHelperTests.cs index 9ee5b23..0b27a2e 100644 --- a/src/Polly.Caching.IDistributedCache.SharedSpecs/TtlStrategyHelperTests.cs +++ b/src/Polly.Caching.Distributed.SharedSpecs/TtlStrategyHelperTests.cs @@ -2,7 +2,7 @@ using FluentAssertions; using Moq; using Microsoft.Extensions.Caching.Distributed; -using Polly.Caching.IDistributedCache; +using Polly.Caching.Distributed; using Polly.Caching; using Xunit; diff --git a/src/Polly.Caching.IDistributedCache.nuspec b/src/Polly.Caching.Distributed.nuspec similarity index 100% rename from src/Polly.Caching.IDistributedCache.nuspec rename to src/Polly.Caching.Distributed.nuspec diff --git a/src/Polly.Caching.Distributed.sln b/src/Polly.Caching.Distributed.sln new file mode 100644 index 0000000..74d7a32 --- /dev/null +++ b/src/Polly.Caching.Distributed.sln @@ -0,0 +1,57 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.16 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{79FE9DBE-1155-4F78-A41F-FE95DEFA19DD}" + ProjectSection(SolutionItems) = preProject + GlobalAssemblyInfo.cs = GlobalAssemblyInfo.cs + Polly.nuspec = Polly.nuspec + EndProjectSection +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Polly.Caching.Distributed.Shared", "Polly.Caching.Distributed.Shared\Polly.Caching.Distributed.Shared.shproj", "{23FA87F9-C77D-4C67-A0B0-2901DE51B3FF}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Polly.Caching.Distributed.SharedSpecs", "Polly.Caching.Distributed.SharedSpecs\Polly.Caching.Distributed.SharedSpecs.shproj", "{8D537C37-A4A2-4BE1-84BC-34F1AFB51CA8}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Polly.Caching.Distributed.NetStandard11", "Polly.Caching.Distributed.NetStandard11\Polly.Caching.Distributed.NetStandard11.csproj", "{44926F85-3309-4D4E-BD6E-AAEF076B9D6A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Polly.Caching.Distributed.NetStandard11.Specs", "Polly.Caching.Distributed.NetStandard11.Specs\Polly.Caching.Distributed.NetStandard11.Specs.csproj", "{E5EB8F22-174A-4D2B-A0A1-4C2F82883F8E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Polly.Caching.Distributed.NetStandard20", "Polly.Caching.Distributed.NetStandard20\Polly.Caching.Distributed.NetStandard20.csproj", "{67FD1222-E88B-4472-A84C-66752020126E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Polly.Caching.Distributed.NetStandard20.Specs", "Polly.Caching.Distributed.NetStandard20.Specs\Polly.Caching.Distributed.NetStandard20.Specs.csproj", "{1A92408B-54BF-40C9-A2A0-3BC49B174A07}" +EndProject +Global + GlobalSection(SharedMSBuildProjectFiles) = preSolution + Polly.Caching.Distributed.Shared\Polly.Caching.Distributed.Shared.projitems*{23fa87f9-c77d-4c67-a0b0-2901de51b3ff}*SharedItemsImports = 13 + Polly.Caching.Distributed.SharedSpecs\Polly.Caching.Distributed.SharedSpecs.projitems*{8d537c37-a4a2-4be1-84bc-34f1afb51ca8}*SharedItemsImports = 13 + EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {44926F85-3309-4D4E-BD6E-AAEF076B9D6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {44926F85-3309-4D4E-BD6E-AAEF076B9D6A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {44926F85-3309-4D4E-BD6E-AAEF076B9D6A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {44926F85-3309-4D4E-BD6E-AAEF076B9D6A}.Release|Any CPU.Build.0 = Release|Any CPU + {E5EB8F22-174A-4D2B-A0A1-4C2F82883F8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E5EB8F22-174A-4D2B-A0A1-4C2F82883F8E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E5EB8F22-174A-4D2B-A0A1-4C2F82883F8E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E5EB8F22-174A-4D2B-A0A1-4C2F82883F8E}.Release|Any CPU.Build.0 = Release|Any CPU + {67FD1222-E88B-4472-A84C-66752020126E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {67FD1222-E88B-4472-A84C-66752020126E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {67FD1222-E88B-4472-A84C-66752020126E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {67FD1222-E88B-4472-A84C-66752020126E}.Release|Any CPU.Build.0 = Release|Any CPU + {1A92408B-54BF-40C9-A2A0-3BC49B174A07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1A92408B-54BF-40C9-A2A0-3BC49B174A07}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1A92408B-54BF-40C9-A2A0-3BC49B174A07}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1A92408B-54BF-40C9-A2A0-3BC49B174A07}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B79F0C1F-1732-4033-8D25-C26DAD98B10D} + EndGlobalSection +EndGlobal diff --git a/src/Polly.Caching.IDistributedCache.sln b/src/Polly.Caching.IDistributedCache.sln deleted file mode 100644 index 34b38a1..0000000 --- a/src/Polly.Caching.IDistributedCache.sln +++ /dev/null @@ -1,59 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26430.16 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{79FE9DBE-1155-4F78-A41F-FE95DEFA19DD}" - ProjectSection(SolutionItems) = preProject - GlobalAssemblyInfo.cs = GlobalAssemblyInfo.cs - Polly.nuspec = Polly.nuspec - EndProjectSection -EndProject -Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Polly.Caching.IDistributedCache.Shared", "Polly.Caching.IDistributedCache.Shared\Polly.Caching.IDistributedCache.Shared.shproj", "{23FA87F9-C77D-4C67-A0B0-2901DE51B3FF}" -EndProject -Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Polly.Caching.IDistributedCache.SharedSpecs", "Polly.Caching.IDistributedCache.SharedSpecs\Polly.Caching.IDistributedCache.SharedSpecs.shproj", "{8D537C37-A4A2-4BE1-84BC-34F1AFB51CA8}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Polly.Caching.IDistributedCache.NetStandard11.Specs", "Polly.Caching.IDistributedCache.NetStandard11.Specs\Polly.Caching.IDistributedCache.NetStandard11.Specs.csproj", "{4AB46D16-0806-4F51-8677-D849BA87CB05}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Polly.Caching.IDistributedCache.NetStandard11", "Polly.Caching.IDistributedCache.NetStandard11\Polly.Caching.IDistributedCache.NetStandard11.csproj", "{5017174E-DAC5-4408-AB15-1F902F40C612}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Polly.Caching.IDistributedCache.NetStandard20", "Polly.Caching.IDistributedCache.NetStandard20\Polly.Caching.IDistributedCache.NetStandard20.csproj", "{BEB48D73-7C49-49AD-A53E-EBE7897833D7}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Polly.Caching.IDistributedCache.NetStandard20.Specs", "Polly.Caching.IDistributedCache.NetStandard20.Specs\Polly.Caching.IDistributedCache.NetStandard20.Specs.csproj", "{2D38A483-3D6D-4B50-BE51-DBFFB960EF69}" -EndProject -Global - GlobalSection(SharedMSBuildProjectFiles) = preSolution - Polly.Caching.IDistributedCache.Shared\Polly.Caching.IDistributedCache.Shared.projitems*{23fa87f9-c77d-4c67-a0b0-2901de51b3ff}*SharedItemsImports = 13 - Polly.Caching.IDistributedCache.SharedSpecs\Polly.Caching.IDistributedCache.SharedSpecs.projitems*{4ab46d16-0806-4f51-8677-d849ba87cb05}*SharedItemsImports = 4 - Polly.Caching.IDistributedCache.Shared\Polly.Caching.IDistributedCache.Shared.projitems*{5017174e-dac5-4408-ab15-1f902f40c612}*SharedItemsImports = 4 - Polly.Caching.IDistributedCache.SharedSpecs\Polly.Caching.IDistributedCache.SharedSpecs.projitems*{8d537c37-a4a2-4be1-84bc-34f1afb51ca8}*SharedItemsImports = 13 - EndGlobalSection - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4AB46D16-0806-4F51-8677-D849BA87CB05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {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 - {5017174E-DAC5-4408-AB15-1F902F40C612}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5017174E-DAC5-4408-AB15-1F902F40C612}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5017174E-DAC5-4408-AB15-1F902F40C612}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5017174E-DAC5-4408-AB15-1F902F40C612}.Release|Any CPU.Build.0 = Release|Any CPU - {BEB48D73-7C49-49AD-A53E-EBE7897833D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BEB48D73-7C49-49AD-A53E-EBE7897833D7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BEB48D73-7C49-49AD-A53E-EBE7897833D7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BEB48D73-7C49-49AD-A53E-EBE7897833D7}.Release|Any CPU.Build.0 = Release|Any CPU - {2D38A483-3D6D-4B50-BE51-DBFFB960EF69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2D38A483-3D6D-4B50-BE51-DBFFB960EF69}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2D38A483-3D6D-4B50-BE51-DBFFB960EF69}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2D38A483-3D6D-4B50-BE51-DBFFB960EF69}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {B79F0C1F-1732-4033-8D25-C26DAD98B10D} - EndGlobalSection -EndGlobal From 7a2146f82d0f3be99bb08e54fb9c35fcd21988ee Mon Sep 17 00:00:00 2001 From: Sean Farrow Date: Tue, 22 May 2018 06:36:53 +0100 Subject: [PATCH 04/12] Update the Polly main package to V6.0.1. --- .../Polly.Caching.Distributed.NetStandard11.Specs.csproj | 2 +- .../Polly.Caching.Distributed.NetStandard11.csproj | 2 +- .../Polly.Caching.Distributed.NetStandard20.Specs.csproj | 2 +- .../Polly.Caching.Distributed.NetStandard20.csproj | 2 +- .../TtlStrategyHelperTests.cs | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Polly.Caching.Distributed.NetStandard11.Specs/Polly.Caching.Distributed.NetStandard11.Specs.csproj b/src/Polly.Caching.Distributed.NetStandard11.Specs/Polly.Caching.Distributed.NetStandard11.Specs.csproj index 921b49b..2eb0751 100644 --- a/src/Polly.Caching.Distributed.NetStandard11.Specs/Polly.Caching.Distributed.NetStandard11.Specs.csproj +++ b/src/Polly.Caching.Distributed.NetStandard11.Specs/Polly.Caching.Distributed.NetStandard11.Specs.csproj @@ -20,7 +20,7 @@ - + diff --git a/src/Polly.Caching.Distributed.NetStandard11/Polly.Caching.Distributed.NetStandard11.csproj b/src/Polly.Caching.Distributed.NetStandard11/Polly.Caching.Distributed.NetStandard11.csproj index 81b6fa4..3266207 100644 --- a/src/Polly.Caching.Distributed.NetStandard11/Polly.Caching.Distributed.NetStandard11.csproj +++ b/src/Polly.Caching.Distributed.NetStandard11/Polly.Caching.Distributed.NetStandard11.csproj @@ -31,7 +31,7 @@ - + \ No newline at end of file diff --git a/src/Polly.Caching.Distributed.NetStandard20.Specs/Polly.Caching.Distributed.NetStandard20.Specs.csproj b/src/Polly.Caching.Distributed.NetStandard20.Specs/Polly.Caching.Distributed.NetStandard20.Specs.csproj index e6f49fc..168bb1d 100644 --- a/src/Polly.Caching.Distributed.NetStandard20.Specs/Polly.Caching.Distributed.NetStandard20.Specs.csproj +++ b/src/Polly.Caching.Distributed.NetStandard20.Specs/Polly.Caching.Distributed.NetStandard20.Specs.csproj @@ -20,7 +20,7 @@ - + diff --git a/src/Polly.Caching.Distributed.NetStandard20/Polly.Caching.Distributed.NetStandard20.csproj b/src/Polly.Caching.Distributed.NetStandard20/Polly.Caching.Distributed.NetStandard20.csproj index 6072064..5d7f7e8 100644 --- a/src/Polly.Caching.Distributed.NetStandard20/Polly.Caching.Distributed.NetStandard20.csproj +++ b/src/Polly.Caching.Distributed.NetStandard20/Polly.Caching.Distributed.NetStandard20.csproj @@ -31,7 +31,7 @@ - + \ No newline at end of file diff --git a/src/Polly.Caching.Distributed.SharedSpecs/TtlStrategyHelperTests.cs b/src/Polly.Caching.Distributed.SharedSpecs/TtlStrategyHelperTests.cs index 0b27a2e..61a6303 100644 --- a/src/Polly.Caching.Distributed.SharedSpecs/TtlStrategyHelperTests.cs +++ b/src/Polly.Caching.Distributed.SharedSpecs/TtlStrategyHelperTests.cs @@ -23,7 +23,7 @@ public void Can_render_AbsoluteExpiration_as_ttlstrategy() ttlStrategy.Should().BeOfType(); - Ttl ttl = ttlStrategy.GetTtl(noContext); + Ttl ttl = ttlStrategy.GetTtl(noContext, null); ttl.SlidingExpiration.Should().BeFalse(); ttl.Timespan.Should().BeCloseTo(forwardTimeSpan, 10000); } @@ -38,7 +38,7 @@ public void Can_render_AbsoluteExpirationRelativeToNow_as_ttlstrategy() ttlStrategy.Should().BeOfType(); - Ttl ttl = ttlStrategy.GetTtl(noContext); + Ttl ttl = ttlStrategy.GetTtl(noContext, null); ttl.SlidingExpiration.Should().BeFalse(); ttl.Timespan.Should().BeCloseTo(forwardTimeSpan, 10000); } @@ -53,7 +53,7 @@ public void Can_render_SlidingExpiration_as_ttlstrategy() ttlStrategy.Should().BeOfType(); - Ttl ttl = ttlStrategy.GetTtl(noContext); + Ttl ttl = ttlStrategy.GetTtl(noContext, null); ttl.SlidingExpiration.Should().BeTrue(); ttl.Timespan.Should().BeCloseTo(forwardTimeSpan); } From 65fa16aa53786c43adeea6bfa3881e623e746560 Mon Sep 17 00:00:00 2001 From: Sean Farrow Date: Tue, 22 May 2018 06:52:40 +0100 Subject: [PATCH 05/12] Add a dependency group to support .net standard 2.0 to the NuSpec file. Also, update the release notes for v1.0.0. Finally, updatethe changelog.md file. --- CHANGELOG.md | 6 +++++- src/Polly.Caching.Distributed.nuspec | 17 ++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fafe24..7c2ff1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ -# Polly.Caching.IDistributedCache change log +# Polly.Caching.Distributed change log +## 1.0.0 + - Update Polly to V6.0.1. + - Update the namespaces to match the other cache providers + - Support .net Standard 2.0. ## 1.0-RC diff --git a/src/Polly.Caching.Distributed.nuspec b/src/Polly.Caching.Distributed.nuspec index 16474c8..a313d12 100644 --- a/src/Polly.Caching.Distributed.nuspec +++ b/src/Polly.Caching.Distributed.nuspec @@ -4,7 +4,7 @@ App vNext App vNext - Polly.Caching.IDistributedCache is a plug-in for the .NET OSS resilience library Polly, supporting Microsoft.Extensions.Caching.Distributed.IDistributedCache as a provider for Polly's CachePolicy. + Polly.Caching.Distributed is a plug-in for the .NET OSS resilience library Polly, supporting Microsoft.Extensions.Caching.Distributed.IDistributedCache as a provider for Polly's CachePolicy. en-US https://raw.github.com/App-vNext/Polly/master/LICENSE.txt @@ -13,6 +13,12 @@ Polly Cache Caching Cache-aside Copyright © 2017, App vNext + 1.0.0 + --------------------- + + - Update Polly to V6.0.1. + - Update the namespaces to match the other cache providers + - Support .net Standard 2.0. 1.0-RC --------------------- @@ -24,12 +30,17 @@ - + + + + + + - + \ No newline at end of file From c29753218b5b6b9edc3d479070a8fae86b01884e Mon Sep 17 00:00:00 2001 From: Sean Farrow Date: Tue, 22 May 2018 07:13:41 +0100 Subject: [PATCH 06/12] Update the cake build script. --- build.cake | 143 ++++++++++-------- .../Properties/AssemblyInfo.cs | 2 + .../Properties/AssemblyInfo.cs | 2 + 3 files changed, 82 insertions(+), 65 deletions(-) diff --git a/build.cake b/build.cake index f42504f..aa405bb 100644 --- a/build.cake +++ b/build.cake @@ -1,4 +1,4 @@ -/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// // ARGUMENTS /////////////////////////////////////////////////////////////////////////////// @@ -25,7 +25,7 @@ using System.Text.Json; // GLOBAL VARIABLES /////////////////////////////////////////////////////////////////////////////// -var projectName = "Polly.Caching.IDistributedCache"; +var projectName = "Polly.Caching.Distributed"; var keyName = "Polly.snk"; var solutions = GetFiles("./**/*.sln"); @@ -37,20 +37,28 @@ var artifactsDir = Directory("./artifacts"); var testResultsDir = artifactsDir + Directory("test-results"); // NuGet -var nuspecFilename = projectName + ".nuspec"; -var nuspecSrcFile = srcDir + File(nuspecFilename); -var nuspecDestFile = buildDir + File(nuspecFilename); -var nupkgDestDir = artifactsDir + Directory("nuget-package"); +var nuspecExtension = ".nuspec"; +var nuspecFolder = "nuget-package"; +var nuspecSrcFile = srcDir + File(projectName + nuspecExtension); +var nuspecDestFile = buildDir + File(projectName + nuspecExtension); +var nupkgDestDir = artifactsDir + Directory(nuspecFolder); var snkFile = srcDir + File(keyName); var projectToNugetFolderMap = new Dictionary() { { "NetStandard11", new [] {"netstandard1.1"} }, + { "NetStandard20", new [] {"netstandard2.0"} }, }; // Gitversion var gitVersionPath = ToolsExePath("GitVersion.exe"); Dictionary gitVersionOutput; +// Versioning +string nugetVersion; +string appveyorBuildNumber; +string assemblyVersion; +string assemblySemver; + // StrongNameSigner var strongNameSignerPath = ToolsExePath("StrongNameSigner.Console.exe"); @@ -62,12 +70,11 @@ var strongNameSignerPath = ToolsExePath("StrongNameSigner.Console.exe"); Setup(_ => { Information(""); - Information(" ██████╗ ██████╗ ██╗ ██╗ ██╗ ██╗"); - Information(" ██╔══██╗██╔═══██╗██║ ██║ ╚██╗ ██╔╝"); - Information(" ██████╔╝██║ ██║██║ ██║ ╚████╔╝ "); - Information(" ██╔═══╝ ██║ ██║██║ ██║ ╚██╔╝ "); - Information(" ██║ ╚██████╔╝███████╗███████╗██║ "); - Information(" ╚═╝ ╚═════╝ ╚══════╝╚══════╝╚═╝ "); + Information(@" ____ __ __ __ _ _ ____ _ _ ____ ____ __ _ ____ __ __ __ _ ____ _ _ ____ ____ ____ "); + Information(@"( _ \ / \ ( ) ( ) ( \/ ) ( __)( \/ )(_ _)( __)( ( \/ ___)( )/ \ ( ( \/ ___) / )( \(_ _)(_ _)( _ \"); + Information(@" ) __/( O )/ (_/\/ (_/\ ) /_ ) _) ) ( )( ) _) / /\___ \ )(( O )/ /\___ \ _ ) __ ( )( )( ) __/"); + Information(@"(__) \__/ \____/\____/(__/(_)(____)(_/\_) (__) (____)\_)__)(____/(__)\__/ \_)__)(____/(_)\_)(_/ (__) (__) (__) "); + Information(""); }); @@ -83,12 +90,16 @@ Teardown(_ => Task("__Clean") .Does(() => { - CleanDirectories(new DirectoryPath[] { + DirectoryPath[] cleanDirectories = new DirectoryPath[] { buildDir, - artifactsDir, testResultsDir, - nupkgDestDir - }); + nupkgDestDir, + artifactsDir + }; + + CleanDirectories(cleanDirectories); + + foreach(var path in cleanDirectories) { EnsureDirectoryExists(path); } foreach(var path in solutionPaths) { @@ -121,31 +132,62 @@ Task("__UpdateAssemblyVersionInformation") gitVersionOutput = new JsonParser().Parse>(output); Information("Updated GlobalAssemblyInfo"); - Information("AssemblyVersion -> {0}", gitVersionOutput["AssemblySemVer"]); - Information("AssemblyFileVersion -> {0}", gitVersionOutput["MajorMinorPatch"]); - Information("AssemblyInformationalVersion -> {0}", gitVersionOutput["InformationalVersion"]); + + Information(""); + Information("Obtained raw version info for package versioning:"); + Information("NuGetVersion -> {0}", gitVersionOutput["NuGetVersion"]); + Information("FullSemVer -> {0}", gitVersionOutput["FullSemVer"]); + Information("AssemblySemVer -> {0}", gitVersionOutput["AssemblySemVer"]); + + appveyorBuildNumber = gitVersionOutput["FullSemVer"].ToString(); + nugetVersion = gitVersionOutput["NuGetVersion"].ToString(); + assemblyVersion = gitVersionOutput["Major"].ToString() + ".0.0.0"; + assemblySemver = gitVersionOutput["AssemblySemVer"].ToString(); + + Information(""); + Information("Mapping versioning information to:"); + Information("Appveyor build number -> {0}", appveyorBuildNumber); + Information("Nuget package version -> {0}", nugetVersion); + Information("AssemblyVersion -> {0}", assemblyVersion); + Information("AssemblyFileVersion -> {0}", assemblySemver); + Information("AssemblyInformationalVersion -> {0}", assemblySemver); }); Task("__UpdateDotNetStandardAssemblyVersionNumber") .Does(() => { - // 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 NetStandard1.1 AssemblyVersion to {0}", assemblySemVer); - var replacedFiles = ReplaceRegexInFiles("./src/Polly.Caching.IDistributedCache.NetStandard11/Properties/AssemblyInfo.cs", "AssemblyVersion[(]\".*\"[)]", "AssemblyVersion(\"" + assemblySemVer +"\")"); - if (!replacedFiles.Any()) - { - Information("NetStandard1.1 AssemblyVersion could not be updated."); + Information("Updating Assembly Version Information"); + + var attributeToValueMap = new Dictionary() { + { "AssemblyVersion", assemblyVersion }, + { "AssemblyFileVersion", assemblySemver }, + { "AssemblyInformationalVersion", assemblySemver }, + }; + + var assemblyInfosToUpdate = GetFiles("./src/**/Properties/AssemblyInfo.cs") + .Select(f => f.FullPath) + .Where(f => !f.Contains("Specs")); + + foreach(var attributeMap in attributeToValueMap) { + var attribute = attributeMap.Key; + var value = attributeMap.Value; + + foreach(var assemblyInfo in assemblyInfosToUpdate) { + var replacedFiles = ReplaceRegexInFiles(assemblyInfo, attribute + "[(]\".*\"[)]", attribute + "(\"" + value +"\")"); + if (!replacedFiles.Any()) + { + throw new Exception($"{attribute} attribute could not be updated in {assemblyInfo}."); + } + } } + }); Task("__UpdateAppVeyorBuildNumber") .WithCriteria(() => AppVeyor.IsRunningOnAppVeyor) .Does(() => { - var fullSemVer = gitVersionOutput["FullSemVer"].ToString(); - AppVeyor.UpdateBuildVersion(fullSemVer); + AppVeyor.UpdateBuildVersion(appveyorBuildNumber); }); Task("__BuildSolutions") @@ -168,19 +210,12 @@ Task("__BuildSolutions") Task("__RunTests") .Does(() => { - XUnit2("./src/**/bin/" + configuration + "/**/*.Net4*.Specs.dll", new XUnit2Settings { - OutputDirectory = testResultsDir, - XmlReportV1 = true - }); -}); - -Task("__RunDotnetTests") - .Does(() => -{ - DotNetCoreTest("./src/Polly.Caching.IDistributedCache.NetStandard11.Specs/Polly.Caching.IDistributedCache.NetStandard11.Specs.csproj", new DotNetCoreTestSettings { - Configuration = configuration, - NoBuild = true - }); + foreach(var specsProj in GetFiles("./src/**/*.Specs.csproj")) { + DotNetCoreTest(specsProj.FullPath, new DotNetCoreTestSettings { + Configuration = configuration, + NoBuild = true + }); + } }); Task("__CopyOutputToNugetFolder") @@ -200,24 +235,6 @@ Task("__CopyOutputToNugetFolder") CopyFile(nuspecSrcFile, nuspecDestFile); }); -Task("__CreateNugetPackage") - .Does(() => -{ - var nugetVersion = gitVersionOutput["NuGetVersion"].ToString(); - var packageName = projectName; - - Information("Building {0}.{1}.nupkg", packageName, nugetVersion); - - var nuGetPackSettings = new NuGetPackSettings { - Id = packageName, - Title = packageName, - Version = nugetVersion, - OutputDirectory = nupkgDestDir - }; - - NuGetPack(nuspecDestFile, nuGetPackSettings); -}); - Task("__StronglySignAssemblies") .Does(() => { @@ -237,8 +254,7 @@ Task("__StronglySignAssemblies") Task("__CreateSignedNugetPackage") .Does(() => { - var nugetVersion = gitVersionOutput["NuGetVersion"].ToString(); - var packageName = projectName + "-Signed"; + var packageName = projectName; Information("Building {0}.{1}.nupkg", packageName, nugetVersion); @@ -252,7 +268,6 @@ Task("__CreateSignedNugetPackage") NuGetPack(nuspecDestFile, nuGetPackSettings); }); - ////////////////////////////////////////////////////////////////////// // BUILD TASKS ////////////////////////////////////////////////////////////////////// @@ -265,9 +280,7 @@ Task("Build") .IsDependentOn("__UpdateAppVeyorBuildNumber") .IsDependentOn("__BuildSolutions") .IsDependentOn("__RunTests") - .IsDependentOn("__RunDotnetTests") .IsDependentOn("__CopyOutputToNugetFolder") - .IsDependentOn("__CreateNugetPackage") .IsDependentOn("__StronglySignAssemblies") .IsDependentOn("__CreateSignedNugetPackage"); diff --git a/src/Polly.Caching.Distributed.NetStandard11/Properties/AssemblyInfo.cs b/src/Polly.Caching.Distributed.NetStandard11/Properties/AssemblyInfo.cs index c2736d2..e9d8433 100644 --- a/src/Polly.Caching.Distributed.NetStandard11/Properties/AssemblyInfo.cs +++ b/src/Polly.Caching.Distributed.NetStandard11/Properties/AssemblyInfo.cs @@ -4,6 +4,8 @@ [assembly: AssemblyTitle("Polly.Caching.Distributed")] [assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.5.0")] +[assembly: AssemblyInformationalVersion("1.0.5.0")] [assembly: CLSCompliant(false)] // Because Microsoft.Extensions.Caching.Memory.IDistributedCache, on which Polly.Caching.IDistributedCache.NetStandard11 depends, is not CLSCompliant. [assembly: InternalsVisibleTo("Polly.Caching.Distributed.NetStandard11.Specs")] \ No newline at end of file diff --git a/src/Polly.Caching.Distributed.NetStandard20/Properties/AssemblyInfo.cs b/src/Polly.Caching.Distributed.NetStandard20/Properties/AssemblyInfo.cs index 2847bed..02a940c 100644 --- a/src/Polly.Caching.Distributed.NetStandard20/Properties/AssemblyInfo.cs +++ b/src/Polly.Caching.Distributed.NetStandard20/Properties/AssemblyInfo.cs @@ -4,6 +4,8 @@ [assembly: AssemblyTitle("Polly.Caching.Distributed")] [assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.5.0")] +[assembly: AssemblyInformationalVersion("1.0.5.0")] [assembly: CLSCompliant(false)] // Because Microsoft.Extensions.Caching.Memory.IDistributedCache, on which Polly.Caching.IDistributedCache.NetStandard11 depends, is not CLSCompliant. [assembly: InternalsVisibleTo("Polly.Caching.Distributed.NetStandard20.Specs")] \ No newline at end of file From 177cb0795b9b6f65622a1c6d48cdd24b0d7239e1 Mon Sep 17 00:00:00 2001 From: Sean Farrow Date: Tue, 22 May 2018 07:21:17 +0100 Subject: [PATCH 07/12] Update the dependency group for .net standard 2.0 to use the abstractions caching package rather than memory. --- src/Polly.Caching.Distributed.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Polly.Caching.Distributed.nuspec b/src/Polly.Caching.Distributed.nuspec index a313d12..0de2f83 100644 --- a/src/Polly.Caching.Distributed.nuspec +++ b/src/Polly.Caching.Distributed.nuspec @@ -36,7 +36,7 @@ - + From 8d15b574133a7c03c0ed5a1c7987c194d5a035a9 Mon Sep 17 00:00:00 2001 From: reisenberger Date: Tue, 29 May 2018 12:30:13 +0100 Subject: [PATCH 08/12] Fix ASCII art in build script --- build.cake | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/build.cake b/build.cake index aa405bb..2d135b5 100644 --- a/build.cake +++ b/build.cake @@ -69,12 +69,14 @@ var strongNameSignerPath = ToolsExePath("StrongNameSigner.Console.exe"); Setup(_ => { + // ASCII art via: http://patorjk.com/software/taag/?#p=display&f=Graceful&t=Polly.Caching.Distributed%0A Information(""); - Information(@" ____ __ __ __ _ _ ____ _ _ ____ ____ __ _ ____ __ __ __ _ ____ _ _ ____ ____ ____ "); - Information(@"( _ \ / \ ( ) ( ) ( \/ ) ( __)( \/ )(_ _)( __)( ( \/ ___)( )/ \ ( ( \/ ___) / )( \(_ _)(_ _)( _ \"); - Information(@" ) __/( O )/ (_/\/ (_/\ ) /_ ) _) ) ( )( ) _) / /\___ \ )(( O )/ /\___ \ _ ) __ ( )( )( ) __/"); - Information(@"(__) \__/ \____/\____/(__/(_)(____)(_/\_) (__) (____)\_)__)(____/(__)\__/ \_)__)(____/(_)\_)(_/ (__) (__) (__) "); - + Information(@""); + Information(@" ____ __ __ __ _ _ ___ __ ___ _ _ __ __ _ ___ ____ __ ____ ____ ____ __ ____ _ _ ____ ____ ____ "); + Information(@"( _ \ / \ ( ) ( ) ( \/ ) / __) / _\ / __)/ )( \( )( ( \ / __) ( \( )/ ___)(_ _)( _ \( )( _ \/ )( \(_ _)( __)( \"); + Information(@" ) __/( O )/ (_/\/ (_/\ ) /_( (__ / \( (__ ) __ ( )( / /( (_ \ _ ) D ( )( \___ \ )( ) / )( ) _ () \/ ( )( ) _) ) D ("); + Information(@"(__) \__/ \____/\____/(__/(_)\___)\_/\_/ \___)\_)(_/(__)\_)__) \___/(_)(____/(__)(____/ (__) (__\_)(__)(____/\____/ (__) (____)(____/"); + Information(@" ____ __ __ __ _ _ ___ __ ___ _ _ __ __ _ ___ __ ____ __ ____ ____ ____ __ ____ _ _ ____ ____ ____ ___ __ ___ _ _ ____ "); Information(""); }); From d1ba9908b49fb5269d4715a7efce569a86862912 Mon Sep 17 00:00:00 2001 From: reisenberger Date: Tue, 29 May 2018 12:38:51 +0100 Subject: [PATCH 09/12] Fix ASCII art in readme --- build.cake | 1 - 1 file changed, 1 deletion(-) diff --git a/build.cake b/build.cake index 2d135b5..14a47ed 100644 --- a/build.cake +++ b/build.cake @@ -76,7 +76,6 @@ Setup(_ => Information(@"( _ \ / \ ( ) ( ) ( \/ ) / __) / _\ / __)/ )( \( )( ( \ / __) ( \( )/ ___)(_ _)( _ \( )( _ \/ )( \(_ _)( __)( \"); Information(@" ) __/( O )/ (_/\/ (_/\ ) /_( (__ / \( (__ ) __ ( )( / /( (_ \ _ ) D ( )( \___ \ )( ) / )( ) _ () \/ ( )( ) _) ) D ("); Information(@"(__) \__/ \____/\____/(__/(_)\___)\_/\_/ \___)\_)(_/(__)\_)__) \___/(_)(____/(__)(____/ (__) (__\_)(__)(____/\____/ (__) (____)(____/"); - Information(@" ____ __ __ __ _ _ ___ __ ___ _ _ __ __ _ ___ __ ____ __ ____ ____ ____ __ ____ _ _ ____ ____ ____ ___ __ ___ _ _ ____ "); Information(""); }); From 1648086cbb5f15012ae857e2d3cfd1ec9a321cd4 Mon Sep 17 00:00:00 2001 From: reisenberger Date: Tue, 29 May 2018 12:52:02 +0100 Subject: [PATCH 10/12] Fix readme for v2.0 Update for new package name. Add DI configuration example. Add credit. --- README.md | 90 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 66 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 5df6a9a..575bbb6 100644 --- a/README.md +++ b/README.md @@ -1,74 +1,115 @@ -# Polly.Caching.IDistributedCache +# Polly.Caching.Distributed -This repo contains the `Microsoft.Extensions.Caching.Distributed.IDistributedCache` plugin for the [Polly](https://github.com/App-vNext/Polly) [Cache policy](https://github.com/App-vNext/Polly/wiki/Cache). It targets .NET Standard 1.1. +This repo contains the `Microsoft.Extensions.Caching.Distributed.IDistributedCache` provider for the [Polly](https://github.com/App-vNext/Polly) [Cache policy](https://github.com/App-vNext/Polly/wiki/Cache). The current version targets .NET Standard 1.1 and .NET Standard 2.0. -[![NuGet version](https://badge.fury.io/nu/Polly.Caching.IDistributedCache.svg)](https://badge.fury.io/nu/Polly.Caching.IDistributedCache) [![Build status](https://ci.appveyor.com/api/projects/status/pgd89nfdr9u4ig8m?svg=true)](https://ci.appveyor.com/project/joelhulen/polly-caching-IDistributedCache) [![Slack Status](http://www.pollytalk.org/badge.svg)](http://www.pollytalk.org) +[![NuGet version](https://badge.fury.io/nu/Polly.Caching.Distributed.svg)](https://badge.fury.io/nu/Polly.Caching.Distributed) [![Build status](https://ci.appveyor.com/api/projects/status/pgd89nfdr9u4ig8m?svg=true)](https://ci.appveyor.com/project/joelhulen/polly-caching-Distributed) [![Slack Status](http://www.pollytalk.org/badge.svg)](http://www.pollytalk.org) ## What is Polly? -[Polly](https://github.com/App-vNext/Polly) is a .NET resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, Cache aside and Fallback in a fluent and thread-safe manner. Polly targets .NET 4.0, .NET 4.5 and .NET Standard 1.1. +[Polly](https://github.com/App-vNext/Polly) is a .NET resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, Cache aside and Fallback in a fluent and thread-safe manner. Polly targets .NET Standard 1.1 and .NET Standard 2.0. -Polly is a member of the [.NET Foundation](https://www.dotnetfoundation.org/about)! +Polly is a member of the [.NET Foundation](https://www.dotnetfoundation.org/about). **Keep up to date with new feature announcements, tips & tricks, and other news through [www.thepollyproject.org](http://www.thepollyproject.org)** ![](https://raw.github.com/App-vNext/Polly/master/Polly-Logo.png) -## What is Polly.Caching.IDistributedCache? +## What is Polly.Caching.Distributed? -This project, Polly.Caching.IDistributedCache, allows you to use Polly's `CachePolicy` with [implementations of](https://docs.microsoft.com/en-us/aspnet/core/performance/caching/distributed) .Net Standard's [`IDistributedCache`](https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.caching.distributed.idistributedcache). +This project, Polly.Caching.Distributed, allows you to use Polly's `CachePolicy` with [implementations of](https://docs.microsoft.com/en-us/aspnet/core/performance/caching/distributed) .Net Standard's [`IDistributedCache`](https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.caching.distributed.idistributedcache). -# Installing Polly.Caching.IDistributedCache via NuGet +# Installing Polly.Caching.Distributed via NuGet - Install-Package Polly.Caching.IDistributedCache - -You can install the Strongly Named version via: - - Install-Package Polly.Caching.IDistributedCache-Signed + Install-Package Polly.Caching.Distributed # Supported targets -Polly.Caching.IDistributedCache supports .NetStandard 1.1 and above. +Polly.Caching.Distributed supports .NET Standard 1.1 and .NET Standard 2.0. ## Dependencies -Polly.Caching.IDistributedCache requires: +Polly.Caching.IDistributedCache <v2.0 requires: + [Polly](nuget.org/packages/polly) v5.4.0 or above. + [Microsoft.Extensions.Caching.Abstractions](https://www.nuget.org/packages/Microsoft.Extensions.Caching.Abstractions/) v1.1.2 or above. -# How to use the Polly.Caching.IDistributedCache plugin +Polly.Caching.Distributed >=v2.0 requires: + ++ [Polly](nuget.org/packages/polly) v6.0.1 or above. ++ [Microsoft.Extensions.Caching.Abstractions](https://www.nuget.org/packages/Microsoft.Extensions.Caching.Abstractions/) v2.0.2 or above. + +# How to use the Polly.Caching.Distributed plugin These notes assume you are familiar with using the .Net Standard `IDistributedCache` implementations. For information, see: https://docs.microsoft.com/en-us/aspnet/core/performance/caching/distributed . As described on that page, Microsoft provide a Redis implementation and an SQL server implementation for `IDistributedCache`. Assuming you have an instance `IDistributedCache distributedCache` in hand (perhaps just configured and instantiated, perhaps provided to local code by Dependency Injection): + ```csharp -// Create a Polly cache policy for caching string results, using that `IDistributedCache` instance. -var cachePolicy = Policy.Cache(distributedCache.AsSyncCacheProvider, TimeSpan.FromMinutes(5)); +// Create a Polly cache policy for caching string results, using that IDistributedCache instance. +var cachePolicy = Policy.Cache(distributedCache.AsSyncCacheProvider(), TimeSpan.FromMinutes(5)); -// Create a Polly cache policy for caching byte[] results, using that `IDistributedCache` instance. -var cachePolicy = Policy.Cache(distributedCache.AsSyncCacheProvider, TimeSpan.FromMinutes(5)); +// Create a Polly cache policy for caching byte[] results, using that IDistributedCache instance. +var cachePolicy = Policy.Cache(distributedCache.AsSyncCacheProvider(), TimeSpan.FromMinutes(5)); // Or similarly for async executions returning string results: -var cachePolicy = Policy.CacheAsync(distributedCache.AsAsyncCacheProvider, TimeSpan.FromMinutes(5)); +var cachePolicy = Policy.CacheAsync(distributedCache.AsAsyncCacheProvider(), TimeSpan.FromMinutes(5)); // Or similarly for async executions returning byte[] results: -var cachePolicy = Policy.CacheAsync(distributedCache.AsAsyncCacheProvider, TimeSpan.FromMinutes(5)); +var cachePolicy = Policy.CacheAsync(distributedCache.AsAsyncCacheProvider(), TimeSpan.FromMinutes(5)); // You can also use ASP.NET Core's DistributedCacheEntryOptions for specifying cache item time-to-live, as shown below. // All time-to-live functionality represented by DistributedCacheEntryOptions is supported. DistributedCacheEntryOptions entryOptions = // ... -var cachePolicy = Policy.CacheAsync(distributedCache.AsAsyncCacheProvider, entryOptions.AsTtlStrategy()); +var cachePolicy = Policy.CacheAsync(distributedCache.AsAsyncCacheProvider(), entryOptions.AsTtlStrategy()); ``` +Configuration via DI in ASPNET Core: + +```csharp +// In this example we choose to pass a whole PolicyRegistry by dependency injection rather than the individual policy, on the assumption the webapp will probably use multiple policies across the app. + +// For example: +public class Startup +{ + public void ConfigureServices(IServiceCollection services) + { + services.AddDistributedRedisCache(options => + { + options.Configuration = "localhost"; // or whatever + options.InstanceName = "SampleInstance"; + }); + + services.AddSingleton>(serviceProvider => serviceProvider.GetRequiredService().AsAsyncCacheProvider()); + + services.AddSingleton, Polly.Registry.PolicyRegistry>((serviceProvider) => + { + PolicyRegistry registry = new PolicyRegistry(); + registry.Add("myCachePolicy", Policy.CacheAsync(serviceProvider.GetRequiredService>(), TimeSpan.FromMinutes(5))); + + return registry; + }); + + // ... + } +} + +// In a controller, inject the policyRegistry and retrieve the policy: +// (magic string "myCachePolicy" hard-coded here only to keep the example simple) +public MyController(IPolicyRegistry policyRegistry) +{ + var _cachePolicy = policyRegistry.Get>("myCachePolicy"); + // ... +} +``` + Usage: ```csharp string productId = // ... from somewhere -string productDescription = await cachePolicy.ExecuteAsync(() => getProductDescription(productId), +string productDetails = await cachePolicy.ExecuteAsync(() => getProductDetails(productId), new Context(productId) // productId will also be the cache key used in this execution. ); ``` @@ -86,6 +127,7 @@ For details of changes by release see the [change log](CHANGELOG.md). * [@seanfarrow](https://github.com/seanfarrow) and [@reisenberger](https://github.com/reisenberger) - Initial caching architecture in the main Polly repo * [@reisenberger](https://github.com/reisenberger) - `IDistributedCache` implementation +* [@seanfarrow](https://github.com/seanfarrow) - v2.0 update to Signed packages only to correspond with Polly v6.0.1 # Instructions for Contributing From e57e4b4215416c787e886da73296698b092aa4d3 Mon Sep 17 00:00:00 2001 From: reisenberger Date: Tue, 29 May 2018 12:52:14 +0100 Subject: [PATCH 11/12] Update changelog --- CHANGELOG.md | 10 ++++++---- src/Polly.Caching.Distributed.nuspec | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c2ff1b..f0c9fb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,10 @@ # Polly.Caching.Distributed change log -## 1.0.0 - - Update Polly to V6.0.1. - - Update the namespaces to match the other cache providers - - Support .net Standard 2.0. + +## 2.0.0 +- Provide a single signed package only. +- Update Polly to V6.0.1. +- Support .net Standard 2.0. +- Rename package, and change namespaces, from Polly.Caching.IDistributedCache to Polly.Caching.Distributed, to avoid clashes. ## 1.0-RC diff --git a/src/Polly.Caching.Distributed.nuspec b/src/Polly.Caching.Distributed.nuspec index 0de2f83..149790b 100644 --- a/src/Polly.Caching.Distributed.nuspec +++ b/src/Polly.Caching.Distributed.nuspec @@ -13,12 +13,12 @@ Polly Cache Caching Cache-aside Copyright © 2017, App vNext - 1.0.0 + 2.0.0 --------------------- - + - Provide a single signed package only. - Update Polly to V6.0.1. - - Update the namespaces to match the other cache providers - Support .net Standard 2.0. + - Rename package, and change namespaces, from Polly.Caching.IDistributedCache to Polly.Caching.Distributed, to avoid clashes. 1.0-RC --------------------- From 964f71865603037e752a673429e414dc4007ebf3 Mon Sep 17 00:00:00 2001 From: reisenberger Date: Tue, 29 May 2018 12:52:42 +0100 Subject: [PATCH 12/12] Bump version to v2.0.0 --- GitVersionConfig.yaml | 2 +- .../Properties/AssemblyInfo.cs | 6 +++--- .../Properties/AssemblyInfo.cs | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/GitVersionConfig.yaml b/GitVersionConfig.yaml index 4c817b9..49572ad 100644 --- a/GitVersionConfig.yaml +++ b/GitVersionConfig.yaml @@ -1 +1 @@ -next-version: 1.0.0 +next-version: 2.0.0 diff --git a/src/Polly.Caching.Distributed.NetStandard11/Properties/AssemblyInfo.cs b/src/Polly.Caching.Distributed.NetStandard11/Properties/AssemblyInfo.cs index e9d8433..49f7a37 100644 --- a/src/Polly.Caching.Distributed.NetStandard11/Properties/AssemblyInfo.cs +++ b/src/Polly.Caching.Distributed.NetStandard11/Properties/AssemblyInfo.cs @@ -3,9 +3,9 @@ using System.Runtime.CompilerServices; [assembly: AssemblyTitle("Polly.Caching.Distributed")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.5.0")] -[assembly: AssemblyInformationalVersion("1.0.5.0")] +[assembly: AssemblyVersion("2.0.0.0")] +[assembly: AssemblyFileVersion("2.0.0.0")] +[assembly: AssemblyInformationalVersion("2.0.0.0")] [assembly: CLSCompliant(false)] // Because Microsoft.Extensions.Caching.Memory.IDistributedCache, on which Polly.Caching.IDistributedCache.NetStandard11 depends, is not CLSCompliant. [assembly: InternalsVisibleTo("Polly.Caching.Distributed.NetStandard11.Specs")] \ No newline at end of file diff --git a/src/Polly.Caching.Distributed.NetStandard20/Properties/AssemblyInfo.cs b/src/Polly.Caching.Distributed.NetStandard20/Properties/AssemblyInfo.cs index 02a940c..9e8a3da 100644 --- a/src/Polly.Caching.Distributed.NetStandard20/Properties/AssemblyInfo.cs +++ b/src/Polly.Caching.Distributed.NetStandard20/Properties/AssemblyInfo.cs @@ -3,9 +3,9 @@ using System.Runtime.CompilerServices; [assembly: AssemblyTitle("Polly.Caching.Distributed")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.5.0")] -[assembly: AssemblyInformationalVersion("1.0.5.0")] +[assembly: AssemblyVersion("2.0.0.0")] +[assembly: AssemblyFileVersion("2.0.0.0")] +[assembly: AssemblyInformationalVersion("2.0.0.0")] [assembly: CLSCompliant(false)] // Because Microsoft.Extensions.Caching.Memory.IDistributedCache, on which Polly.Caching.IDistributedCache.NetStandard11 depends, is not CLSCompliant. [assembly: InternalsVisibleTo("Polly.Caching.Distributed.NetStandard20.Specs")] \ No newline at end of file