Skip to content

Commit

Permalink
Fix CodeQL violations
Browse files Browse the repository at this point in the history
  • Loading branch information
commonsensesoftware committed Dec 27, 2022
1 parent 9ae3dd5 commit 52cb28d
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Asp.Versioning.ApiExplorer;
[CLSCompliant( false )]
public class PartialODataDescriptionProvider : IApiDescriptionProvider
{
private static int? beforeOData;
private static readonly int BeforeOData = ODataOrder() + 10;
private readonly IOptionsFactory<ODataOptions> odataOptionsFactory;
private readonly IOptions<ODataApiExplorerOptions> options;
private bool markedAdHoc;
Expand All @@ -42,8 +42,6 @@ public PartialODataDescriptionProvider(
{
this.odataOptionsFactory = odataOptionsFactory ?? throw new ArgumentNullException( nameof( odataOptionsFactory ) );
this.options = options ?? throw new ArgumentNullException( nameof( options ) );
beforeOData ??= ODataOrder( odataOptionsFactory, options ) + 10;
Order = beforeOData.Value;
}

/// <summary>
Expand Down Expand Up @@ -84,7 +82,7 @@ protected ODataApiExplorerOptions Options
/// Gets or sets the order precedence of the current API description provider.
/// </summary>
/// <value>The order precedence of the current API description provider.</value>
public int Order { get; protected set; }
public int Order { get; protected set; } = BeforeOData;

/// <inheritdoc />
public virtual void OnProvidersExecuting( ApiDescriptionProviderContext context )
Expand All @@ -107,9 +105,9 @@ public virtual void OnProvidersExecuting( ApiDescriptionProviderContext context
{
var model = models[i];
var version = model.GetApiVersion();
var options = odataOptionsFactory.Create( Opts.DefaultName );
var odata = odataOptionsFactory.Create( Opts.DefaultName );

options.AddRouteComponents( model );
odata.AddRouteComponents( model );

for ( var j = 0; j < results.Count; j++ )
{
Expand Down Expand Up @@ -149,12 +147,14 @@ public virtual void OnProvidersExecuted( ApiDescriptionProviderContext context )
}

[MethodImpl( MethodImplOptions.AggressiveInlining )]
private static int ODataOrder( IOptionsFactory<ODataOptions> factory, IOptions<ODataApiExplorerOptions> options ) =>
private static int ODataOrder() =>
new ODataApiDescriptionProvider(
new StubModelMetadataProvider(),
new StubModelTypeBuilder(),
factory,
options ).Order;
new OptionsFactory<ODataOptions>(
Enumerable.Empty<IConfigureOptions<ODataOptions>>(),
Enumerable.Empty<IPostConfigureOptions<ODataOptions>>() ),
Opts.Create( new ODataApiExplorerOptions() ) ).Order;

[MethodImpl( MethodImplOptions.AggressiveInlining )]
private static void MarkAsAdHoc( ODataModelBuilder builder, IEdmModel model ) =>
Expand Down

0 comments on commit 52cb28d

Please sign in to comment.