@@ -23,7 +23,7 @@ namespace Asp.Versioning.ApiExplorer;
23
23
[ CLSCompliant ( false ) ]
24
24
public class PartialODataDescriptionProvider : IApiDescriptionProvider
25
25
{
26
- private static int ? beforeOData ;
26
+ private static readonly int BeforeOData = ODataOrder ( ) + 10 ;
27
27
private readonly IOptionsFactory < ODataOptions > odataOptionsFactory ;
28
28
private readonly IOptions < ODataApiExplorerOptions > options ;
29
29
private bool markedAdHoc ;
@@ -42,8 +42,6 @@ public PartialODataDescriptionProvider(
42
42
{
43
43
this . odataOptionsFactory = odataOptionsFactory ?? throw new ArgumentNullException ( nameof ( odataOptionsFactory ) ) ;
44
44
this . options = options ?? throw new ArgumentNullException ( nameof ( options ) ) ;
45
- beforeOData ??= ODataOrder ( odataOptionsFactory , options ) + 10 ;
46
- Order = beforeOData . Value ;
47
45
}
48
46
49
47
/// <summary>
@@ -84,7 +82,7 @@ protected ODataApiExplorerOptions Options
84
82
/// Gets or sets the order precedence of the current API description provider.
85
83
/// </summary>
86
84
/// <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 ;
88
86
89
87
/// <inheritdoc />
90
88
public virtual void OnProvidersExecuting ( ApiDescriptionProviderContext context )
@@ -102,9 +100,9 @@ public virtual void OnProvidersExecuting( ApiDescriptionProviderContext context
102
100
{
103
101
var model = models [ i ] ;
104
102
var version = model . GetApiVersion ( ) ;
105
- var options = odataOptionsFactory . Create ( Opts . DefaultName ) ;
103
+ var odata = odataOptionsFactory . Create ( Opts . DefaultName ) ;
106
104
107
- options . AddRouteComponents ( model ) ;
105
+ odata . AddRouteComponents ( model ) ;
108
106
109
107
for ( var j = 0 ; j < results . Count ; j ++ )
110
108
{
@@ -139,12 +137,18 @@ public virtual void OnProvidersExecuted( ApiDescriptionProviderContext context )
139
137
}
140
138
141
139
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
142
- private static int ODataOrder ( IOptionsFactory < ODataOptions > factory , IOptions < ODataApiExplorerOptions > options ) =>
140
+ private static int ODataOrder ( ) =>
143
141
new ODataApiDescriptionProvider (
144
142
new StubModelMetadataProvider ( ) ,
145
143
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 ;
148
152
149
153
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
150
154
private static void MarkAsAdHoc ( ODataModelBuilder builder , IEdmModel model ) =>
@@ -206,6 +210,15 @@ public Type NewStructuredType( IEdmModel model, IEdmStructuredType structuredTyp
206
210
throw new NotImplementedException ( ) ;
207
211
}
208
212
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
+
209
222
private static class ODataMetadata
210
223
{
211
224
private const string ArbitrarySegment = "52459ff8-bca1-4a26-b7f2-08c7da04472d" ;
0 commit comments