diff --git a/src/Microsoft.OpenApi.OData.Reader/Edm/ODataPath.cs b/src/Microsoft.OpenApi.OData.Reader/Edm/ODataPath.cs index 7c2d9cc..bd07491 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Edm/ODataPath.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Edm/ODataPath.cs @@ -146,8 +146,8 @@ namespace Microsoft.OpenApi.OData.Edm // From Open API spec, parameter name is case sensitive, so don't use the IgnoreCase HashSet. // HashSet parameters = new HashSet(StringComparer.OrdinalIgnoreCase); - HashSet parameters = new HashSet(); - StringBuilder sb = new StringBuilder(); + HashSet parameters = new(); + StringBuilder sb = new(); if (!string.IsNullOrWhiteSpace(settings.PathPrefix)) { diff --git a/src/Microsoft.OpenApi.OData.Reader/EdmModelOpenApiExtensions.cs b/src/Microsoft.OpenApi.OData.Reader/EdmModelOpenApiExtensions.cs index 5043276..60fab5c 100644 --- a/src/Microsoft.OpenApi.OData.Reader/EdmModelOpenApiExtensions.cs +++ b/src/Microsoft.OpenApi.OData.Reader/EdmModelOpenApiExtensions.cs @@ -42,21 +42,20 @@ namespace Microsoft.OpenApi.OData if (settings.VerifyEdmModel) { - IEnumerable errors; - if (!model.Validate(out errors)) - { - OpenApiDocument document = new OpenApiDocument(); - int index = 1; - foreach (var error in errors) - { - document.Extensions.Add(Constants.xMsEdmModelError + index++, new OpenApiString(error.ToString())); - } + if (!model.Validate(out var errors)) + { + OpenApiDocument document = new(); + int index = 1; + foreach (var error in errors) + { + document.Extensions.Add(Constants.xMsEdmModelError + index++, new OpenApiString(error.ToString())); + } - return document; - } - } + return document; + } + } - ODataContext context = new ODataContext(model, settings); + ODataContext context = new(model, settings); return context.CreateDocument(); } } diff --git a/src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiPathItemGenerator.cs b/src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiPathItemGenerator.cs index 13832d7..db276fd 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiPathItemGenerator.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiPathItemGenerator.cs @@ -54,7 +54,7 @@ namespace Microsoft.OpenApi.OData.Generator if (settings.ShowRootPath) { - OpenApiPathItem rootPath = new OpenApiPathItem() + OpenApiPathItem rootPath = new() { Operations = new Dictionary { { diff --git a/src/Microsoft.OpenApi.OData.Reader/PathItem/PathItemHandlerProvider.cs b/src/Microsoft.OpenApi.OData.Reader/PathItem/PathItemHandlerProvider.cs index 00eac42..ae81bc3 100644 --- a/src/Microsoft.OpenApi.OData.Reader/PathItem/PathItemHandlerProvider.cs +++ b/src/Microsoft.OpenApi.OData.Reader/PathItem/PathItemHandlerProvider.cs @@ -13,7 +13,7 @@ namespace Microsoft.OpenApi.OData.PathItem /// internal class PathItemHandlerProvider : IPathItemHandlerProvider { - private IDictionary _handlers = new Dictionary + private readonly IDictionary _handlers = new Dictionary { // EntitySet { ODataPathKind.EntitySet, new EntitySetPathItemHandler() },