8
8
using Microsoft . AspNetCore . Mvc . Abstractions ;
9
9
using Microsoft . AspNetCore . Mvc . ActionConstraints ;
10
10
using Microsoft . AspNetCore . Mvc . ApplicationModels ;
11
- using Microsoft . AspNetCore . Mvc . ApplicationParts ;
12
11
using Microsoft . AspNetCore . Mvc . Controllers ;
13
12
using Microsoft . AspNetCore . Mvc . Formatters ;
14
13
using Microsoft . AspNetCore . Mvc . Internal ;
15
14
using Microsoft . AspNetCore . Mvc . ModelBinding ;
16
- using Microsoft . AspNetCore . Mvc . ModelBinding . Metadata ;
17
15
using Microsoft . AspNetCore . Mvc . Routing ;
18
16
using Microsoft . AspNetCore . Routing ;
19
17
using Microsoft . AspNetCore . Routing . Template ;
26
24
using System . Diagnostics . Contracts ;
27
25
using System . Globalization ;
28
26
using System . Linq ;
29
- using System . Reflection ;
30
27
using System . Threading . Tasks ;
31
28
using static Microsoft . AspNet . OData . Routing . ODataRouteActionType ;
32
29
using static Microsoft . AspNetCore . Http . StatusCodes ;
@@ -132,9 +129,9 @@ public ODataApiDescriptionProvider(
132
129
protected MvcOptions MvcOptions { get ; }
133
130
134
131
/// <summary>
135
- /// Gets the order prescendence of the current API description provider.
132
+ /// Gets the order precedence of the current API description provider.
136
133
/// </summary>
137
- /// <value>The order prescendence of the current API description provider. The default value is -100.</value>
134
+ /// <value>The order precedence of the current API description provider. The default value is -100.</value>
138
135
public virtual int Order => AfterApiVersioning ;
139
136
140
137
/// <summary>
@@ -144,10 +141,8 @@ public ODataApiDescriptionProvider(
144
141
/// <remarks>The default implementation performs no action.</remarks>
145
142
public virtual void OnProvidersExecuted ( ApiDescriptionProviderContext context )
146
143
{
147
- var ignoreApiExplorerSettings = ! Options . UseApiExplorerSettings ;
148
144
var mappings = RouteCollectionProvider . Items ;
149
145
var results = context . Results ;
150
-
151
146
var groupNameFormat = Options . GroupNameFormat ;
152
147
var formatProvider = CultureInfo . CurrentCulture ;
153
148
@@ -164,8 +159,9 @@ public virtual void OnProvidersExecuted( ApiDescriptionProviderContext context )
164
159
165
160
if ( model . IsApiVersionNeutral )
166
161
{
167
- foreach ( var mapping in mappings )
162
+ for ( var i = 0 ; i < mappings . Count ; i ++ )
168
163
{
164
+ var mapping = mappings [ i ] ;
169
165
var descriptions = new List < ApiDescription > ( ) ;
170
166
var groupName = mapping . ApiVersion . ToString ( groupNameFormat , formatProvider ) ;
171
167
@@ -183,17 +179,19 @@ public virtual void OnProvidersExecuted( ApiDescriptionProviderContext context )
183
179
}
184
180
else
185
181
{
186
- foreach ( var apiVersion in model . DeclaredApiVersions )
182
+ for ( var i = 0 ; i < model . DeclaredApiVersions . Count ; i ++ )
187
183
{
184
+ var apiVersion = model . DeclaredApiVersions [ i ] ;
188
185
var groupName = apiVersion . ToString ( groupNameFormat , formatProvider ) ;
189
186
190
187
if ( ! mappings . TryGetValue ( apiVersion , out var mappingsPerApiVersion ) )
191
188
{
192
189
continue ;
193
190
}
194
191
195
- foreach ( var mapping in mappingsPerApiVersion )
192
+ for ( var j = 0 ; j < mappingsPerApiVersion . Count ; j ++ )
196
193
{
194
+ var mapping = mappingsPerApiVersion [ j ] ;
197
195
var descriptions = new List < ApiDescription > ( ) ;
198
196
199
197
foreach ( var apiDescription in NewODataApiDescriptions ( action , groupName , mapping ) )
@@ -364,7 +362,7 @@ static string BuildRelativePath( ControllerActionDescriptor action, ODataRouteBu
364
362
365
363
var relativePath = action . AttributeRouteInfo ? . Template ;
366
364
367
- // note: if path happens to be built adhead of time, it's expected to be qualified; rebuild it as necessary
365
+ // note: if path happens to be built ahead of time, it's expected to be qualified; rebuild it as necessary
368
366
if ( string . IsNullOrEmpty ( relativePath ) || ! routeContext . Options . UseQualifiedNames )
369
367
{
370
368
var builder = new ODataRouteBuilder ( routeContext ) ;
@@ -422,14 +420,15 @@ IEnumerable<ApiDescription> NewODataApiDescriptions( ControllerActionDescriptor
422
420
apiDescription . Properties [ typeof ( IEdmOperation ) ] = routeContext . Operation ;
423
421
}
424
422
425
- foreach ( var parameter in parameters )
423
+ for ( var i = 0 ; i < parameters . Count ; i ++ )
426
424
{
425
+ var parameter = parameters [ i ] ;
427
426
apiDescription . ParameterDescriptions . Add ( parameter ) ;
428
427
}
429
428
430
- foreach ( var apiResponseType in apiResponseTypes )
429
+ for ( var i = 0 ; i < apiResponseTypes . Count ; i ++ )
431
430
{
432
- apiDescription . SupportedResponseTypes . Add ( apiResponseType ) ;
431
+ apiDescription . SupportedResponseTypes . Add ( apiResponseTypes [ i ] ) ;
433
432
}
434
433
435
434
PopulateApiVersionParameters ( apiDescription , mapping . ApiVersion ) ;
@@ -445,8 +444,9 @@ IList<ApiParameterDescription> GetParameters( ApiParameterContext context )
445
444
446
445
if ( action . Parameters != null )
447
446
{
448
- foreach ( var actionParameter in action . Parameters )
447
+ for ( var i = 0 ; i < action . Parameters . Count ; i ++ )
449
448
{
449
+ var actionParameter = action . Parameters [ i ] ;
450
450
var metadata = MetadataProvider . GetMetadataForType ( actionParameter . ParameterType ) ;
451
451
452
452
UpdateBindingInfo ( context , actionParameter , metadata ) ;
@@ -460,8 +460,9 @@ IList<ApiParameterDescription> GetParameters( ApiParameterContext context )
460
460
461
461
if ( action . BoundProperties != null )
462
462
{
463
- foreach ( var actionParameter in action . BoundProperties )
463
+ for ( var i = 0 ; i < action . BoundProperties . Count ; i ++ )
464
464
{
465
+ var actionParameter = action . BoundProperties [ i ] ;
465
466
var visitor = new PseudoModelBindingVisitor ( context , actionParameter ) ;
466
467
var modelMetadata = context . MetadataProvider . GetMetadataForProperty (
467
468
containerType : action . ControllerTypeInfo . AsType ( ) ,
0 commit comments