Skip to content

Commit c4a2632

Browse files
Skip collation of actions that do not have API versioning metadata. Fixes #839
1 parent d87c1b3 commit c4a2632

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/AspNetCore/WebApi/src/Asp.Versioning.Mvc/ApiVersionCollator.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
namespace Asp.Versioning;
44

5+
using Asp.Versioning.ApplicationModels;
56
using Asp.Versioning.Conventions;
67
using Microsoft.AspNetCore.Mvc.Abstractions;
8+
using Microsoft.AspNetCore.Mvc.ApplicationModels;
79
using Microsoft.AspNetCore.Mvc.Controllers;
810
using System.Runtime.CompilerServices;
911
using static Asp.Versioning.ApiVersionMapping;
@@ -102,13 +104,22 @@ protected virtual string GetControllerName( ActionDescriptor action )
102104
return NamingConvention.GroupName( name );
103105
}
104106

107+
[MethodImpl( MethodImplOptions.AggressiveInlining )]
108+
private static bool IsUnversioned( ActionDescriptor action ) => action.GetApiVersionMetadata() == ApiVersionMetadata.Empty;
109+
105110
private IEnumerable<IReadOnlyList<ActionDescriptor>> GroupActionsByController( IList<ActionDescriptor> actions )
106111
{
107112
var groups = new Dictionary<string, List<ActionDescriptor>>( StringComparer.OrdinalIgnoreCase );
108113

109114
for ( var i = 0; i < actions.Count; i++ )
110115
{
111116
var action = actions[i];
117+
118+
if ( IsUnversioned( action ) )
119+
{
120+
continue;
121+
}
122+
112123
var key = GetControllerName( action );
113124

114125
if ( string.IsNullOrEmpty( key ) )

0 commit comments

Comments
 (0)