Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Commit fd201f9

Browse files
committed
Moving out the cancellation token. List->IList
1 parent bcd1e25 commit fd201f9

File tree

7 files changed

+29
-23
lines changed

7 files changed

+29
-23
lines changed

Mvc.sln

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
4-
VisualStudioVersion = 14.0.21901.1
5-
VisualStudioVersion = 14.0.21806.0
4+
VisualStudioVersion = 14.0.21916.0
65
MinimumVisualStudioVersion = 10.0.40219.1
76
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{DAAE4C74-D06F-4874-A166-33305D2643CE}"
87
EndProject
@@ -55,10 +54,13 @@ EndProject
5554
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "RazorWebSite", "test\WebSites\RazorWebSite\RazorWebSite.kproj", "{B07CAF59-11ED-40E3-A5DB-E1178F84FA78}"
5655
EndProject
5756
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ValueProvidersSite", "test\WebSites\ValueProvidersSite\ValueProvidersSite.kproj", "{14F79E79-AE79-48FA-95DE-D794EF4EABB3}"
57+
EndProject
5858
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.HeaderValueAbstractions", "src\Microsoft.AspNet.Mvc.HeaderValueAbstractions\Microsoft.AspNet.Mvc.HeaderValueAbstractions.kproj", "{98335B23-E4B9-4CAD-9749-0DED32A659A1}"
5959
EndProject
6060
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.HeaderValueAbstractions.Tests", "test\Microsoft.AspNet.Mvc.HeaderValueAbstractions.Test\Microsoft.AspNet.Mvc.HeaderValueAbstractions.Tests.kproj", "{E69FD235-2042-43A4-9970-59CB29955B4E}"
6161
EndProject
62+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ConnegWebsite", "test\WebSites\ConnegWebSite\ConnegWebsite.kproj", "{C6E5AFFA-890A-448F-8DE3-878B1D3C9FC7}"
63+
EndProject
6264
Global
6365
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6466
Debug|Any CPU = Debug|Any CPU
@@ -309,6 +311,16 @@ Global
309311
{E69FD235-2042-43A4-9970-59CB29955B4E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
310312
{E69FD235-2042-43A4-9970-59CB29955B4E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
311313
{E69FD235-2042-43A4-9970-59CB29955B4E}.Release|x86.ActiveCfg = Release|Any CPU
314+
{C6E5AFFA-890A-448F-8DE3-878B1D3C9FC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
315+
{C6E5AFFA-890A-448F-8DE3-878B1D3C9FC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
316+
{C6E5AFFA-890A-448F-8DE3-878B1D3C9FC7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
317+
{C6E5AFFA-890A-448F-8DE3-878B1D3C9FC7}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
318+
{C6E5AFFA-890A-448F-8DE3-878B1D3C9FC7}.Debug|x86.ActiveCfg = Debug|Any CPU
319+
{C6E5AFFA-890A-448F-8DE3-878B1D3C9FC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
320+
{C6E5AFFA-890A-448F-8DE3-878B1D3C9FC7}.Release|Any CPU.Build.0 = Release|Any CPU
321+
{C6E5AFFA-890A-448F-8DE3-878B1D3C9FC7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
322+
{C6E5AFFA-890A-448F-8DE3-878B1D3C9FC7}.Release|Mixed Platforms.Build.0 = Release|Any CPU
323+
{C6E5AFFA-890A-448F-8DE3-878B1D3C9FC7}.Release|x86.ActiveCfg = Release|Any CPU
312324
EndGlobalSection
313325
GlobalSection(SolutionProperties) = preSolution
314326
HideSolutionNode = FALSE
@@ -339,5 +351,6 @@ Global
339351
{14F79E79-AE79-48FA-95DE-D794EF4EABB3} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
340352
{98335B23-E4B9-4CAD-9749-0DED32A659A1} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E}
341353
{E69FD235-2042-43A4-9970-59CB29955B4E} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
354+
{C6E5AFFA-890A-448F-8DE3-878B1D3C9FC7} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
342355
EndGlobalSection
343356
EndGlobal

src/Microsoft.AspNet.Mvc.Core/ActionResults/ObjectResult.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ public override async Task ExecuteResultAsync(ActionContext context)
4747
return;
4848
}
4949

50-
await selectedFormatter.WriteAsync(formatterContext,
51-
formatterContext.ActionContext.HttpContext.RequestAborted);
50+
await selectedFormatter.WriteAsync(formatterContext);
5251
}
5352

5453
public virtual IOutputFormatter SelectFormatter(OutputFormatterContext formatterContext,

src/Microsoft.AspNet.Mvc.Core/Formatters/IOutputFormatter.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ public interface IOutputFormatter
3434
/// Writes the object represented by <paramref name="context"/>'s Object property.
3535
/// </summary>
3636
/// <param name="context">The formatter context associated with the call.</param>
37-
/// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
3837
/// <returns>A Task that serializes the value to the <paramref name="context"/>'s response message.</returns>
39-
Task WriteAsync(OutputFormatterContext context, CancellationToken cancellationToken);
38+
Task WriteAsync(OutputFormatterContext context);
4039
}
4140
}

src/Microsoft.AspNet.Mvc.Core/Formatters/JsonOutputFormatter.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,8 @@ private JsonSerializer CreateJsonSerializer()
7373
return jsonSerializer;
7474
}
7575

76-
public override Task WriteResponseBodyAsync(OutputFormatterContext context,
77-
CancellationToken cancellationToken)
76+
public override Task WriteResponseBodyAsync(OutputFormatterContext context)
7877
{
79-
cancellationToken.ThrowIfCancellationRequested();
8078
var response = context.ActionContext.HttpContext.Response;
8179
var selectedEncoding = context.SelectedEncoding;
8280
using (var writer = new StreamWriter(response.Body, selectedEncoding, 1024, leaveOpen: true))

src/Microsoft.AspNet.Mvc.Core/Formatters/OutputFormatter.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ public abstract class OutputFormatter : IOutputFormatter
2222
/// this <see cref="OutputFormatter"/> instance. The encodings are
2323
/// used when writing the data.
2424
/// </summary>
25-
public List<Encoding> SupportedEncodings { get; private set; }
25+
public IList<Encoding> SupportedEncodings { get; private set; }
2626

2727
/// <summary>
2828
/// Gets the mutable collection of <see cref="MediaTypeHeaderValue"/> elements supported by
2929
/// this <see cref="OutputFormatter"/> instance.
3030
/// </summary>
31-
public List<MediaTypeHeaderValue> SupportedMediaTypes { get; private set; }
31+
public IList<MediaTypeHeaderValue> SupportedMediaTypes { get; private set; }
3232

3333
/// <summary>
3434
/// Initializes a new instance of the <see cref="OutputFormatter"/> class.
@@ -95,11 +95,10 @@ public virtual bool CanWriteResult(OutputFormatterContext context, MediaTypeHead
9595
}
9696

9797
/// <inheritdoc />
98-
public async Task WriteAsync(OutputFormatterContext context, CancellationToken cancellationToken)
98+
public async Task WriteAsync(OutputFormatterContext context)
9999
{
100-
cancellationToken.ThrowIfCancellationRequested();
101100
WriteResponseContentHeaders(context);
102-
await WriteResponseBodyAsync(context, cancellationToken);
101+
await WriteResponseBodyAsync(context);
103102
}
104103

105104
/// <summary>
@@ -136,10 +135,8 @@ public virtual void WriteResponseContentHeaders(OutputFormatterContext context)
136135
/// Writes the response body.
137136
/// </summary>
138137
/// <param name="context">The formatter context associated with the call.</param>
139-
/// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
140-
/// <returns></returns>
141-
public abstract Task WriteResponseBodyAsync(OutputFormatterContext context,
142-
CancellationToken cancellationToken);
138+
/// <returns>A task which can write the response body.</returns>
139+
public abstract Task WriteResponseBodyAsync(OutputFormatterContext context);
143140

144141
private Encoding MatchAcceptCharacterEncoding(string acceptCharsetHeader)
145142
{

test/Microsoft.AspNet.Mvc.Core.Test/ActionResults/ObjectContentResultTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public async Task ObjectResult_MultipleFormattersSupportingTheSameContentType_Se
187187

188188
// Assert
189189
// Verify that mock formatter was chosen.
190-
mockFormatter.Verify(o => o.WriteAsync(It.IsAny<OutputFormatterContext>(), CancellationToken.None));
190+
mockFormatter.Verify(o => o.WriteAsync(It.IsAny<OutputFormatterContext>()));
191191
}
192192

193193
[Fact]
@@ -364,7 +364,7 @@ public async Task ObjectResult_Execute_CallsJsonResult_SetsContent()
364364
};
365365
var formatter = new JsonOutputFormatter(JsonOutputFormatter.CreateDefaultSettings(), true);
366366
formatter.WriteResponseContentHeaders(formatterContext);
367-
await formatter.WriteAsync(formatterContext, CancellationToken.None);
367+
await formatter.WriteAsync(formatterContext);
368368

369369
// Act
370370
var result = new ObjectResult(nonStringValue);
@@ -418,7 +418,7 @@ private static Mock<CannotWriteFormatter> GetMockFormatter()
418418
It.IsAny<MediaTypeHeaderValue>()))
419419
.Returns(true);
420420

421-
mockFormatter.Setup(o => o.WriteAsync(It.IsAny<OutputFormatterContext>(), CancellationToken.None))
421+
mockFormatter.Setup(o => o.WriteAsync(It.IsAny<OutputFormatterContext>()))
422422
.Returns(Task.FromResult<bool>(true))
423423
.Verifiable();
424424
return mockFormatter;
@@ -460,7 +460,7 @@ public virtual bool CanWriteResult(OutputFormatterContext context, MediaTypeHead
460460
return false;
461461
}
462462

463-
public virtual Task WriteAsync(OutputFormatterContext context, CancellationToken cancellationToken)
463+
public virtual Task WriteAsync(OutputFormatterContext context)
464464
{
465465
throw new NotImplementedException();
466466
}

test/Microsoft.AspNet.Mvc.Core.Test/Formatters/OutputFormatterTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public TestOutputFormatter()
103103
SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/acceptCharset"));
104104
}
105105

106-
public override Task WriteResponseBodyAsync(OutputFormatterContext context, CancellationToken token)
106+
public override Task WriteResponseBodyAsync(OutputFormatterContext context)
107107
{
108108
return Task.FromResult(true);
109109
}

0 commit comments

Comments
 (0)