Skip to content

Commit

Permalink
adding .NET 5.0 issue #266
Browse files Browse the repository at this point in the history
  • Loading branch information
aliostad committed Dec 13, 2021
1 parent cc60675 commit bb0b910
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net461;net5.0</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netstandard2.0;net5.0</TargetFrameworks>
<Summary>Redis Storage for HTTP Client Caching</Summary>
<AssemblyName>CacheCow.Client.RedisCacheStore</AssemblyName>
<PackageId>CacheCow.Client.RedisCacheStore</PackageId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="11.0.1" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.5" />
<PackageReference Include="StackExchange.Redis" Version="2.0.601" />
<PackageReference Include="StackExchange.Redis" Version="2.2.88" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CacheCow.Client\CacheCow.Client.csproj" />
Expand Down
15 changes: 9 additions & 6 deletions src/CacheCow.Client/CacheCow.Client.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net452;net5.0</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netstandard2.0;net5.0</TargetFrameworks>
<Summary>Client constructs for HTTP Caching</Summary>
<AssemblyName>CacheCow.Client</AssemblyName>
<PackageId>CacheCow.Client</PackageId>
Expand All @@ -18,8 +18,11 @@
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
<Reference Include="System.Runtime.Caching" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.0.1" />
</ItemGroup>
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.0.1" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions src/CacheCow.Common/CacheCow.Common.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net452;net5.0</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netstandard2.0;net5.0</TargetFrameworks>
<Summary>Common constructs for HTTP Caching</Summary>
<AssemblyName>CacheCow.Common</AssemblyName>
<PackageId>CacheCow.Common</PackageId>
Expand Down
9 changes: 7 additions & 2 deletions src/CacheCow.Server.Core.Mvc/CacheCow.Server.Core.Mvc.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net5.0</TargetFrameworks>
<Summary>Server constructs for HTTP Caching in ASP.NET Core MVC</Summary>
<AssemblyName>CacheCow.Server.Core.Mvc</AssemblyName>
<PackageId>CacheCow.Server.Core.Mvc</PackageId>
</PropertyGroup>

<ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.3" />
<PackageReference Include="microsoft.extensions.configuration.binder" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.5" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="microsoft.extensions.configuration.binder" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\CacheCow.Common\CacheCow.Common.csproj" />
Expand Down
15 changes: 10 additions & 5 deletions src/CacheCow.Server/CacheCow.Server.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net452;net5.0</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netstandard2.0;net5.0</TargetFrameworks>
<Summary>Server constructs for HTTP Caching</Summary>
<AssemblyName>CacheCow.Server</AssemblyName>
<PackageId>CacheCow.Server</PackageId>
Expand All @@ -11,17 +11,22 @@
<Compile Include="..\Common\TraceWriter.cs" Link="TraceWriter.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="11.0.1" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CacheCow.Common\CacheCow.Common.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
<PackageReference Include="Newtonsoft.Json" Version="11.0.1" />
<PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.2.5" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' Or '$(TargetFramework)' == 'netcoreapp2.0' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.3" />
</ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="11.0.1" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net461;netcoreapp3.0</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp2.0;netcoreapp3.0</TargetFrameworks>
<TargetFrameworks>netcoreapp2.1;net461;netcoreapp3.0;net5.0</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp2.1;netcoreapp3.0;net5.0</TargetFrameworks>
<Summary>Client constructs for HTTP Caching</Summary>
<AssemblyName>CacheCow.Client.RedisCacheStore.Tests</AssemblyName>
<PackageId>CacheCow.Client.RedisCacheStore.Tests</PackageId>
Expand Down
6 changes: 3 additions & 3 deletions test/CacheCow.Client.Tests/CacheCow.Client.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net452;netcoreapp2.0;netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp2.0;netcoreapp3.0</TargetFrameworks>
<TargetFrameworks>net452;netcoreapp2.0;netcoreapp2.1;netcoreapp3.0;net5.0</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp2.0;netcoreapp3.0;net5.0</TargetFrameworks>
<Summary>Client constructs for HTTP Caching</Summary>
<AssemblyName>CacheCow.Client.Tests</AssemblyName>
<PackageId>CacheCow.Client.Tests</PackageId>
Expand All @@ -21,7 +21,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="11.0.1" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.5" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="Moq" Version="4.8.2" />
Expand Down
9 changes: 7 additions & 2 deletions test/CacheCow.Client.Tests/Helper/DeepComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,13 @@ private static void RecursiveCompare(string name, object a, object b, List<strin
propCount++;
}

if (propCount == 0)
errors.AddError(name, a, b);
if (name == ".Properties" || name == ".Options") // this is rubbish
return;

if (propCount == 0)
{
errors.AddError(name, a, b);
}

}

Expand Down
11 changes: 11 additions & 0 deletions test/CacheCow.Client.Tests/IntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ public async Task Test_GoogleImage_WorksOnFirstSecondRequestNotThird()
Assert.Equal(true, cacheCowHeader.RetrievedFromCache);
}

[Fact]
public async Task Simple_Caching_Example_From_Issue263()
{
var client = ClientExtensions.CreateClient();
const string CacheableResource = "https://code.jquery.com/jquery-3.3.1.slim.min.js";
var response = await client.GetAsync(CacheableResource);
var responseFromCache = await client.GetAsync(CacheableResource);
Assert.Equal(true, response.Headers.GetCacheCowHeader().DidNotExist);
Assert.Equal(true, responseFromCache.Headers.GetCacheCowHeader().RetrievedFromCache);
}

[Fact]
public async Task SettingNoHeaderWorks()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
<ApplicationIcon />
<OutputType>Library</OutputType>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.0" />
<PackageReference Include="microsoft.extensions.configuration.json" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.5" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="Moq" Version="4.8.2" />
Expand All @@ -22,6 +26,13 @@
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.2.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="Moq" Version="4.8.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="5.0.12" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\CacheCow.Client\CacheCow.Client.csproj" />
<ProjectReference Include="..\..\src\CacheCow.Common\CacheCow.Common.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ public HttpCacheFilterTestsStartup(IConfiguration configuration)
// This method gets called by the runtime. Use this method to add services to the container.
public virtual void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddMvc(options =>
{
options.EnableEndpointRouting = false;
});
services.AddHttpCachingMvc(options =>
{
options.EnableConfiguration = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ public class WithCustomExtractorStartup : WithQueryProviderStartup
// This method gets called by the runtime. Use this method to add services to the container.
public override void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddMvc(options =>
{
options.EnableEndpointRouting = false;
});
services.AddHttpCachingMvc();
services.AddExtractorForViewModelMvc<IEnumerable<TestViewModel>, TestViewModelCollectionExtractor>();
}
Expand Down
10 changes: 8 additions & 2 deletions test/CacheCow.Server.Core.Mvc.Tests/WithQueryProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ public class WithQueryProviderStartup
// This method gets called by the runtime. Use this method to add services to the container.
public virtual void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddMvc(options =>
{
options.EnableEndpointRouting = false;
});
services.AddHttpCachingMvc();
services.AddQueryProviderForViewModelMvc<TestViewModel, TestViewModelQueryProvider>();
services.AddQueryProviderForViewModelMvc<IEnumerable<TestViewModel>, TestViewModelCollectionQueryProvider>();
Expand Down Expand Up @@ -208,7 +211,10 @@ public class WithQueryProviderStartupWithNoHeaderOptions : WithQueryProviderStar
public override void ConfigureServices(IServiceCollection services)
{
services.AddOptions();
services.AddMvc();
services.AddMvc(options =>
{
options.EnableEndpointRouting = false;
});
services.AddHttpCachingMvc(options => options.DoNotEmitCacheCowHeader = true);
services.AddQueryProviderForViewModelMvc<TestViewModel, TestViewModelQueryProvider>();
services.AddQueryProviderForViewModelMvc<IEnumerable<TestViewModel>, TestViewModelCollectionQueryProvider>();
Expand Down
4 changes: 2 additions & 2 deletions test/CacheCow.Tests/CacheCow.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp3.0;netcoreapp2.0;net452</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp2.0;netcoreapp3.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.0;netcoreapp2.0;net452;net5.0</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp2.0;netcoreapp3.0;net5.0</TargetFrameworks>
<Summary>Client constructs for HTTP Caching</Summary>
<AssemblyName>CacheCow.Tests</AssemblyName>
<PackageId>CacheCow.Tests</PackageId>
Expand Down

0 comments on commit bb0b910

Please sign in to comment.