diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b4f3eb..764e07e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Polly.Caching.Distributed change log +## 3.0.1 +- No functional changes +- Updated Polly dependency to latest, v7.1.1 +- Consolidated solution and fixed build +- Add SourceLink support +- Added NetStandard 2.1 target (for .NET Core3.0 consumption) +- Added test runs in netcoreapp3.0; .NET Framework 4.6.1; and .NET Framework 4.7.2 +- Updated FluentAssertions and xUnit dependencies + ## 3.0.0 - Allow caching of `default(TResult)` - Compatible with Polly >= v7 diff --git a/GitVersionConfig.yaml b/GitVersionConfig.yaml index aade6b1..9d2597a 100644 --- a/GitVersionConfig.yaml +++ b/GitVersionConfig.yaml @@ -1 +1 @@ -next-version: 3.0.0 \ No newline at end of file +next-version: 3.0.1 \ No newline at end of file diff --git a/README.md b/README.md index 9625d2c..cddf4f7 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Polly.Caching.Distributed -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. +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, .NET Standard 2.0 and .NET Standard 2.1. [![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 Standard 1.1 and .NET Standard 2.0. +[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 is a member of the [.NET Foundation](https://www.dotnetfoundation.org/about). @@ -24,24 +24,27 @@ This project, Polly.Caching.Distributed, allows you to use Polly's `CachePolicy` # Supported targets -Polly.Caching.Distributed supports .NET Standard 1.1 and .NET Standard 2.0. +Polly.Caching.Distributed >= v3.0.1 supports .NET Standard 1.1, .NET Standard 2.0 and .NET Standard 2.1. -## Versions and Dependencies +Polly.Caching.Distributed < v3.0.1 supports .NET Standard 1.1 and .NET Standard 2.0. -Polly.Caching.Distributed >=v3.0 requires: +## Dependency compatibility with Polly + +Polly.Caching.Distributed >=v3.0.1 requires: + ++ [Polly](https://nuget.org/packages/polly) >= v7.1.1. + +Polly.Caching.Distributed v3.0.0 requires: + [Polly](https://nuget.org/packages/polly) >= v7.0.0. -+ [Microsoft.Extensions.Caching.Abstractions](https://www.nuget.org/packages/Microsoft.Extensions.Caching.Abstractions/) v2.0.2 or above. Polly.Caching.Distributed >=v2.0 and <v3 requires: + [Polly](https://nuget.org/packages/polly) >= v6.0.1 and <v7. -+ [Microsoft.Extensions.Caching.Abstractions](https://www.nuget.org/packages/Microsoft.Extensions.Caching.Abstractions/) v2.0.2 or above. Polly.Caching.IDistributedCache <v2.0 requires: + [Polly](https://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.Distributed plugin diff --git a/appveyor.yml b/appveyor.yml index 3dd6b59..d7996cc 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -os: Visual Studio 2017 +image: Visual Studio 2019 # Build script build_script: @@ -9,6 +9,7 @@ test: off artifacts: - path: artifacts\nuget-package\*.nupkg + - path: artifacts\nuget-package\*.snupkg environment: # Skip dotnet package caching on build servers diff --git a/build.cake b/build.cake index 6e3259f..5be7e10 100644 --- a/build.cake +++ b/build.cake @@ -11,45 +11,35 @@ var configuration = Argument("configuration", "Release"); #Tool "xunit.runner.console" #Tool "GitVersion.CommandLine" -#Tool "Brutal.Dev.StrongNameSigner" ////////////////////////////////////////////////////////////////////// // EXTERNAL NUGET LIBRARIES ////////////////////////////////////////////////////////////////////// #addin "Cake.FileHelpers" +#addin nuget:?package=Cake.Yaml +#addin nuget:?package=YamlDotNet&version=5.2.1 /////////////////////////////////////////////////////////////////////////////// // GLOBAL VARIABLES /////////////////////////////////////////////////////////////////////////////// var projectName = "Polly.Caching.Distributed"; -var keyName = "Polly.snk"; var solutions = GetFiles("./**/*.sln"); var solutionPaths = solutions.Select(solution => solution.GetDirectory()); var srcDir = Directory("./src"); -var buildDir = Directory("./build"); var artifactsDir = Directory("./artifacts"); var testResultsDir = artifactsDir + Directory("test-results"); // NuGet -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"} }, -}; +var nupkgDestDir = artifactsDir + Directory("nuget-package"); // Gitversion var gitVersionPath = ToolsExePath("GitVersion.exe"); Dictionary gitVersionOutput; +var gitVersionConfigFilePath = "./GitVersionConfig.yaml"; // Versioning string nugetVersion; @@ -57,9 +47,13 @@ string appveyorBuildNumber; string assemblyVersion; string assemblySemver; -// StrongNameSigner -var strongNameSignerPath = ToolsExePath("StrongNameSigner.Console.exe"); - +/////////////////////////////////////////////////////////////////////////////// +// INNER CLASSES +/////////////////////////////////////////////////////////////////////////////// +class GitVersionConfigYaml +{ + public string NextVersion { get; set; } +} /////////////////////////////////////////////////////////////////////////////// // SETUP / TEARDOWN @@ -67,13 +61,11 @@ 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(@"( _ \ / \ ( ) ( ) ( \/ ) / __) / _\ / __)/ )( \( )( ( \ / __) ( \( )/ ___)(_ _)( _ \( )( _ \/ )( \(_ _)( __)( \"); - Information(@" ) __/( O )/ (_/\/ (_/\ ) /_( (__ / \( (__ ) __ ( )( / /( (_ \ _ ) D ( )( \___ \ )( ) / )( ) _ () \/ ( )( ) _) ) D ("); - Information(@"(__) \__/ \____/\____/(__/(_)\___)\_/\_/ \___)\_)(_/(__)\_)__) \___/(_)(____/(__)(____/ (__) (__\_)(__)(____/\____/ (__) (____)(____/"); + Information("----------------------------------------"); + Information("Starting the cake build script"); + Information("Building: " + projectName); + Information("----------------------------------------"); Information(""); }); @@ -90,7 +82,6 @@ Task("__Clean") .Does(() => { DirectoryPath[] cleanDirectories = new DirectoryPath[] { - buildDir, testResultsDir, nupkgDestDir, artifactsDir @@ -103,8 +94,7 @@ Task("__Clean") foreach(var path in solutionPaths) { Information("Cleaning {0}", path); - CleanDirectories(path + "/**/bin/" + configuration); - CleanDirectories(path + "/**/obj/" + configuration); + DotNetCoreClean(path.ToString()); } }); @@ -114,7 +104,7 @@ Task("__RestoreNugetPackages") foreach(var solution in solutions) { Information("Restoring NuGet Packages for {0}", solution); - NuGetRestore(solution); + DotNetCoreRestore(solution.ToString()); } }); @@ -124,13 +114,29 @@ Task("__UpdateAssemblyVersionInformation") var gitVersionSettings = new ProcessSettings() .SetRedirectStandardOutput(true); - IEnumerable outputLines; - StartProcess(gitVersionPath, gitVersionSettings, out outputLines); + try { + IEnumerable outputLines; + StartProcess(gitVersionPath, gitVersionSettings, out outputLines); + + var output = string.Join("\n", outputLines); + gitVersionOutput = Newtonsoft.Json.JsonConvert.DeserializeObject>(output); + } + catch + { + Information("Error reading git version information. Build may be running outside of a git repo. Falling back to version specified in " + gitVersionConfigFilePath); + + string gitVersionYamlString = System.IO.File.ReadAllText(gitVersionConfigFilePath); + GitVersionConfigYaml deserialized = DeserializeYaml(gitVersionYamlString.Replace("next-version", "NextVersion")); + string gitVersionConfig = deserialized.NextVersion; - var output = string.Join("\n", outputLines); - gitVersionOutput = Newtonsoft.Json.JsonConvert.DeserializeObject>(output); + gitVersionOutput = new Dictionary{ + { "NuGetVersion", gitVersionConfig + "-NotFromGitRepo" }, + { "FullSemVer", gitVersionConfig }, + { "AssemblySemVer", gitVersionConfig }, + { "Major", gitVersionConfig.Split('.')[0] }, + }; - Information("Updated GlobalAssemblyInfo"); + } Information(""); Information("Obtained raw version info for package versioning:"); @@ -159,24 +165,22 @@ Task("__UpdateDotNetStandardAssemblyVersionNumber") var attributeToValueMap = new Dictionary() { { "AssemblyVersion", assemblyVersion }, - { "AssemblyFileVersion", assemblySemver }, - { "AssemblyInformationalVersion", assemblySemver }, + { "FileVersion", assemblySemver }, + { "InformationalVersion", assemblySemver }, + { "Version", nugetVersion }, + { "PackageVersion", nugetVersion }, }; - var assemblyInfosToUpdate = GetFiles("./src/**/Properties/AssemblyInfo.cs") - .Select(f => f.FullPath) - .Where(f => !f.Contains("Specs")); + var csproj = File("./src/" + projectName + "/" + projectName + ".csproj"); 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}."); - } + var replacedFiles = ReplaceRegexInFiles(csproj, $@"\<{attribute}\>[^\<]*\", $@"<{attribute}>{value}"); + if (!replacedFiles.Any()) + { + throw new Exception($"{attribute} version could not be updated in {csproj}."); } } @@ -196,13 +200,14 @@ Task("__BuildSolutions") { Information("Building {0}", solution); - MSBuild(solution, settings => - settings - .SetConfiguration(configuration) - .WithProperty("TreatWarningsAsErrors", "true") - .UseToolVersion(MSBuildToolVersion.VS2017) - .SetVerbosity(Verbosity.Minimal) - .SetNodeReuse(false)); + var dotNetCoreBuildSettings = new DotNetCoreBuildSettings { + Configuration = configuration, + Verbosity = DotNetCoreVerbosity.Minimal, + NoRestore = true, + MSBuildSettings = new DotNetCoreMSBuildSettings { TreatAllWarningsAs = MSBuildTreatAllWarningsAs.Error } + }; + + DotNetCoreBuild(solution.ToString(), dotNetCoreBuildSettings); } }); @@ -217,39 +222,6 @@ Task("__RunTests") } }); -Task("__CopyOutputToNugetFolder") - .Does(() => -{ - foreach(var project in projectToNugetFolderMap.Keys) { - var sourceDir = srcDir + Directory(projectName + "." + project) + Directory("bin") + Directory(configuration); - - foreach(var targetFolder in projectToNugetFolderMap[project]) { - var destDir = buildDir + Directory("lib"); - - Information("Copying {0} -> {1}.", sourceDir, destDir); - CopyDirectory(sourceDir, destDir); - } - } - - CopyFile(nuspecSrcFile, nuspecDestFile); -}); - -Task("__StronglySignAssemblies") - .Does(() => -{ - //see: https://github.com/brutaldev/StrongNameSigner - var strongNameSignerSettings = new ProcessSettings() - .WithArguments(args => args - .Append("-in") - .AppendQuoted(buildDir) - .Append("-k") - .AppendQuoted(snkFile) - .Append("-l") - .AppendQuoted("Changes")); - - StartProcess(strongNameSignerPath, strongNameSignerSettings); -}); - Task("__CreateSignedNugetPackage") .Does(() => { @@ -257,14 +229,13 @@ Task("__CreateSignedNugetPackage") Information("Building {0}.{1}.nupkg", packageName, nugetVersion); - var nuGetPackSettings = new NuGetPackSettings { - Id = packageName, - Title = packageName, - Version = nugetVersion, + var dotNetCorePackSettings = new DotNetCorePackSettings { + Configuration = configuration, + NoBuild = true, OutputDirectory = nupkgDestDir }; - NuGetPack(nuspecDestFile, nuGetPackSettings); + DotNetCorePack($@"{srcDir}\{projectName}.sln", dotNetCorePackSettings); }); ////////////////////////////////////////////////////////////////////// @@ -279,8 +250,6 @@ Task("Build") .IsDependentOn("__UpdateAppVeyorBuildNumber") .IsDependentOn("__BuildSolutions") .IsDependentOn("__RunTests") - .IsDependentOn("__CopyOutputToNugetFolder") - .IsDependentOn("__StronglySignAssemblies") .IsDependentOn("__CreateSignedNugetPackage"); /////////////////////////////////////////////////////////////////////////////// @@ -301,6 +270,6 @@ RunTarget(target); ////////////////////////////////////////////////////////////////////// string ToolsExePath(string exeFileName) { - var exePath = System.IO.Directory.GetFiles(@".\Tools", exeFileName, SearchOption.AllDirectories).FirstOrDefault(); + var exePath = System.IO.Directory.GetFiles(@"./tools", exeFileName, SearchOption.AllDirectories).FirstOrDefault(); return exePath; } diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 0000000..252d5b3 --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,7 @@ + + + + ..\Polly.snk + true + + \ No newline at end of file diff --git a/src/GlobalAssemblyInfo.cs b/src/GlobalAssemblyInfo.cs deleted file mode 100644 index d9e6868..0000000 --- a/src/GlobalAssemblyInfo.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Reflection; - -[assembly: AssemblyProduct("Polly.Caching.Distributed")] -[assembly: AssemblyCompany("App vNext")] -[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) 2019, App vNext")] - -#if DEBUG -[assembly: AssemblyConfiguration("Debug")] -#else -[assembly: AssemblyConfiguration("Release")] -#endif 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 deleted file mode 100644 index 6da8810..0000000 --- a/src/Polly.Caching.Distributed.NetStandard11.Specs/Polly.Caching.Distributed.NetStandard11.Specs.csproj +++ /dev/null @@ -1,36 +0,0 @@ - - - false - Library - netcoreapp1.1 - library - - - full - TRACE;DEBUG;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.Distributed.NetStandard11.Specs/Properties/AssemblyInfo.cs b/src/Polly.Caching.Distributed.NetStandard11.Specs/Properties/AssemblyInfo.cs deleted file mode 100644 index 51233cb..0000000 --- a/src/Polly.Caching.Distributed.NetStandard11.Specs/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,5 +0,0 @@ -using System.Reflection; -using Xunit; - -[assembly: AssemblyTitle("Polly.Caching.Distributed.NetStandard11.Specs")] -[assembly: CollectionBehavior(DisableTestParallelization = true)] \ No newline at end of file diff --git a/src/Polly.Caching.Distributed.NetStandard11/Polly.Caching.Distributed.NetStandard11.csproj b/src/Polly.Caching.Distributed.NetStandard11/Polly.Caching.Distributed.NetStandard11.csproj deleted file mode 100644 index 1d141e0..0000000 --- a/src/Polly.Caching.Distributed.NetStandard11/Polly.Caching.Distributed.NetStandard11.csproj +++ /dev/null @@ -1,38 +0,0 @@ - - - Polly.Caching.Distributed - ..\Polly.Caching.IDistributedCache.Net45\Polly.Caching.IDistributedCache.snk - TRACE;PORTABLE - en-US - false - true - Polly.Caching.Distributed - netstandard1.1 - 1.6.1 - - - full - true - - - - pdbonly - true - - - - False - - - - - Properties\GlobalAssemblyInfo.cs - - - - - - - - - \ No newline at end of file diff --git a/src/Polly.Caching.Distributed.NetStandard11/Properties/AssemblyInfo.cs b/src/Polly.Caching.Distributed.NetStandard11/Properties/AssemblyInfo.cs deleted file mode 100644 index ec763bd..0000000 --- a/src/Polly.Caching.Distributed.NetStandard11/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Reflection; -using System.Runtime.CompilerServices; - -[assembly: AssemblyTitle("Polly.Caching.Distributed")] -[assembly: AssemblyVersion("3.0.0.0")] -[assembly: AssemblyFileVersion("3.0.0.0")] -[assembly: AssemblyInformationalVersion("3.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.Specs/Polly.Caching.Distributed.NetStandard20.Specs.csproj b/src/Polly.Caching.Distributed.NetStandard20.Specs/Polly.Caching.Distributed.NetStandard20.Specs.csproj deleted file mode 100644 index 1fcb192..0000000 --- a/src/Polly.Caching.Distributed.NetStandard20.Specs/Polly.Caching.Distributed.NetStandard20.Specs.csproj +++ /dev/null @@ -1,37 +0,0 @@ - - - false - Library - netcoreapp2.0 - library - - - full - TRACE;DEBUG;NETCOREAPP2_0;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.Distributed.NetStandard20.Specs/Properties/AssemblyInfo.cs b/src/Polly.Caching.Distributed.NetStandard20.Specs/Properties/AssemblyInfo.cs deleted file mode 100644 index d3cdae6..0000000 --- a/src/Polly.Caching.Distributed.NetStandard20.Specs/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,5 +0,0 @@ -using System.Reflection; -using Xunit; - -[assembly: AssemblyTitle("Polly.Caching.Distributed.NetStandard20.Specs")] -[assembly: CollectionBehavior(DisableTestParallelization = true)] \ No newline at end of file diff --git a/src/Polly.Caching.Distributed.NetStandard20/Polly.Caching.Distributed.NetStandard20.csproj b/src/Polly.Caching.Distributed.NetStandard20/Polly.Caching.Distributed.NetStandard20.csproj deleted file mode 100644 index b45093d..0000000 --- a/src/Polly.Caching.Distributed.NetStandard20/Polly.Caching.Distributed.NetStandard20.csproj +++ /dev/null @@ -1,37 +0,0 @@ - - - Polly.Caching.Distributed - ..\Polly.Caching.IDistributedCache.Net45\Polly.Caching.IDistributedCache.snk - TRACE;PORTABLE - en-US - false - true - Polly.Caching.Distributed - 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.Distributed.NetStandard20/Properties/AssemblyInfo.cs b/src/Polly.Caching.Distributed.NetStandard20/Properties/AssemblyInfo.cs deleted file mode 100644 index 4e5c197..0000000 --- a/src/Polly.Caching.Distributed.NetStandard20/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Reflection; -using System.Runtime.CompilerServices; - -[assembly: AssemblyTitle("Polly.Caching.Distributed")] -[assembly: AssemblyVersion("3.0.0.0")] -[assembly: AssemblyFileVersion("3.0.0.0")] -[assembly: AssemblyInformationalVersion("3.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 diff --git a/src/Polly.Caching.Distributed.Shared/Polly.Caching.Distributed.Shared.projitems b/src/Polly.Caching.Distributed.Shared/Polly.Caching.Distributed.Shared.projitems deleted file mode 100644 index add0aea..0000000 --- a/src/Polly.Caching.Distributed.Shared/Polly.Caching.Distributed.Shared.projitems +++ /dev/null @@ -1,19 +0,0 @@ - - - - $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - true - 23fa87f9-c77d-4c67-a0b0-2901de51b3ff - - - Polly.Caching.Distributed - - - - - - - - - - \ No newline at end of file diff --git a/src/Polly.Caching.Distributed.Shared/Polly.Caching.Distributed.Shared.shproj b/src/Polly.Caching.Distributed.Shared/Polly.Caching.Distributed.Shared.shproj deleted file mode 100644 index 63ae828..0000000 --- a/src/Polly.Caching.Distributed.Shared/Polly.Caching.Distributed.Shared.shproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - 23fa87f9-c77d-4c67-a0b0-2901de51b3ff - 14.0 - - - - - - - - diff --git a/src/Polly.Caching.Distributed.SharedSpecs/Polly.Caching.Distributed.SharedSpecs.projitems b/src/Polly.Caching.Distributed.SharedSpecs/Polly.Caching.Distributed.SharedSpecs.projitems deleted file mode 100644 index e54580f..0000000 --- a/src/Polly.Caching.Distributed.SharedSpecs/Polly.Caching.Distributed.SharedSpecs.projitems +++ /dev/null @@ -1,27 +0,0 @@ - - - - $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - true - 8d537c37-a4a2-4be1-84bc-34f1afb51ca8 - - - Polly.Caching.Distributed.Specs - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Polly.Caching.Distributed.SharedSpecs/Polly.Caching.Distributed.SharedSpecs.shproj b/src/Polly.Caching.Distributed.SharedSpecs/Polly.Caching.Distributed.SharedSpecs.shproj deleted file mode 100644 index 3933378..0000000 --- a/src/Polly.Caching.Distributed.SharedSpecs/Polly.Caching.Distributed.SharedSpecs.shproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - 8d537c37-a4a2-4be1-84bc-34f1afb51ca8 - 14.0 - - - - - - - - diff --git a/src/Polly.Caching.Distributed.SharedSpecs/Integration/ByteArraySerializer.cs b/src/Polly.Caching.Distributed.Specs/Integration/ByteArraySerializer.cs similarity index 100% rename from src/Polly.Caching.Distributed.SharedSpecs/Integration/ByteArraySerializer.cs rename to src/Polly.Caching.Distributed.Specs/Integration/ByteArraySerializer.cs diff --git a/src/Polly.Caching.Distributed.SharedSpecs/Integration/CacheRoundTripSpecsBase.cs b/src/Polly.Caching.Distributed.Specs/Integration/CacheRoundTripSpecsBase.cs similarity index 93% rename from src/Polly.Caching.Distributed.SharedSpecs/Integration/CacheRoundTripSpecsBase.cs rename to src/Polly.Caching.Distributed.Specs/Integration/CacheRoundTripSpecsBase.cs index f97dacb..6ec7510 100644 --- a/src/Polly.Caching.Distributed.SharedSpecs/Integration/CacheRoundTripSpecsBase.cs +++ b/src/Polly.Caching.Distributed.Specs/Integration/CacheRoundTripSpecsBase.cs @@ -77,8 +77,7 @@ public async Task Should_roundtrip_all_variants_of_nullable_bool(bool? testValue { "some string", "", - null, - default(string), + null, // == default(string), "null" }; @@ -86,9 +85,8 @@ public async Task Should_roundtrip_all_variants_of_nullable_bool(bool? testValue new TheoryData { -1, - 0, - 1, - default(int) + 0, // == default(int) + 1 }; public static TheoryData SampleEnumData => @@ -103,8 +101,7 @@ public async Task Should_roundtrip_all_variants_of_nullable_bool(bool? testValue new TheoryData { true, - false, - default(bool), + false, // == default(bool), }; public static TheoryData SampleNullableBoolData => @@ -112,8 +109,7 @@ public async Task Should_roundtrip_all_variants_of_nullable_bool(bool? testValue { true, false, - null, - default(bool?), + null, // == default(bool?), }; public class SampleClass @@ -124,6 +120,7 @@ public class SampleClass public enum SampleEnum { + Default, FirstValue, SecondValue, } diff --git a/src/Polly.Caching.Distributed.SharedSpecs/Integration/CacheRoundTripSpecsSyncBase.cs b/src/Polly.Caching.Distributed.Specs/Integration/CacheRoundTripSpecsSyncBase.cs similarity index 91% rename from src/Polly.Caching.Distributed.SharedSpecs/Integration/CacheRoundTripSpecsSyncBase.cs rename to src/Polly.Caching.Distributed.Specs/Integration/CacheRoundTripSpecsSyncBase.cs index 7c95cfd..a7bc927 100644 --- a/src/Polly.Caching.Distributed.SharedSpecs/Integration/CacheRoundTripSpecsSyncBase.cs +++ b/src/Polly.Caching.Distributed.Specs/Integration/CacheRoundTripSpecsSyncBase.cs @@ -27,7 +27,7 @@ public override Task Should_roundtrip_this_variant_of(TResult testValue underlyingDelegateExecuteCount++; return testValue; }, new Context(OperationKey)) - .ShouldBeEquivalentTo(testValue); + .Should().BeEquivalentTo(testValue); // Assert - should have executed underlying delegate underlyingDelegateExecuteCount.Should().Be(1); @@ -35,7 +35,7 @@ public override Task Should_roundtrip_this_variant_of(TResult testValue // Assert - should be in cache (bool cacheHit2, TResult fromCache2) = cacheProvider.TryGet(OperationKey); cacheHit2.Should().BeTrue(); - fromCache2.ShouldBeEquivalentTo(testValue); + fromCache2.Should().BeEquivalentTo(testValue); // Act - should execute underlying delegate and place in cache cache.Execute(ctx => @@ -43,7 +43,7 @@ public override Task Should_roundtrip_this_variant_of(TResult testValue underlyingDelegateExecuteCount++; throw new Exception("Cache should be used so this should not get invoked."); }, new Context(OperationKey)) - .ShouldBeEquivalentTo(testValue); + .Should().BeEquivalentTo(testValue); underlyingDelegateExecuteCount.Should().Be(1); return Task.CompletedTask; diff --git a/src/Polly.Caching.Distributed.SharedSpecs/Integration/CacheRoundTripSpecs_NetStandardIDistributedCacheProvider_Async_ByteArray.cs b/src/Polly.Caching.Distributed.Specs/Integration/CacheRoundTripSpecs_NetStandardIDistributedCacheProvider_Async_ByteArray.cs similarity index 100% rename from src/Polly.Caching.Distributed.SharedSpecs/Integration/CacheRoundTripSpecs_NetStandardIDistributedCacheProvider_Async_ByteArray.cs rename to src/Polly.Caching.Distributed.Specs/Integration/CacheRoundTripSpecs_NetStandardIDistributedCacheProvider_Async_ByteArray.cs diff --git a/src/Polly.Caching.Distributed.SharedSpecs/Integration/CacheRoundTripSpecs_NetStandardIDistributedCacheProvider_Async_String.cs b/src/Polly.Caching.Distributed.Specs/Integration/CacheRoundTripSpecs_NetStandardIDistributedCacheProvider_Async_String.cs similarity index 100% rename from src/Polly.Caching.Distributed.SharedSpecs/Integration/CacheRoundTripSpecs_NetStandardIDistributedCacheProvider_Async_String.cs rename to src/Polly.Caching.Distributed.Specs/Integration/CacheRoundTripSpecs_NetStandardIDistributedCacheProvider_Async_String.cs diff --git a/src/Polly.Caching.Distributed.SharedSpecs/Integration/CacheRoundTripSpecs_NetStandardIDistributedCacheProvider_Sync_ByteArray.cs b/src/Polly.Caching.Distributed.Specs/Integration/CacheRoundTripSpecs_NetStandardIDistributedCacheProvider_Sync_ByteArray.cs similarity index 100% rename from src/Polly.Caching.Distributed.SharedSpecs/Integration/CacheRoundTripSpecs_NetStandardIDistributedCacheProvider_Sync_ByteArray.cs rename to src/Polly.Caching.Distributed.Specs/Integration/CacheRoundTripSpecs_NetStandardIDistributedCacheProvider_Sync_ByteArray.cs diff --git a/src/Polly.Caching.Distributed.SharedSpecs/Integration/CacheRoundTripSpecs_NetStandardIDistributedCacheProvider_Sync_String.cs b/src/Polly.Caching.Distributed.Specs/Integration/CacheRoundTripSpecs_NetStandardIDistributedCacheProvider_Sync_String.cs similarity index 100% rename from src/Polly.Caching.Distributed.SharedSpecs/Integration/CacheRoundTripSpecs_NetStandardIDistributedCacheProvider_Sync_String.cs rename to src/Polly.Caching.Distributed.Specs/Integration/CacheRoundTripSpecs_NetStandardIDistributedCacheProvider_Sync_String.cs diff --git a/src/Polly.Caching.Distributed.SharedSpecs/Integration/CacheRoundTripspecsAsyncBase.cs b/src/Polly.Caching.Distributed.Specs/Integration/CacheRoundTripspecsAsyncBase.cs similarity index 92% rename from src/Polly.Caching.Distributed.SharedSpecs/Integration/CacheRoundTripspecsAsyncBase.cs rename to src/Polly.Caching.Distributed.Specs/Integration/CacheRoundTripspecsAsyncBase.cs index 52e4ec1..8a0d80c 100644 --- a/src/Polly.Caching.Distributed.SharedSpecs/Integration/CacheRoundTripspecsAsyncBase.cs +++ b/src/Polly.Caching.Distributed.Specs/Integration/CacheRoundTripspecsAsyncBase.cs @@ -28,7 +28,7 @@ public override async Task Should_roundtrip_this_variant_of(TResult tes underlyingDelegateExecuteCount++; return Task.FromResult(testValue); }, new Context(OperationKey))) - .ShouldBeEquivalentTo(testValue); + .Should().BeEquivalentTo(testValue); // Assert - should have executed underlying delegate underlyingDelegateExecuteCount.Should().Be(1); @@ -36,7 +36,7 @@ public override async Task Should_roundtrip_this_variant_of(TResult tes // Assert - should be in cache (bool cacheHit2, TResult fromCache2) = await cacheProvider.TryGetAsync(OperationKey, CancellationToken.None, false); cacheHit2.Should().BeTrue(); - fromCache2.ShouldBeEquivalentTo(testValue); + fromCache2.Should().BeEquivalentTo(testValue); // Act - should execute underlying delegate and place in cache (await cache.ExecuteAsync(ctx => @@ -44,7 +44,7 @@ public override async Task Should_roundtrip_this_variant_of(TResult tes underlyingDelegateExecuteCount++; throw new Exception("Cache should be used so this should not get invoked."); }, new Context(OperationKey))) - .ShouldBeEquivalentTo(testValue); + .Should().BeEquivalentTo(testValue); underlyingDelegateExecuteCount.Should().Be(1); } } diff --git a/src/Polly.Caching.Distributed.SharedSpecs/Integration/ICachePolicyFactory.cs b/src/Polly.Caching.Distributed.Specs/Integration/ICachePolicyFactory.cs similarity index 100% rename from src/Polly.Caching.Distributed.SharedSpecs/Integration/ICachePolicyFactory.cs rename to src/Polly.Caching.Distributed.Specs/Integration/ICachePolicyFactory.cs diff --git a/src/Polly.Caching.Distributed.SharedSpecs/Integration/MemoryDistributedCachePolicyFactory.cs b/src/Polly.Caching.Distributed.Specs/Integration/MemoryDistributedCachePolicyFactory.cs similarity index 100% rename from src/Polly.Caching.Distributed.SharedSpecs/Integration/MemoryDistributedCachePolicyFactory.cs rename to src/Polly.Caching.Distributed.Specs/Integration/MemoryDistributedCachePolicyFactory.cs diff --git a/src/Polly.Caching.Distributed.Specs/Polly.Caching.Distributed.Specs.csproj b/src/Polly.Caching.Distributed.Specs/Polly.Caching.Distributed.Specs.csproj new file mode 100644 index 0000000..ce69ae2 --- /dev/null +++ b/src/Polly.Caching.Distributed.Specs/Polly.Caching.Distributed.Specs.csproj @@ -0,0 +1,43 @@ + + + + netcoreapp1.1;netcoreapp2.0;net461;net472;netcoreapp3.0 + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Polly.Caching.Distributed.SharedSpecs/Unit/CacheProviderHelperTests.cs b/src/Polly.Caching.Distributed.Specs/Unit/CacheProviderHelperTests.cs similarity index 87% rename from src/Polly.Caching.Distributed.SharedSpecs/Unit/CacheProviderHelperTests.cs rename to src/Polly.Caching.Distributed.Specs/Unit/CacheProviderHelperTests.cs index c41f3e6..3308c81 100644 --- a/src/Polly.Caching.Distributed.SharedSpecs/Unit/CacheProviderHelperTests.cs +++ b/src/Polly.Caching.Distributed.Specs/Unit/CacheProviderHelperTests.cs @@ -1,10 +1,9 @@ using System; using FluentAssertions; using Moq; -using Polly.Caching.Distributed; using Xunit; -namespace Polly.Specs.Caching.Distributed.Unit +namespace Polly.Caching.Distributed.Specs.Unit { public class CacheProviderHelperTests { @@ -15,7 +14,7 @@ public void Should_configure_sync_string_provider() Action configure = () => mockDistributedCache.Object.AsSyncCacheProvider(); - configure.ShouldNotThrow(); + configure.Should().NotThrow(); } [Fact] @@ -25,7 +24,7 @@ public void Should_configure_sync_bytearray_provider() Action configure = () => mockDistributedCache.Object.AsSyncCacheProvider(); - configure.ShouldNotThrow(); + configure.Should().NotThrow(); } [Fact] @@ -35,7 +34,7 @@ public void Should_configure_async_string_provider() Action configure = () => mockDistributedCache.Object.AsAsyncCacheProvider(); - configure.ShouldNotThrow(); + configure.Should().NotThrow(); } [Fact] @@ -45,7 +44,7 @@ public void Should_configure_async_bytearray_provider() Action configure = () => mockDistributedCache.Object.AsAsyncCacheProvider(); - configure.ShouldNotThrow(); + configure.Should().NotThrow(); } [Fact] @@ -55,7 +54,7 @@ public void Should_throw_for_unsupported_type_of_results_to_cache_sync() Action configure = () => mockDistributedCache.Object.AsSyncCacheProvider(); - configure.ShouldThrow(); + configure.Should().Throw(); } [Fact] @@ -65,7 +64,7 @@ public void Should_throw_for_unsupported_type_of_results_to_cache_async() Action configure = () => mockDistributedCache.Object.AsAsyncCacheProvider(); - configure.ShouldThrow(); + configure.Should().Throw(); } } diff --git a/src/Polly.Caching.Distributed.SharedSpecs/Unit/NetStandardIDistributedCacheByteArrayProviderSpecs.cs b/src/Polly.Caching.Distributed.Specs/Unit/NetStandardIDistributedCacheByteArrayProviderSpecs.cs similarity index 94% rename from src/Polly.Caching.Distributed.SharedSpecs/Unit/NetStandardIDistributedCacheByteArrayProviderSpecs.cs rename to src/Polly.Caching.Distributed.Specs/Unit/NetStandardIDistributedCacheByteArrayProviderSpecs.cs index 735f8c4..8b42a0a 100644 --- a/src/Polly.Caching.Distributed.SharedSpecs/Unit/NetStandardIDistributedCacheByteArrayProviderSpecs.cs +++ b/src/Polly.Caching.Distributed.Specs/Unit/NetStandardIDistributedCacheByteArrayProviderSpecs.cs @@ -5,11 +5,9 @@ using FluentAssertions; using Microsoft.Extensions.Caching.Distributed; using Moq; -using Polly.Caching; -using Polly.Caching.Distributed; using Xunit; -namespace Polly.Specs.Caching.Distributed.Unit +namespace Polly.Caching.Distributed.Specs.Unit { public class NetStandardIDistributedCacheByteArrayProviderSpecs { @@ -20,7 +18,7 @@ public void Should_throw_when_IDistributedCache_is_null() { Action configure = () => ((IDistributedCache)null).AsSyncCacheProvider(); - configure.ShouldThrow().And.ParamName.Should().Be("iDistributedCache"); + configure.Should().Throw().And.ParamName.Should().Be("iDistributedCache"); } @@ -30,7 +28,7 @@ public void Should_not_throw_when_IDistributedCache_is_not_null() IDistributedCache mockDistributedCache = new Mock().Object; Action configure = () => mockDistributedCache.AsSyncCacheProvider(); - configure.ShouldNotThrow(); + configure.Should().NotThrow(); } #endregion @@ -123,7 +121,7 @@ public async Task GetAsync_should_return_instance_previously_stored_in_cache() string key = "anything"; var cachedValue = Encoding.UTF8.GetBytes(Guid.NewGuid().ToString()); mockDistributedCache.Setup(idc => idc.GetAsync(It.Is(k => k == key) -#if NETCOREAPP2_0 +#if !NETCOREAPP1_1 , It.IsAny() #endif )).Returns(Task.FromResult(cachedValue)); @@ -133,7 +131,7 @@ public async Task GetAsync_should_return_instance_previously_stored_in_cache() got.Should().BeTrue(); mockDistributedCache.Verify(v => v.GetAsync(key -#if NETCOREAPP2_0 +#if !NETCOREAPP1_1 , It.IsAny() #endif ), Times.Once); @@ -147,13 +145,13 @@ public async Task GetAsync_should_return_false_on_unknown_key() string key = "anything"; var cachedValue = Encoding.UTF8.GetBytes(Guid.NewGuid().ToString()); mockDistributedCache.Setup(idc => idc.GetAsync(It.Is(k => k == key) -#if NETCOREAPP2_0 +#if !NETCOREAPP1_1 , It.IsAny() #endif )).Returns(Task.FromResult(cachedValue)); mockDistributedCache.Setup(idc => idc.GetAsync(It.Is(k => k != key) -#if NETCOREAPP2_0 +#if !NETCOREAPP1_1 , It.IsAny() #endif )).Returns(Task.FromResult(null)).Verifiable(); @@ -165,7 +163,7 @@ public async Task GetAsync_should_return_false_on_unknown_key() got.Should().BeFalse(); mockDistributedCache.Verify(v => v.GetAsync(someOtherKey -#if NETCOREAPP2_0 +#if !NETCOREAPP1_1 , It.IsAny() #endif ), Times.Once); @@ -180,7 +178,7 @@ public void GetAsync_should_throw_for_cancellation() IAsyncCacheProvider provider = mockDistributedCache.Object.AsAsyncCacheProvider(); Func action = () => provider.TryGetAsync(key, new CancellationToken(true), false); - action.ShouldThrow(); + action.Should().Throw(); } #endregion @@ -197,7 +195,7 @@ 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() -#if NETCOREAPP2_0 +#if !NETCOREAPP1_1 , It.IsAny() #endif )).Returns(Task.CompletedTask).Verifiable(); @@ -208,7 +206,7 @@ public async Task PutAsync_should_put_item_using_passed_nonsliding_ttl() await provider.PutAsync(key, valueToCache, ttl, CancellationToken.None, false); mockDistributedCache.Verify(idc => idc.SetAsync(key, valueToCache, It.Is(o => o.AbsoluteExpirationRelativeToNow == timespan) -#if NETCOREAPP2_0 +#if !NETCOREAPP1_1 , It.IsAny() #endif )); @@ -224,7 +222,7 @@ 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() -#if NETCOREAPP2_0 +#if !NETCOREAPP1_1 , It.IsAny() #endif )).Returns(Task.CompletedTask).Verifiable(); @@ -234,7 +232,7 @@ public async Task PutAsync_should_put_item_using_passed_sliding_ttl() await provider.PutAsync(key, valueToCache, ttl, CancellationToken.None, false); mockDistributedCache.Verify(idc => idc.SetAsync(key, valueToCache, It.Is(o => o.SlidingExpiration == timespan) -#if NETCOREAPP2_0 +#if !NETCOREAPP1_1 , It.IsAny() #endif )); @@ -252,7 +250,7 @@ public void PutAsync_should_throw_for_cancellation() IAsyncCacheProvider provider = mockDistributedCache.Object.AsAsyncCacheProvider(); Func action = () => provider.PutAsync(key, valueToCache, ttl, new CancellationToken(true), false); - action.ShouldThrow(); + action.Should().Throw(); } #endregion } diff --git a/src/Polly.Caching.Distributed.SharedSpecs/Unit/NetStandardIDistributedCacheStringProviderSpecs.cs b/src/Polly.Caching.Distributed.Specs/Unit/NetStandardIDistributedCacheStringProviderSpecs.cs similarity index 95% rename from src/Polly.Caching.Distributed.SharedSpecs/Unit/NetStandardIDistributedCacheStringProviderSpecs.cs rename to src/Polly.Caching.Distributed.Specs/Unit/NetStandardIDistributedCacheStringProviderSpecs.cs index c944c04..08c5b8b 100644 --- a/src/Polly.Caching.Distributed.SharedSpecs/Unit/NetStandardIDistributedCacheStringProviderSpecs.cs +++ b/src/Polly.Caching.Distributed.Specs/Unit/NetStandardIDistributedCacheStringProviderSpecs.cs @@ -5,11 +5,9 @@ using FluentAssertions; using Microsoft.Extensions.Caching.Distributed; using Moq; -using Polly.Caching; -using Polly.Caching.Distributed; using Xunit; -namespace Polly.Specs.Caching.Distributed.Unit +namespace Polly.Caching.Distributed.Specs.Unit { public class NetStandardIDistributedCacheStringProviderSpecs { @@ -20,7 +18,7 @@ public void Should_throw_when_IDistributedCache_is_null() { Action configure = () => ((IDistributedCache)null).AsSyncCacheProvider(); - configure.ShouldThrow().And.ParamName.Should().Be("iDistributedCache"); + configure.Should().Throw().And.ParamName.Should().Be("iDistributedCache"); } @@ -30,7 +28,7 @@ public void Should_not_throw_when_IDistributedCache_is_not_null() IDistributedCache mockDistributedCache = new Mock().Object; Action configure = () => mockDistributedCache.AsSyncCacheProvider(); - configure.ShouldNotThrow(); + configure.Should().NotThrow(); } #endregion @@ -123,7 +121,7 @@ public async Task GetAsync_should_return_instance_previously_stored_in_cache() string key = "anything"; string valueToCache = Guid.NewGuid().ToString(); mockDistributedCache.Setup(idc => idc.GetAsync(It.Is(k => k == key) -#if NETCOREAPP2_0 +#if !NETCOREAPP1_1 , It.IsAny() #endif )).Returns(Task.FromResult(Encoding.UTF8.GetBytes(valueToCache))).Verifiable(); // Because GetStringAsync() is an extension method, we cannot mock it. We mock GetAsync() instead. @@ -133,7 +131,7 @@ public async Task GetAsync_should_return_instance_previously_stored_in_cache() got.Should().BeTrue(); mockDistributedCache.Verify(v => v.GetAsync(key -#if NETCOREAPP2_0 +#if !NETCOREAPP1_1 , It.IsAny() #endif ), Times.Once); @@ -147,13 +145,13 @@ public async Task GetAsync_should_return_false_on_unknown_key() string key = "anything"; var cachedValue = Encoding.UTF8.GetBytes(Guid.NewGuid().ToString()); mockDistributedCache.Setup(idc => idc.GetAsync(It.Is(k => k == key) -#if NETCOREAPP2_0 +#if !NETCOREAPP1_1 , It.IsAny() #endif )).Returns(Task.FromResult(cachedValue)); // 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 +#if !NETCOREAPP1_1 , It.IsAny() #endif )).Returns(Task.FromResult(null)).Verifiable(); @@ -164,7 +162,7 @@ public async Task GetAsync_should_return_false_on_unknown_key() got.Should().BeFalse(); mockDistributedCache.Verify(v => v.GetAsync(someOtherKey -#if NETCOREAPP2_0 +#if !NETCOREAPP1_1 , It.IsAny() #endif ), Times.Once); @@ -179,7 +177,7 @@ public void GetAsync_should_throw_for_cancellation() IAsyncCacheProvider provider = mockDistributedCache.Object.AsAsyncCacheProvider(); Func action = () => provider.TryGetAsync(key, new CancellationToken(true), false); - action.ShouldThrow(); + action.Should().Throw(); } #endregion @@ -196,7 +194,7 @@ 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() -#if NETCOREAPP2_0 +#if !NETCOREAPP1_1 , It.IsAny() #endif )).Returns(Task.CompletedTask).Verifiable(); // Because SetStringAsync() is an extension method, we cannot mock it. We mock SetAsync() instead. @@ -207,7 +205,7 @@ public async Task PutAsync_should_put_item_using_passed_nonsliding_ttl() await provider.PutAsync(key, valueToCache, ttl, CancellationToken.None, false); mockDistributedCache.Verify(idc => idc.SetAsync(key, It.IsAny(), It.Is(o => o.AbsoluteExpirationRelativeToNow == timespan) -#if NETCOREAPP2_0 +#if !NETCOREAPP1_1 , It.IsAny() #endif )); @@ -223,7 +221,7 @@ 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() -#if NETCOREAPP2_0 +#if !NETCOREAPP1_1 , It.IsAny() #endif )).Returns(Task.CompletedTask); // Because SetStringAsync() is an extension method, we cannot mock it. We mock SetAsync() instead. @@ -233,7 +231,7 @@ public async Task PutAsync_should_put_item_using_passed_sliding_ttl() await provider.PutAsync(key, valueToCache, ttl, CancellationToken.None, false); mockDistributedCache.Verify(idc => idc.SetAsync(key, It.IsAny(), It.Is(o => o.SlidingExpiration == timespan) -#if NETCOREAPP2_0 +#if !NETCOREAPP1_1 , It.IsAny() #endif )); @@ -251,7 +249,7 @@ public void PutAsync_should_throw_for_cancellation() IAsyncCacheProvider provider = mockDistributedCache.Object.AsAsyncCacheProvider(); Func action = () => provider.PutAsync(key, valueToCache, ttl, new CancellationToken(true), false); - action.ShouldThrow(); + action.Should().Throw(); } #endregion } diff --git a/src/Polly.Caching.Distributed.SharedSpecs/Unit/TtlStrategyHelperTests.cs b/src/Polly.Caching.Distributed.Specs/Unit/TtlStrategyHelperTests.cs similarity index 95% rename from src/Polly.Caching.Distributed.SharedSpecs/Unit/TtlStrategyHelperTests.cs rename to src/Polly.Caching.Distributed.Specs/Unit/TtlStrategyHelperTests.cs index 5cf264b..0010a4f 100644 --- a/src/Polly.Caching.Distributed.SharedSpecs/Unit/TtlStrategyHelperTests.cs +++ b/src/Polly.Caching.Distributed.Specs/Unit/TtlStrategyHelperTests.cs @@ -1,12 +1,9 @@ using System; using FluentAssertions; -using Moq; using Microsoft.Extensions.Caching.Distributed; -using Polly.Caching.Distributed; -using Polly.Caching; using Xunit; -namespace Polly.Specs.Caching.Distributed.Unit +namespace Polly.Caching.Distributed.Specs.Unit { public class TtlStrategyHelperTests { diff --git a/src/Polly.Caching.Distributed.nuspec b/src/Polly.Caching.Distributed.nuspec deleted file mode 100644 index 536fa95..0000000 --- a/src/Polly.Caching.Distributed.nuspec +++ /dev/null @@ -1,56 +0,0 @@ - - - - App vNext - App vNext - - 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 - BSD-3-Clause - https://raw.github.com/App-vNext/Polly/master/Polly.png - https://github.com/App-vNext/Polly.Caching.IDistributedCache - Polly Cache Caching Cache-aside - Copyright © 2019, App vNext - - 3.0.0 - --------------------- - - Allow caching of default(TResult) - - Compatible with Polly >= v7 - - 2.0.1 - --------------------- - - No functional changes - - Indicate compatibility with Polly < v7 - - 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 - --------------------- - - - Allows Polly CachePolicy to be used with Microsoft.Extensions.Caching.Distributed.IDistributedCache implementations. - - Release candidate - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Polly.Caching.Distributed.sln b/src/Polly.Caching.Distributed.sln index 74d7a32..c3bd3a4 100644 --- a/src/Polly.Caching.Distributed.sln +++ b/src/Polly.Caching.Distributed.sln @@ -1,52 +1,26 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26430.16 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29403.142 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 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Polly.Caching.Distributed", "Polly.Caching.Distributed\Polly.Caching.Distributed.csproj", "{78D2B68F-131C-43DD-820B-D761C30AB2CD}" 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}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Polly.Caching.Distributed.Specs", "Polly.Caching.Distributed.Specs\Polly.Caching.Distributed.Specs.csproj", "{732E300F-20CD-4F1F-A07B-2A5FA17F9789}" 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 + {78D2B68F-131C-43DD-820B-D761C30AB2CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {78D2B68F-131C-43DD-820B-D761C30AB2CD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {78D2B68F-131C-43DD-820B-D761C30AB2CD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {78D2B68F-131C-43DD-820B-D761C30AB2CD}.Release|Any CPU.Build.0 = Release|Any CPU + {732E300F-20CD-4F1F-A07B-2A5FA17F9789}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {732E300F-20CD-4F1F-A07B-2A5FA17F9789}.Debug|Any CPU.Build.0 = Debug|Any CPU + {732E300F-20CD-4F1F-A07B-2A5FA17F9789}.Release|Any CPU.ActiveCfg = Release|Any CPU + {732E300F-20CD-4F1F-A07B-2A5FA17F9789}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Polly.Caching.Distributed.Shared/CacheProviderHelper.cs b/src/Polly.Caching.Distributed/CacheProviderHelper.cs similarity index 100% rename from src/Polly.Caching.Distributed.Shared/CacheProviderHelper.cs rename to src/Polly.Caching.Distributed/CacheProviderHelper.cs diff --git a/src/Polly.Caching.Distributed.Shared/NetStandardIDistributedCacheByteArrayProvider.cs b/src/Polly.Caching.Distributed/NetStandardIDistributedCacheByteArrayProvider.cs similarity index 99% rename from src/Polly.Caching.Distributed.Shared/NetStandardIDistributedCacheByteArrayProvider.cs rename to src/Polly.Caching.Distributed/NetStandardIDistributedCacheByteArrayProvider.cs index 98f251e..123c66d 100644 --- a/src/Polly.Caching.Distributed.Shared/NetStandardIDistributedCacheByteArrayProvider.cs +++ b/src/Polly.Caching.Distributed/NetStandardIDistributedCacheByteArrayProvider.cs @@ -1,5 +1,4 @@ -using System; -using System.Threading; +using System.Threading; using System.Threading.Tasks; namespace Polly.Caching.Distributed diff --git a/src/Polly.Caching.Distributed.Shared/NetStandardIDistributedCacheProvider.cs b/src/Polly.Caching.Distributed/NetStandardIDistributedCacheProvider.cs similarity index 100% rename from src/Polly.Caching.Distributed.Shared/NetStandardIDistributedCacheProvider.cs rename to src/Polly.Caching.Distributed/NetStandardIDistributedCacheProvider.cs diff --git a/src/Polly.Caching.Distributed.Shared/NetStandardIDistributedCacheStringProvider.cs b/src/Polly.Caching.Distributed/NetStandardIDistributedCacheStringProvider.cs similarity index 100% rename from src/Polly.Caching.Distributed.Shared/NetStandardIDistributedCacheStringProvider.cs rename to src/Polly.Caching.Distributed/NetStandardIDistributedCacheStringProvider.cs diff --git a/src/Polly.Caching.Distributed/Polly.Caching.Distributed.csproj b/src/Polly.Caching.Distributed/Polly.Caching.Distributed.csproj new file mode 100644 index 0000000..2b45df0 --- /dev/null +++ b/src/Polly.Caching.Distributed/Polly.Caching.Distributed.csproj @@ -0,0 +1,56 @@ + + + netstandard1.1;netstandard2.0;netstandard2.1 + Polly.Caching.Distributed + Polly.Caching.Distributed + 3.0.1 + 3.0.0.0 + 3.0.1.0 + 3.0.1.0 + 3.0.1 + App vNext + Copyright (c) 2019, App vNext + 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 + true + true + App vNext + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + + + true + true + snupkg + + + + + + true + + + 1.6.1 + + + + + + + + + + + + + + + + en-US + Polly.Caching.Distributed + BSD-3-Clause + https://raw.github.com/App-vNext/Polly/master/Polly.png + https://github.com/App-vNext/Polly.Caching.IDistributedCache + Polly Cache Caching Cache-aside + See https://github.com/App-vNext/Polly.Caching.IDistributedCache/blob/master/CHANGELOG.md + + diff --git a/src/Polly.Caching.Distributed.Shared/TtlHelper.cs b/src/Polly.Caching.Distributed/TtlHelper.cs similarity index 100% rename from src/Polly.Caching.Distributed.Shared/TtlHelper.cs rename to src/Polly.Caching.Distributed/TtlHelper.cs diff --git a/src/Polly.Caching.Distributed.Shared/TtlStrategyHelper.cs b/src/Polly.Caching.Distributed/TtlStrategyHelper.cs similarity index 100% rename from src/Polly.Caching.Distributed.Shared/TtlStrategyHelper.cs rename to src/Polly.Caching.Distributed/TtlStrategyHelper.cs