diff --git a/src/Microsoft.AspNetCore.Mvc.Core/ProducesAttribute.cs b/src/Microsoft.AspNetCore.Mvc.Core/ProducesAttribute.cs
index 2bb580b5a6..6c89fc036d 100644
--- a/src/Microsoft.AspNetCore.Mvc.Core/ProducesAttribute.cs
+++ b/src/Microsoft.AspNetCore.Mvc.Core/ProducesAttribute.cs
@@ -19,7 +19,7 @@ namespace Microsoft.AspNetCore.Mvc
/// .
///
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
- public class ProducesAttribute : ResultFilterAttribute, IApiResponseMetadataProvider
+ public class ProducesAttribute : Attribute, IResultFilter, IOrderedFilter, IApiResponseMetadataProvider
{
///
/// Initializes an instance of .
@@ -72,14 +72,16 @@ namespace Microsoft.AspNetCore.Mvc
public int StatusCode => StatusCodes.Status200OK;
///
- public override void OnResultExecuting(ResultExecutingContext context)
+ public int Order { get; set; }
+
+ ///
+ public virtual void OnResultExecuting(ResultExecutingContext context)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}
- base.OnResultExecuting(context);
var objectResult = context.Result as ObjectResult;
if (objectResult != null)
@@ -100,6 +102,21 @@ namespace Microsoft.AspNetCore.Mvc
}
}
+ ///
+ public virtual void OnResultExecuted(ResultExecutedContext context)
+ {
+ }
+
+ ///
+ public void SetContentTypes(MediaTypeCollection contentTypes)
+ {
+ contentTypes.Clear();
+ foreach (var contentType in ContentTypes)
+ {
+ contentTypes.Add(contentType);
+ }
+ }
+
private MediaTypeCollection GetContentTypes(string firstArg, string[] args)
{
var completeArgs = new List();
@@ -121,15 +138,5 @@ namespace Microsoft.AspNetCore.Mvc
return contentTypes;
}
-
- ///
- public void SetContentTypes(MediaTypeCollection contentTypes)
- {
- contentTypes.Clear();
- foreach (var contentType in ContentTypes)
- {
- contentTypes.Add(contentType);
- }
- }
}
}
diff --git a/src/Microsoft.AspNetCore.Mvc.Core/exceptions.net45.json b/src/Microsoft.AspNetCore.Mvc.Core/exceptions.net45.json
new file mode 100644
index 0000000000..5e4e55a0be
--- /dev/null
+++ b/src/Microsoft.AspNetCore.Mvc.Core/exceptions.net45.json
@@ -0,0 +1,6 @@
+[
+ {
+ "OldTypeId": "public class Microsoft.AspNetCore.Mvc.ProducesAttribute : Microsoft.AspNetCore.Mvc.Filters.ResultFilterAttribute, Microsoft.AspNetCore.Mvc.ApiExplorer.IApiResponseMetadataProvider",
+ "Kind": "Removal"
+ }
+]
\ No newline at end of file
diff --git a/src/Microsoft.AspNetCore.Mvc.Core/exceptions.netcore.json b/src/Microsoft.AspNetCore.Mvc.Core/exceptions.netcore.json
new file mode 100644
index 0000000000..5e4e55a0be
--- /dev/null
+++ b/src/Microsoft.AspNetCore.Mvc.Core/exceptions.netcore.json
@@ -0,0 +1,6 @@
+[
+ {
+ "OldTypeId": "public class Microsoft.AspNetCore.Mvc.ProducesAttribute : Microsoft.AspNetCore.Mvc.Filters.ResultFilterAttribute, Microsoft.AspNetCore.Mvc.ApiExplorer.IApiResponseMetadataProvider",
+ "Kind": "Removal"
+ }
+]
\ No newline at end of file
diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/ProducesAttributeTests.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/ProducesAttributeTests.cs
index 8ae4563270..44dc11e471 100644
--- a/test/Microsoft.AspNetCore.Mvc.Core.Test/ProducesAttributeTests.cs
+++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/ProducesAttributeTests.cs
@@ -19,7 +19,7 @@ namespace Microsoft.AspNetCore.Mvc.Test
public class ProducesAttributeTests
{
[Fact]
- public async Task ProducesAttribute_SetsContentType()
+ public void ProducesAttribute_SetsContentType()
{
// Arrange
var mediaType1 = new StringSegment("application/json");
@@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Mvc.Test
() => Task.FromResult(CreateResultExecutedContext(resultExecutingContext)));
// Act
- await producesContentAttribute.OnResultExecutionAsync(resultExecutingContext, next);
+ producesContentAttribute.OnResultExecuting(resultExecutingContext);
// Assert
var objectResult = resultExecutingContext.Result as ObjectResult;
@@ -40,7 +40,7 @@ namespace Microsoft.AspNetCore.Mvc.Test
}
[Fact]
- public async Task ProducesContentAttribute_FormatFilterAttribute_NotActive()
+ public void ProducesContentAttribute_FormatFilterAttribute_NotActive()
{
// Arrange
var producesContentAttribute = new ProducesAttribute("application/xml");
@@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.Mvc.Test
() => Task.FromResult(CreateResultExecutedContext(resultExecutingContext)));
// Act
- await producesContentAttribute.OnResultExecutionAsync(resultExecutingContext, next);
+ producesContentAttribute.OnResultExecuting(resultExecutingContext);
// Assert
var objectResult = Assert.IsType(resultExecutingContext.Result);
@@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.Mvc.Test
}
[Fact]
- public async Task ProducesContentAttribute_FormatFilterAttribute_Active()
+ public void ProducesContentAttribute_FormatFilterAttribute_Active()
{
// Arrange
var producesContentAttribute = new ProducesAttribute("application/xml");
@@ -82,7 +82,7 @@ namespace Microsoft.AspNetCore.Mvc.Test
() => Task.FromResult(CreateResultExecutedContext(resultExecutingContext)));
// Act
- await producesContentAttribute.OnResultExecutionAsync(resultExecutingContext, next);
+ producesContentAttribute.OnResultExecuting(resultExecutingContext);
// Assert
var objectResult = Assert.IsType(resultExecutingContext.Result);