Skip to content

Commit 699d4c6

Browse files
committed
update with code review feedbacks and nuget building fixes
update with code review feedbacks and nuget building fixes
1 parent d9add85 commit 699d4c6

12 files changed

Lines changed: 60 additions & 63 deletions

File tree

src/CustomOutputCacheProvider/Microsoft.AspNet.OutputCache.CustomOutputCacheProvider.csproj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory),Microsoft.AspNet.OutputCache.sln))\tools\MicrosoftAspNetOutputCache.settings.targets" />
45
<PropertyGroup>
56
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
67
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,26 +10,27 @@
910
<AppDesignerFolder>Properties</AppDesignerFolder>
1011
<RootNamespace>Microsoft.AspNet.OutputCache.CustomOutputCacheProvider</RootNamespace>
1112
<AssemblyName>Microsoft.AspNet.OutputCache.CustomOutputCacheProvider</AssemblyName>
12-
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
13+
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
1314
<FileAlignment>512</FileAlignment>
1415
<SccProjectName>SAK</SccProjectName>
1516
<SccLocalPath>SAK</SccLocalPath>
1617
<SccAuxPath>SAK</SccAuxPath>
1718
<SccProvider>SAK</SccProvider>
19+
<DocumentationFile>$(OutputPath)$(AssemblyName).xml</DocumentationFile>
20+
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
21+
<TargetFrameworkProfile />
1822
</PropertyGroup>
1923
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2024
<DebugSymbols>true</DebugSymbols>
2125
<DebugType>full</DebugType>
2226
<Optimize>false</Optimize>
23-
<OutputPath>bin\Debug\</OutputPath>
2427
<DefineConstants>DEBUG;TRACE</DefineConstants>
2528
<ErrorReport>prompt</ErrorReport>
2629
<WarningLevel>4</WarningLevel>
2730
</PropertyGroup>
2831
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2932
<DebugType>pdbonly</DebugType>
3033
<Optimize>true</Optimize>
31-
<OutputPath>bin\Release\</OutputPath>
3234
<DefineConstants>TRACE</DefineConstants>
3335
<ErrorReport>prompt</ErrorReport>
3436
<WarningLevel>4</WarningLevel>

src/CustomOutputCacheProvider/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,3 @@
2121

2222
// The following GUID is for the ID of the typelib if this project is exposed to COM
2323
[assembly: Guid("a8f3e399-bcaf-4f3e-bc16-5ca98a779916")]
24-
25-
// Version information for an assembly consists of the following four values:
26-
//
27-
// Major Version
28-
// Minor Version
29-
// Build Number
30-
// Revision
31-
//
32-
// You can specify all the values or you can default the Build and Revision Numbers
33-
// by using the '*' as shown below:
34-
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.0.0")]
36-
[assembly: AssemblyFileVersion("1.0.0.0")]

src/OutputCacheModuleAsync/InMemoryOutputCacheProvider.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public override Task<object> AddAsync(string key, object entry, DateTime utcExpi
1616
}
1717

1818
public override Task SetAsync(string key, object entry, DateTime utcExpiry) {
19-
return Task.Run(() => Set(key, entry, utcExpiry));
19+
return Task.Run(() => Set(key, entry, utcExpiry));
2020
}
2121

2222
public override Task RemoveAsync(string key) {
@@ -28,15 +28,17 @@ public override object Get(string key) {
2828
}
2929

3030
public override object Add(string key, object entry, DateTime utcExpiry) {
31-
return _cache.Add(key, entry, utcExpiry) ? entry : null;
31+
DateTimeOffset expiration = (utcExpiry == Cache.NoAbsoluteExpiration) ? ObjectCache.InfiniteAbsoluteExpiration : utcExpiry;
32+
return _cache.Add(key, entry, expiration) ? entry : null;
3233
}
3334

3435
public void Add(string depKey, DependencyCacheEntryWrapper dcew, DateTimeOffset dateTimeOffsetValue) {
3536
_cache.Add(depKey, dcew, dateTimeOffsetValue);
3637
}
3738

3839
public override void Set(string key, object entry, DateTime utcExpiry) {
39-
_cache.Set(key, entry, utcExpiry);
40+
DateTimeOffset expiration = (utcExpiry == Cache.NoAbsoluteExpiration) ? ObjectCache.InfiniteAbsoluteExpiration : utcExpiry;
41+
_cache.Set(key, entry, expiration);
4042
}
4143

4244
public override void Remove(string key) {

src/OutputCacheModuleAsync/Microsoft.AspNet.OutputCache.OutputCacheModuleAsync.csproj

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory),Microsoft.AspNet.OutputCache.sln))\tools\MicrosoftAspNetOutputCache.settings.targets" />
45
<PropertyGroup>
56
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
67
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
78
<ProjectGuid>{3B446E33-7B1C-4A32-AEB8-92DC6CE94F77}</ProjectGuid>
89
<OutputType>Library</OutputType>
910
<AppDesignerFolder>Properties</AppDesignerFolder>
1011
<RootNamespace>Microsoft.AspNet.OutputCache</RootNamespace>
11-
<AssemblyName>Microsoft.AspNet.OutputCache.OutputCacheProviderAsync</AssemblyName>
12-
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
12+
<AssemblyName>Microsoft.AspNet.OutputCache.OutputCacheModuleAsync</AssemblyName>
13+
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
1314
<FileAlignment>512</FileAlignment>
1415
<SccProjectName>SAK</SccProjectName>
1516
<SccLocalPath>SAK</SccLocalPath>
1617
<SccAuxPath>SAK</SccAuxPath>
1718
<SccProvider>SAK</SccProvider>
19+
<DocumentationFile>$(OutputPath)$(AssemblyName).xml</DocumentationFile>
20+
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
21+
<TargetFrameworkProfile />
1822
</PropertyGroup>
1923
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2024
<DebugSymbols>true</DebugSymbols>
2125
<DebugType>full</DebugType>
2226
<Optimize>false</Optimize>
23-
<OutputPath>bin\Debug\</OutputPath>
2427
<DefineConstants>DEBUG;TRACE</DefineConstants>
2528
<ErrorReport>prompt</ErrorReport>
2629
<WarningLevel>4</WarningLevel>
2730
</PropertyGroup>
2831
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2932
<DebugType>pdbonly</DebugType>
3033
<Optimize>true</Optimize>
31-
<OutputPath>bin\Release\</OutputPath>
3234
<DefineConstants>TRACE</DefineConstants>
3335
<ErrorReport>prompt</ErrorReport>
3436
<WarningLevel>4</WarningLevel>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace Microsoft.AspNet.OutputCache {
2+
using System;
3+
using System.Collections;
4+
using System.Collections.Specialized;
5+
6+
internal class OutputCacheEntry {
7+
public Guid CachedVaryId { get; set; }
8+
public HttpCachePolicySettings Settings { get; set; }
9+
public string KernelCacheUrl { get; set; }
10+
public string DependenciesKey { get; set; }
11+
public string[] Dependencies { get; set; }
12+
public int StatusCode { get; set; }
13+
public string StatusDescription { get; set; }
14+
public NameValueCollection HeaderElements { get; set; }
15+
public ArrayList ResponseElements { get; set; }
16+
}
17+
}

src/OutputCacheModuleAsync/OutputCacheHelper.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
using System.Collections.Generic;
2-
using System.Linq;
3-
4-
namespace Microsoft.AspNet.OutputCache {
1+
namespace Microsoft.AspNet.OutputCache {
2+
using System.Collections.Generic;
3+
using System.Linq;
54
using System;
65
using System.Threading.Tasks;
76
using System.Web.Caching;
@@ -281,6 +280,7 @@ public static void UseSnapshot(HttpRawResponse rawResponse, bool sendBody, HttpR
281280
if (response.HeadersWritten)
282281
throw new HttpException("Cannot_use_snapshot_after_headers_sent");
283282
response.Clear();
283+
response.ClearHeaders();
284284
// restore status
285285
response.StatusCode = rawResponse.StatusCode;
286286
response.StatusDescription = rawResponse.StatusDescription;
@@ -388,7 +388,7 @@ public static void UpdateCachedHeaders(HttpResponse response) {
388388
}
389389
}
390390

391-
public static async Task<string> CreateOutputCachedItemKey(
391+
public static async Task<string> CreateOutputCachedItemKeyAsync(
392392
string path,
393393
string verb,
394394
HttpContext context,
@@ -522,9 +522,9 @@ public static async Task<string> CreateOutputCachedItemKey(
522522
* and form posted data.
523523
*/
524524

525-
public static async Task<string> CreateOutputCachedItemKey(HttpContext context, CachedVary cachedVary) {
525+
public static async Task<string> CreateOutputCachedItemKeyAsync(HttpContext context, CachedVary cachedVary) {
526526
return
527-
await CreateOutputCachedItemKey(context.Request.Path, context.Request.HttpMethod, context, cachedVary);
527+
await CreateOutputCachedItemKeyAsync(context.Request.Path, context.Request.HttpMethod, context, cachedVary);
528528
}
529529

530530
/*
@@ -666,7 +666,7 @@ private static double ParseWeight(string acceptEncoding, int startIndex) {
666666
if (double.TryParse(s, NumberStyles.Float & ~NumberStyles.AllowLeadingSign & ~NumberStyles.AllowExponent,
667667
CultureInfo.InvariantCulture, out d)) {
668668
weight = (d >= 0 && d <= 1) ? d : 1;
669-
// if format is invalid, short-circut search by returning weight of 1
669+
// if format is invalid, short-circut search by returning weight of 1
670670
}
671671
return weight;
672672
}

src/OutputCacheModuleAsync/OutputCacheModuleAsync.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,22 @@ void IHttpModule.Init(HttpApplication app) {
3030
public void Dispose() {}
3131

3232
private IAsyncResult BeginOnResolveRequestCache(object source, EventArgs e, AsyncCallback cb, object extraData) {
33-
return TaskAsyncHelper.BeginTask(() => OnEnter(source, e), cb, extraData);
33+
return TaskAsyncHelper.BeginTask(() => OnEnterAsync(source, e), cb, extraData);
3434
}
3535

3636
private static void EndOnResolveRequestCache(IAsyncResult result) {
3737
TaskAsyncHelper.EndTask(result);
3838
}
3939

4040
private IAsyncResult BeginOnUpdateRequestCache(object source, EventArgs e, AsyncCallback cb, object extraData) {
41-
return TaskAsyncHelper.BeginTask(() => OnLeave(source, e), cb, extraData);
41+
return TaskAsyncHelper.BeginTask(() => OnLeaveAsync(source, e), cb, extraData);
4242
}
4343

4444
private static void EndOnUpdateRequestCache(IAsyncResult result) {
4545
TaskAsyncHelper.EndTask(result);
4646
}
4747

48-
private async Task OnEnter(object source, EventArgs eventArgs) {
48+
private async Task OnEnterAsync(object source, EventArgs eventArgs) {
4949
var app = (HttpApplication) source;
5050
HttpContext context = app.Context;
5151
HttpRequest request = context.Request;
@@ -56,7 +56,7 @@ private async Task OnEnter(object source, EventArgs eventArgs) {
5656
}
5757

5858
// Create a lookup key. Also store the key in global parameter _key to be used inside OnLeave() later
59-
string key = _key = await OutputCacheHelper.CreateOutputCachedItemKey(context, null);
59+
string key = _key = await OutputCacheHelper.CreateOutputCachedItemKeyAsync(context, null);
6060

6161
// Lookup the cache vary using the key
6262
object item = await _outputCacheHelper.Get(key);
@@ -98,7 +98,7 @@ private async Task OnEnter(object source, EventArgs eventArgs) {
9898
app.CompleteRequest();
9999
}
100100

101-
private async Task OnLeave(object source, EventArgs eventArgs) {
101+
private async Task OnLeaveAsync(object source, EventArgs eventArgs) {
102102
HttpContext context = ((HttpApplication) source).Context;
103103
HttpRequest request = context.Request;
104104
HttpResponse response = context.Response;
@@ -172,7 +172,7 @@ private async Task CacheResponse(HttpContext context, HttpResponse response) {
172172
string[] varyByParams = settings.IgnoreParams ? null : settings.VaryByParams;
173173
/* Create the key if it was not created in OnEnter */
174174
if (_key == null) {
175-
_key = await OutputCacheHelper.CreateOutputCachedItemKey(context, null);
175+
_key = await OutputCacheHelper.CreateOutputCachedItemKeyAsync(context, null);
176176
Debug.Assert(_key != null, "_key != null");
177177
}
178178
if (settings.VaryByContentEncodings == null && varyByHeaders == null && varyByParams == null &&
@@ -215,7 +215,7 @@ private async Task CacheResponse(HttpContext context, HttpResponse response) {
215215
VaryByAllParams = varyByAllParams,
216216
VaryByCustom = settings.VaryByCustom
217217
};
218-
keyRawResponse = await OutputCacheHelper.CreateOutputCachedItemKey(context, cachedVary);
218+
keyRawResponse = await OutputCacheHelper.CreateOutputCachedItemKeyAsync(context, cachedVary);
219219
if (keyRawResponse == null) {
220220
Debug.WriteLine("OutputCacheModuleLeave", "Couldn't add non-cacheable post.\n\tkey=" + _key);
221221
return;
@@ -327,6 +327,9 @@ private static void GetCachedResponse(HttpContext context, HttpRequest request,
327327
*/
328328
Debug.WriteLine("OutputCacheModuleEnter", "Hit, conditional request satisfied, status=304. Key=" + key +
329329
". Returning from OutputCacheModule::Enter");
330+
if (response.HeadersWritten) {
331+
response.ClearHeaders();
332+
}
330333
response.Clear();
331334
response.StatusCode = 304;
332335
}
@@ -361,14 +364,14 @@ private async Task<bool> CheckHeadersToDetermineAcceptCachedCopy(string key, Htt
361364
string[] cacheDirectives = request.Headers["Cache-Control"].Split(s_fieldSeparators);
362365
foreach (string directive in cacheDirectives) {
363366
if (directive == "no-cache" || directive == "no-store") {
364-
Debug.WriteLine("OutputCacheModuleEnter",
367+
Debug.WriteLine("OutputCache Module Async Enter",
365368
"Skipping lookup because of Cache-Control: no-cache or no-store directive. Returning from OutputCacheModule::Enter");
366369
return true;
367370
}
368371
if (directive.StartsWith("max-age=")) {
369372
int maxage;
370373
try {
371-
maxage = Convert.ToInt32(directive.Substring(8), CultureInfo.InvariantCulture);
374+
int.TryParse(directive.Substring(8), out maxage);
372375
}
373376
catch {
374377
maxage = -1;
@@ -494,7 +497,7 @@ private async Task<CachedItem> CheckCacheVaryAsync(CachedVary cachedVary, HttpCo
494497
*
495498
* Skip this step if it's a VaryByNone vary policy.
496499
*/
497-
string key = await OutputCacheHelper.CreateOutputCachedItemKey(context, cachedVary);
500+
string key = await OutputCacheHelper.CreateOutputCachedItemKeyAsync(context, cachedVary);
498501
if (key == null) {
499502
Debug.WriteLine("OutputCacheModuleEnter",
500503
"Miss, key could not be created for vary-by item. Returning from OutputCacheModule::Enter");

src/OutputCacheModuleAsync/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,3 @@
2222
// The following GUID is for the ID of the typelib if this project is exposed to COM
2323
[assembly: Guid("3b446e33-7b1c-4a32-aeb8-92dc6ce94f77")]
2424

25-
// Version information for an assembly consists of the following four values:
26-
//
27-
// Major Version
28-
// Minor Version
29-
// Build Number
30-
// Revision
31-
//
32-
// You can specify all the values or you can default the Build and Revision Numbers
33-
// by using the '*' as shown below:
34-
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.0.0")]
36-
[assembly: AssemblyFileVersion("1.0.0.0")]

src/packages/OutputCacheModuleAsync.nupkg/content/Net462/web.config.install.xdt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<modules>
1111
<remove name="OutputCache" xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)" />
1212
<add name="OutputCache"
13-
type="Microsoft.AspNet.OutputCache.OutputCacheModuleAsync, Microsoft.AspNet.OutputCache"
13+
type="Microsoft.AspNet.OutputCache.OutputCacheModuleAsync, Microsoft.AspNet.OutputCache.OutputCacheModuleAsync"
1414
preCondition="integratedMode" xdt:Transform="Insert" />
1515
</modules>
1616
</system.webServer>

src/packages/OutputCacheModuleAsync.nupkg/content/Net462/web.config.uninstall.xdt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
33

44
<system.webServer>
5-
<modules>
6-
<remove name="OutputCache" xdt:Transform="Remove" xdt:Locator="Match(name)" />
7-
<add name="OutputCache"
8-
type="Microsoft.AspNet.OutputCache.OutputCacheModuleAsync, Microsoft.AspNet.OutputCache"
5+
<modules>
6+
<remove name="OutputCache" xdt:Transform="Remove" xdt:Locator="Match(name)" />
7+
<add name="OutputCache"
8+
type="Microsoft.AspNet.OutputCache.OutputCacheModuleAsync, Microsoft.AspNet.OutputCache.OutputCacheModuleAsync"
99
preCondition="integratedMode" xdt:Transform="Remove" xdt:Locator="Match(type)" />
1010
</modules>
1111
</system.webServer>

0 commit comments

Comments
 (0)