Skip to content

Commit 9bc23c6

Browse files
Chris Martinezcommonsensesoftware
Chris Martinez
authored andcommitted
IApiVersionNeutral should be inherited from attributes
1 parent 1df603a commit 9bc23c6

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/Microsoft.AspNet.WebApi.Versioning/Versioning/Conventions/ActionApiVersionConventionBuilderBase.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace Microsoft.Web.Http.Versioning.Conventions
22
{
33
using System;
4+
using System.Collections.Generic;
45
using System.Linq;
56
using System.Web.Http;
67
using System.Web.Http.Controllers;
@@ -20,7 +21,11 @@ public virtual void ApplyTo( HttpActionDescriptor actionDescriptor )
2021
{
2122
Arg.NotNull( actionDescriptor, nameof( actionDescriptor ) );
2223

23-
MergeAttributesWithConventions( actionDescriptor.GetCustomAttributes<Attribute>() );
24+
var attributes = new List<object>();
25+
26+
attributes.AddRange( actionDescriptor.GetCustomAttributes<IApiVersionNeutral>( inherit: true ) );
27+
attributes.AddRange( actionDescriptor.GetCustomAttributes<IApiVersionProvider>( inherit: false ) );
28+
MergeAttributesWithConventions( attributes );
2429

2530
if ( VersionNeutral )
2631
{

src/Microsoft.AspNet.WebApi.Versioning/Versioning/Conventions/ControllerApiVersionConventionBuilderBase.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ public virtual void ApplyTo( HttpControllerDescriptor controllerDescriptor )
2828
{
2929
Arg.NotNull( controllerDescriptor, nameof( controllerDescriptor ) );
3030

31-
MergeAttributesWithConventions( controllerDescriptor.GetCustomAttributes<Attribute>() );
31+
var attributes = new List<object>();
32+
33+
attributes.AddRange( controllerDescriptor.GetCustomAttributes<IApiVersionNeutral>( inherit: true ) );
34+
attributes.AddRange( controllerDescriptor.GetCustomAttributes<IApiVersionProvider>( inherit: false ) );
35+
MergeAttributesWithConventions( attributes );
3236
ApplyActionConventions( controllerDescriptor );
3337
}
3438

0 commit comments

Comments
 (0)