Skip to content

Commit e26bbe1

Browse files
Fix CodeQL findings
1 parent cb7a153 commit e26bbe1

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/AspNet/OData/src/Asp.Versioning.WebApi.OData.ApiExplorer/ApiExplorer/ODataApiExplorer.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ namespace Asp.Versioning.ApiExplorer;
3434
public class ODataApiExplorer : VersionedApiExplorer
3535
{
3636
private static readonly Regex odataVariableRegex = new( $"{{\\*{ODataRouteConstants.ODataPath}}}", CultureInvariant | Compiled | IgnoreCase );
37+
private readonly ODataApiExplorerOptions options;
3738
private IModelTypeBuilder? modelTypeBuilder;
3839

3940
/// <summary>
@@ -49,13 +50,13 @@ public ODataApiExplorer( HttpConfiguration configuration )
4950
/// <param name="configuration">The current <see cref="HttpConfiguration">HTTP configuration</see>.</param>
5051
/// <param name="options">The associated <see cref="ODataApiExplorerOptions">API explorer options</see>.</param>
5152
public ODataApiExplorer( HttpConfiguration configuration, ODataApiExplorerOptions options )
52-
: base( configuration, options ) => Options = options;
53+
: base( configuration, options ) => this.options = options;
5354

5455
/// <summary>
5556
/// Gets the options associated with the API explorer.
5657
/// </summary>
5758
/// <value>The <see cref="ODataApiExplorerOptions">API explorer options</see>.</value>
58-
protected new virtual ODataApiExplorerOptions Options { get; }
59+
protected new virtual ODataApiExplorerOptions Options => options;
5960

6061
/// <summary>
6162
/// Gets the model type builder used by the API explorer.

src/AspNet/WebApi/src/Asp.Versioning.WebApi.ApiExplorer/ApiExplorer/VersionedApiExplorer.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public class VersionedApiExplorer : IApiExplorer
2929
{
3030
private static readonly Regex actionVariableRegex = new( $"{{{RouteValueKeys.Action}}}", Compiled | IgnoreCase | CultureInvariant );
3131
private static readonly Regex controllerVariableRegex = new( $"{{{RouteValueKeys.Controller}}}", Compiled | IgnoreCase | CultureInvariant );
32+
private readonly ApiExplorerOptions options;
3233
private readonly Lazy<ApiDescriptionGroupCollection> apiDescriptions;
3334
private IDocumentationProvider? documentationProvider;
3435
private ISunsetPolicyManager? sunsetPolicyManager;
@@ -48,8 +49,8 @@ public VersionedApiExplorer( HttpConfiguration configuration )
4849
public VersionedApiExplorer( HttpConfiguration configuration, ApiExplorerOptions options )
4950
{
5051
Configuration = configuration;
51-
Options = options;
52-
apiDescriptions = new( InitializeApiDescriptions );
52+
this.options = options;
53+
apiDescriptions = new( Initialize );
5354
}
5455

5556
/// <summary>
@@ -80,7 +81,7 @@ public IDocumentationProvider DocumentationProvider
8081
/// Gets the options associated with the API explorer.
8182
/// </summary>
8283
/// <value>The <see cref="ApiExplorerOptions">API explorer options</see>.</value>
83-
protected virtual ApiExplorerOptions Options { get; }
84+
protected virtual ApiExplorerOptions Options => options;
8485

8586
/// <summary>
8687
/// Gets the comparer used to compare API descriptions.
@@ -205,6 +206,8 @@ protected virtual string GetGroupName( ApiVersion apiVersion )
205206
return apiVersion.ToString( Options.GroupNameFormat, InvariantCulture );
206207
}
207208

209+
private ApiDescriptionGroupCollection Initialize() => InitializeApiDescriptions();
210+
208211
/// <summary>
209212
/// Initializes the API descriptions to explore.
210213
/// </summary>

src/AspNet/WebApi/src/Asp.Versioning.WebApi/Dispatcher/ApiVersionControllerSelector.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,6 @@ private static HttpControllerDescriptor[] ApplyCollatedModels(
251251
List<HttpControllerDescriptor> controllers,
252252
IHttpActionSelector actionSelector )
253253
{
254-
var supported = new HashSet<ApiVersion>();
255-
var deprecated = new HashSet<ApiVersion>();
256254
var controllerModels = new List<ApiVersionModel>( controllers.Count );
257255
var actionModels = new List<ApiVersionModel>( controllers.Count );
258256
var visitedControllers = new List<Tuple<HttpControllerDescriptor, ApiVersionModel>>( controllers.Count );

0 commit comments

Comments
 (0)