@@ -23,7 +23,7 @@ namespace Asp.Versioning.ApiExplorer;
2323[ CLSCompliant ( false ) ]
2424public class PartialODataDescriptionProvider : IApiDescriptionProvider
2525{
26- private static int ? beforeOData ;
26+ private static readonly int BeforeOData = ODataOrder ( ) + 10 ;
2727 private readonly IOptionsFactory < ODataOptions > odataOptionsFactory ;
2828 private readonly IOptions < ODataApiExplorerOptions > options ;
2929 private bool markedAdHoc ;
@@ -42,8 +42,6 @@ public PartialODataDescriptionProvider(
4242 {
4343 this . odataOptionsFactory = odataOptionsFactory ?? throw new ArgumentNullException ( nameof ( odataOptionsFactory ) ) ;
4444 this . options = options ?? throw new ArgumentNullException ( nameof ( options ) ) ;
45- beforeOData ??= ODataOrder ( odataOptionsFactory , options ) + 10 ;
46- Order = beforeOData . Value ;
4745 }
4846
4947 /// <summary>
@@ -84,7 +82,7 @@ protected ODataApiExplorerOptions Options
8482 /// Gets or sets the order precedence of the current API description provider.
8583 /// </summary>
8684 /// <value>The order precedence of the current API description provider.</value>
87- public int Order { get ; protected set ; }
85+ public int Order { get ; protected set ; } = BeforeOData ;
8886
8987 /// <inheritdoc />
9088 public virtual void OnProvidersExecuting ( ApiDescriptionProviderContext context )
@@ -107,9 +105,9 @@ public virtual void OnProvidersExecuting( ApiDescriptionProviderContext context
107105 {
108106 var model = models [ i ] ;
109107 var version = model . GetApiVersion ( ) ;
110- var options = odataOptionsFactory . Create ( Opts . DefaultName ) ;
108+ var odata = odataOptionsFactory . Create ( Opts . DefaultName ) ;
111109
112- options . AddRouteComponents ( model ) ;
110+ odata . AddRouteComponents ( model ) ;
113111
114112 for ( var j = 0 ; j < results . Count ; j ++ )
115113 {
@@ -149,12 +147,14 @@ public virtual void OnProvidersExecuted( ApiDescriptionProviderContext context )
149147 }
150148
151149 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
152- private static int ODataOrder ( IOptionsFactory < ODataOptions > factory , IOptions < ODataApiExplorerOptions > options ) =>
150+ private static int ODataOrder ( ) =>
153151 new ODataApiDescriptionProvider (
154152 new StubModelMetadataProvider ( ) ,
155153 new StubModelTypeBuilder ( ) ,
156- factory ,
157- options ) . Order ;
154+ new OptionsFactory < ODataOptions > (
155+ Enumerable . Empty < IConfigureOptions < ODataOptions > > ( ) ,
156+ Enumerable . Empty < IPostConfigureOptions < ODataOptions > > ( ) ) ,
157+ Opts . Create ( new ODataApiExplorerOptions ( ) ) ) . Order ;
158158
159159 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
160160 private static void MarkAsAdHoc ( ODataModelBuilder builder , IEdmModel model ) =>
0 commit comments