@@ -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 )
@@ -102,9 +100,9 @@ public virtual void OnProvidersExecuting( ApiDescriptionProviderContext context
102100 {
103101 var model = models [ i ] ;
104102 var version = model . GetApiVersion ( ) ;
105- var options = odataOptionsFactory . Create ( Opts . DefaultName ) ;
103+ var odata = odataOptionsFactory . Create ( Opts . DefaultName ) ;
106104
107- options . AddRouteComponents ( model ) ;
105+ odata . AddRouteComponents ( model ) ;
108106
109107 for ( var j = 0 ; j < results . Count ; j ++ )
110108 {
@@ -139,12 +137,18 @@ public virtual void OnProvidersExecuted( ApiDescriptionProviderContext context )
139137 }
140138
141139 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
142- private static int ODataOrder ( IOptionsFactory < ODataOptions > factory , IOptions < ODataApiExplorerOptions > options ) =>
140+ private static int ODataOrder ( ) =>
143141 new ODataApiDescriptionProvider (
144142 new StubModelMetadataProvider ( ) ,
145143 new StubModelTypeBuilder ( ) ,
146- factory ,
147- options ) . Order ;
144+ new OptionsFactory < ODataOptions > (
145+ Enumerable . Empty < IConfigureOptions < ODataOptions > > ( ) ,
146+ Enumerable . Empty < IPostConfigureOptions < ODataOptions > > ( ) ) ,
147+ Opts . Create (
148+ new ODataApiExplorerOptions (
149+ new (
150+ new StubODataApiVersionCollectionProvider ( ) ,
151+ Enumerable . Empty < IModelConfiguration > ( ) ) ) ) ) . Order ;
148152
149153 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
150154 private static void MarkAsAdHoc ( ODataModelBuilder builder , IEdmModel model ) =>
@@ -206,6 +210,15 @@ public Type NewStructuredType( IEdmModel model, IEdmStructuredType structuredTyp
206210 throw new NotImplementedException ( ) ;
207211 }
208212
213+ private sealed class StubODataApiVersionCollectionProvider : IODataApiVersionCollectionProvider
214+ {
215+ public IReadOnlyList < ApiVersion > ApiVersions
216+ {
217+ get => throw new NotImplementedException ( ) ;
218+ set => throw new NotImplementedException ( ) ;
219+ }
220+ }
221+
209222 private static class ODataMetadata
210223 {
211224 private const string ArbitrarySegment = "52459ff8-bca1-4a26-b7f2-08c7da04472d" ;
0 commit comments