From 333ccd843d8e6d9da3a8ee63832669206c36993a Mon Sep 17 00:00:00 2001 From: Marko Lahma Date: Sat, 23 Nov 2024 10:28:59 +0200 Subject: [PATCH] Fix string usage and remove extra usings --- Directory.Build.props | 10 +--------- .../Middlewares/OpenApiDocumentMiddleware.cs | 2 +- src/NSwag.AspNet.Owin/NSwag.AspNet.Owin.csproj | 1 + src/NSwag.AspNetCore.Launcher/Program.cs | 5 +---- .../Middlewares/OpenApiDocumentMiddleware.cs | 2 +- src/NSwag.AspNetCore/NSwag.AspNetCore.csproj | 4 ++++ .../AllowNullableBodyParametersTests.cs | 2 -- .../ArrayParameterTests.cs | 3 +-- .../BinaryTests.cs | 1 - .../CSharpClientSettingsTests.cs | 2 -- .../ControllerGenerationFormatTests.cs | 3 +-- .../ControllerGenerationBasePathTests.cs | 3 +-- .../FileDownloadTests.cs | 6 +----- .../FileTests.cs | 5 +---- .../FileUploadTests.cs | 3 +-- .../FormParameterTests.cs | 4 +--- .../HeadRequestTests.cs | 4 +--- .../InheritanceTests.cs | 1 - .../ObjectParameterTests.cs | 1 - .../OptionalParameterTests.cs | 6 +----- .../ParameterTests.cs | 4 +--- .../PlainResponseTests.cs | 7 +------ .../PlainTextBodyTests.cs | 3 +-- .../QueryParameterTests.cs | 3 +-- .../ResponseTests.cs | 3 +-- .../UseCancellationTokenTests.cs | 5 +---- .../WrapResponsesTests.cs | 3 --- .../Models/CSharpParameterModel.cs | 4 ++-- .../NSwag.CodeGeneration.CSharp.csproj | 2 ++ .../CodeGenerationTests.cs | 6 +----- .../AngularJSTests.cs | 4 +--- .../AngularTests.cs | 4 +--- .../ArrayParameterTests.cs | 3 +-- .../AxiosTests.cs | 4 +--- .../BinaryTests.cs | 3 +-- .../FetchTests.cs | 4 +--- .../InheritanceTests.cs | 3 +-- .../JQueryCallbacksTests.cs | 4 +--- .../JQueryPromisesTests.cs | 4 +--- .../ObjectParameterTests.cs | 3 +-- .../OperationParameterTests.cs | 7 +------ .../TypeScriptDiscriminatorTests.cs | 5 +---- .../TypeScriptOperationParameterTests.cs | 4 +--- src/NSwag.CodeGeneration/ClientGeneratorBase.cs | 2 +- .../Models/OperationModelBase.cs | 2 +- .../Commands/Document/ExecuteDocumentCommand.cs | 2 +- .../AspNetCore/AspNetCoreToOpenApiCommand.cs | 2 +- .../Commands/Generation/AspNetCore/Exe.cs | 8 ++++---- src/NSwag.Commands/Commands/OutputCommandBase.cs | 6 +++--- src/NSwag.Commands/NSwag.Commands.csproj | 4 ++++ src/NSwag.Commands/NSwagDocument.cs | 10 +++++----- src/NSwag.Commands/NSwagDocumentBase.cs | 12 ++++++++---- src/NSwag.Commands/PathUtilities.cs | 8 ++++---- src/NSwag.Console/Program.cs | 4 +--- .../GenerateSampleSpecificationTests.cs | 4 ---- src/NSwag.Core.Tests/DocumentLoadingTests.cs | 3 --- src/NSwag.Core.Tests/DocumentReferenceTests.cs | 4 +--- src/NSwag.Core.Tests/HttpLoadingTests.cs | 3 +-- src/NSwag.Core.Tests/OperationIdTests.cs | 3 +-- .../ComponentsSerializationTests.cs | 1 - .../Serialization/ExampleSerializationTests.cs | 2 -- .../Serialization/ExternalReferenceTests.cs | 4 +--- .../Serialization/NullDefinitionTests.cs | 3 +-- .../Serialization/PathItemTests.cs | 5 +---- .../RequestBodySerializationTests.cs | 2 -- .../Serialization/ServersSerializationTests.cs | 3 +-- .../References/YamlReferencesTests.cs | 5 +---- src/NSwag.Core.Yaml.Tests/YamlDocumentTests.cs | 4 +--- src/NSwag.Core.Yaml/OpenApiYamlDocument.cs | 4 ---- .../Collections/ObservableDictionary.cs | 10 +++++----- src/NSwag.Core/HttpUtilities.cs | 2 +- src/NSwag.Core/OpenApiDocument.Serialization.cs | 2 +- src/NSwag.Core/OpenApiDocument.cs | 13 ++++++------- src/NSwag.Core/OpenApiServerVariable.cs | 1 - src/NSwag.Core/Polyfills.cs | 10 ++++++++++ .../Processors/OperationResponseProcessorTest.cs | 1 - .../Responses/ProducesTests.cs | 1 - .../Responses/WrappedResponseTests.cs | 4 +--- .../SystemTextJsonTests.cs | 1 - .../AspNetCoreOpenApiDocumentGenerator.cs | 8 ++++---- .../NSwag.Generation.AspNetCore.csproj | 5 +++++ .../Processors/OperationParameterProcessor.cs | 6 +++--- .../Processors/OperationResponseProcessor.cs | 2 +- .../Processors/OperationParameterProcessor.cs | 4 ++-- .../WebApiOpenApiDocumentGenerator.cs | 16 ++++++++-------- .../Processors/OperationResponseProcessorBase.cs | 2 +- .../Processors/OperationTagsProcessor.cs | 2 +- .../Security/SecurityDefinitionAppender.cs | 1 - .../Controllers/ValuesController.cs | 4 +--- src/NSwag.Sample.NET80/Program.cs | 3 --- src/NSwag.Sample.NET80/Startup.cs | 5 ----- src/NSwag.Sample.NET80Minimal/Program.cs | 4 ---- .../Controllers/ValuesController.cs | 4 +--- src/NSwag.Sample.NET90/Program.cs | 3 --- src/NSwag.Sample.NET90/Startup.cs | 5 ----- src/NSwag.Sample.NET90Minimal/Program.cs | 4 ---- src/NSwagStudio/Controls/AvalonEditBehavior.cs | 1 - src/NSwagStudio/Controls/TabContent.cs | 1 - .../Converters/IsValueToVisibilityConverter.cs | 3 +-- .../Converters/NumberAdditionConverter.cs | 3 +-- .../Converters/StringArrayConverter.cs | 4 +--- src/NSwagStudio/ISwaggerGeneratorView.cs | 1 - .../CodeGenerators/SwaggerOutputViewModel.cs | 1 - .../SwaggerToCSharpClientGeneratorViewModel.cs | 2 -- ...waggerToCSharpControllerGeneratorViewModel.cs | 2 -- ...waggerToTypeScriptClientGeneratorViewModel.cs | 2 -- src/NSwagStudio/ViewModels/DocumentModel.cs | 3 --- src/NSwagStudio/ViewModels/DocumentViewModel.cs | 3 --- src/NSwagStudio/ViewModels/MainWindowModel.cs | 2 -- .../AspNetCoreToSwaggerGeneratorViewModel.cs | 4 ---- .../SwaggerGenerators/SwaggerInputViewModel.cs | 3 --- src/NSwagStudio/ViewModels/ViewModelBase.cs | 2 -- src/NSwagStudio/Views/DocumentView.xaml.cs | 5 +---- src/NSwagStudio/Views/MainWindow.xaml.cs | 4 +--- .../AspNetCoreToSwaggerGeneratorView.xaml.cs | 5 +---- .../JsonSchemaInputView.xaml.cs | 4 +--- .../SwaggerGenerators/SwaggerInputView.xaml.cs | 3 +-- 117 files changed, 143 insertions(+), 308 deletions(-) create mode 100644 src/NSwag.Core/Polyfills.cs diff --git a/Directory.Build.props b/Directory.Build.props index 5b7517a480..f3c48debe9 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -74,22 +74,14 @@ [CA1200] Avoid using cref tags with a prefix [CA1304] The behavior of 'string.ToUpper()' could vary based on the current user's locale settings [CA1305] The behavior of 'int.ToString()' could vary based on the current user's locale settings - [CA1310] The behavior of 'string.StartsWith(string)' could vary based on the current user's locale settings - [CA1311] The behavior of 'string.StartsWith(string)' could vary based on the current user's locale settings - [CA1507] Use nameof in place of string literal [CA1510] Use 'ArgumentNullException.ThrowIfNull' instead of explicitly throwing a new exception instance [CA1514] 'System.ReadOnlySpan.Slice(int, int)' uses a redundant length calculation that can be removed [CA1710] Rename to end in either 'Dictionary' or 'Collection' [CA1716] rename parameter property so that it no longer conflicts with the reserved language keyword [CA1720] Identifier 'xxx' contains type name [CA1725] Overriden parameter name mismatch - [CA1834] Use 'StringBuilder.Append(char)' instead of 'StringBuilder.Append(string)' when the input is a constant unit string [CA1845] Use span-based 'string.Concat' and 'AsSpan' instead of 'Substring' - [CA1847] Use 'string.Contains(char)' instead of 'string.Contains(string)' - needs polyfill [CA1861] Prefer 'static readonly' fields over constant array arguments - [CA1862] Prefer using 'string.Equals(string, StringComparison)' to perform a case-insensitive comparison - [CA1865] Use 'string.StartsWith(char)' instead of 'string.StartsWith(string)' - needs polyfill - [CA1866] Use 'string.StartsWith(char)' instead of 'string.StartsWith(string)' - needs polyfill [CA1870] Use a cached 'SearchValues' instance for improved searching performance [CA2249] Use 'string.Contains' instead of 'string.IndexOf' to improve readability - needs polyfill [CA2263] Prefer the generic overload 'System.Enum.GetValues()' @@ -97,7 +89,7 @@ [SYSLIB0012] 'Assembly.CodeBase' is obsolete --> $(NoWarn);IDE0005;IDE0008;IDE0017;IDE0021;IDE0022;IDE0025;IDE0027;IDE0029;IDE0032;IDE0039;IDE0045;IDE0046;IDE0055;IDE0056;IDE0057;IDE0060;IDE0061;IDE0090;IDE0130;IDE0160;IDE0200;IDE0270;IDE0290;IDE0330 - $(NoWarn);CA1200;CA1304;CA1305;CA1310;CA1311;CA1507;CA1510;CA1514;CA1710;CA1716;CA1720;CA1725;CA1834;CA1845;CA1847;CA1861;CA1862;CA1865;CA1866;CA1870;CA2249;CA2263;SYSLIB0012 + $(NoWarn);CA1200;CA1304;CA1305;CA1510;CA1514;CA1710;CA1716;CA1720;CA1725;CA1845;CA1861;CA1870;CA2249;CA2263;SYSLIB0012 diff --git a/src/NSwag.AspNet.Owin/Middlewares/OpenApiDocumentMiddleware.cs b/src/NSwag.AspNet.Owin/Middlewares/OpenApiDocumentMiddleware.cs index a0d50780e0..9bcb3f416d 100644 --- a/src/NSwag.AspNet.Owin/Middlewares/OpenApiDocumentMiddleware.cs +++ b/src/NSwag.AspNet.Owin/Middlewares/OpenApiDocumentMiddleware.cs @@ -31,7 +31,7 @@ public class OpenApiDocumentMiddleware : OwinMiddleware public OpenApiDocumentMiddleware(OwinMiddleware next, string path, IEnumerable controllerTypes, SwaggerSettings settings) : base(next) { - _path = path.StartsWith("/") ? path : '/' + path; + _path = path.StartsWith('/') ? path : '/' + path; _controllerTypes = controllerTypes; _settings = settings; } diff --git a/src/NSwag.AspNet.Owin/NSwag.AspNet.Owin.csproj b/src/NSwag.AspNet.Owin/NSwag.AspNet.Owin.csproj index c137a8b05f..944d488bd8 100644 --- a/src/NSwag.AspNet.Owin/NSwag.AspNet.Owin.csproj +++ b/src/NSwag.AspNet.Owin/NSwag.AspNet.Owin.csproj @@ -17,6 +17,7 @@ + diff --git a/src/NSwag.AspNetCore.Launcher/Program.cs b/src/NSwag.AspNetCore.Launcher/Program.cs index 79996c20d7..2e40c0177a 100644 --- a/src/NSwag.AspNetCore.Launcher/Program.cs +++ b/src/NSwag.AspNetCore.Launcher/Program.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; +using System.Reflection; namespace NSwag.AspNetCore.Launcher { diff --git a/src/NSwag.AspNetCore/Middlewares/OpenApiDocumentMiddleware.cs b/src/NSwag.AspNetCore/Middlewares/OpenApiDocumentMiddleware.cs index 4d56614aca..727b2724c2 100644 --- a/src/NSwag.AspNetCore/Middlewares/OpenApiDocumentMiddleware.cs +++ b/src/NSwag.AspNetCore/Middlewares/OpenApiDocumentMiddleware.cs @@ -39,7 +39,7 @@ public OpenApiDocumentMiddleware(RequestDelegate nextDelegate, IServiceProvider _nextDelegate = nextDelegate; _documentName = documentName; - _path = path.StartsWith("/") ? path : '/' + path; + _path = path.StartsWith('/') ? path : '/' + path; _apiDescriptionGroupCollectionProvider = serviceProvider.GetService() ?? throw new InvalidOperationException("API Explorer not registered in DI."); diff --git a/src/NSwag.AspNetCore/NSwag.AspNetCore.csproj b/src/NSwag.AspNetCore/NSwag.AspNetCore.csproj index e8bab7f7d2..9958b22194 100644 --- a/src/NSwag.AspNetCore/NSwag.AspNetCore.csproj +++ b/src/NSwag.AspNetCore/NSwag.AspNetCore.csproj @@ -54,6 +54,10 @@ + + + + diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/AllowNullableBodyParametersTests.cs b/src/NSwag.CodeGeneration.CSharp.Tests/AllowNullableBodyParametersTests.cs index 8ca3104191..107c951414 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/AllowNullableBodyParametersTests.cs +++ b/src/NSwag.CodeGeneration.CSharp.Tests/AllowNullableBodyParametersTests.cs @@ -1,10 +1,8 @@ using Microsoft.AspNetCore.Mvc; -using NJsonSchema.Generation; using NJsonSchema.NewtonsoftJson.Generation; using NSwag.CodeGeneration.OperationNameGenerators; using NSwag.Generation.WebApi; using System.ComponentModel.DataAnnotations; -using System.Threading.Tasks; using Xunit; namespace NSwag.CodeGeneration.CSharp.Tests diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/ArrayParameterTests.cs b/src/NSwag.CodeGeneration.CSharp.Tests/ArrayParameterTests.cs index 551ed0b71e..8bbacbd2b3 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/ArrayParameterTests.cs +++ b/src/NSwag.CodeGeneration.CSharp.Tests/ArrayParameterTests.cs @@ -1,5 +1,4 @@ -using System.Threading.Tasks; -using Xunit; +using Xunit; namespace NSwag.CodeGeneration.CSharp.Tests { diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/BinaryTests.cs b/src/NSwag.CodeGeneration.CSharp.Tests/BinaryTests.cs index 1f5a83cc33..38082ce849 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/BinaryTests.cs +++ b/src/NSwag.CodeGeneration.CSharp.Tests/BinaryTests.cs @@ -1,5 +1,4 @@ using NSwag.CodeGeneration.CSharp.Models; -using System.Threading.Tasks; using Xunit; namespace NSwag.CodeGeneration.CSharp.Tests diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/CSharpClientSettingsTests.cs b/src/NSwag.CodeGeneration.CSharp.Tests/CSharpClientSettingsTests.cs index 05350c01f2..c76eb56fb6 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/CSharpClientSettingsTests.cs +++ b/src/NSwag.CodeGeneration.CSharp.Tests/CSharpClientSettingsTests.cs @@ -1,6 +1,4 @@ -using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; -using NJsonSchema.Generation; using NJsonSchema.NewtonsoftJson.Generation; using NSwag.Generation.WebApi; using Xunit; diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/ControllerGenerationFormatTests.cs b/src/NSwag.CodeGeneration.CSharp.Tests/ControllerGenerationFormatTests.cs index 0d5ca528d0..f4f5fb396f 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/ControllerGenerationFormatTests.cs +++ b/src/NSwag.CodeGeneration.CSharp.Tests/ControllerGenerationFormatTests.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using System.Text.RegularExpressions; +using System.Text.RegularExpressions; using NJsonSchema; using NJsonSchema.NewtonsoftJson.Generation; using NSwag.CodeGeneration.CSharp.Models; diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/Controllers/ControllerGenerationBasePathTests.cs b/src/NSwag.CodeGeneration.CSharp.Tests/Controllers/ControllerGenerationBasePathTests.cs index 773f2dc142..ab1eae526e 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/Controllers/ControllerGenerationBasePathTests.cs +++ b/src/NSwag.CodeGeneration.CSharp.Tests/Controllers/ControllerGenerationBasePathTests.cs @@ -1,5 +1,4 @@ -using System.Threading.Tasks; -using Xunit; +using Xunit; namespace NSwag.CodeGeneration.CSharp.Tests { diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/FileDownloadTests.cs b/src/NSwag.CodeGeneration.CSharp.Tests/FileDownloadTests.cs index 324b269fd9..270623e999 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/FileDownloadTests.cs +++ b/src/NSwag.CodeGeneration.CSharp.Tests/FileDownloadTests.cs @@ -1,8 +1,4 @@ -using System; -using System.Net.Http; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using NJsonSchema.Generation; +using Microsoft.AspNetCore.Mvc; using NJsonSchema.NewtonsoftJson.Generation; using NSwag.Generation.WebApi; using Xunit; diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/FileTests.cs b/src/NSwag.CodeGeneration.CSharp.Tests/FileTests.cs index 995ccbaf09..b23402c688 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/FileTests.cs +++ b/src/NSwag.CodeGeneration.CSharp.Tests/FileTests.cs @@ -1,7 +1,4 @@ -using System; -using System.Net.Http; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using NJsonSchema.NewtonsoftJson.Generation; using NSwag.Generation.WebApi; using Xunit; diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/FileUploadTests.cs b/src/NSwag.CodeGeneration.CSharp.Tests/FileUploadTests.cs index 3f3984439e..036991f4ce 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/FileUploadTests.cs +++ b/src/NSwag.CodeGeneration.CSharp.Tests/FileUploadTests.cs @@ -1,5 +1,4 @@ -using System.Threading.Tasks; -using NJsonSchema; +using NJsonSchema; using Xunit; namespace NSwag.CodeGeneration.CSharp.Tests diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/FormParameterTests.cs b/src/NSwag.CodeGeneration.CSharp.Tests/FormParameterTests.cs index 5ac8baa0e5..7214b376bc 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/FormParameterTests.cs +++ b/src/NSwag.CodeGeneration.CSharp.Tests/FormParameterTests.cs @@ -1,7 +1,5 @@ -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using NJsonSchema; -using NJsonSchema.Generation; using NJsonSchema.NewtonsoftJson.Generation; using NSwag.Generation.WebApi; using Xunit; diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/HeadRequestTests.cs b/src/NSwag.CodeGeneration.CSharp.Tests/HeadRequestTests.cs index d379acd004..abbd90576f 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/HeadRequestTests.cs +++ b/src/NSwag.CodeGeneration.CSharp.Tests/HeadRequestTests.cs @@ -1,6 +1,4 @@ -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using NJsonSchema.Generation; +using Microsoft.AspNetCore.Mvc; using NJsonSchema.NewtonsoftJson.Generation; using NSwag.Generation.WebApi; using Xunit; diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/InheritanceTests.cs b/src/NSwag.CodeGeneration.CSharp.Tests/InheritanceTests.cs index 565dead490..979b5cab6a 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/InheritanceTests.cs +++ b/src/NSwag.CodeGeneration.CSharp.Tests/InheritanceTests.cs @@ -1,5 +1,4 @@ using NSwag.CodeGeneration.CSharp; -using System.Threading.Tasks; using Xunit; namespace NSwag.CodeGeneration.TypeScript.Tests diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/ObjectParameterTests.cs b/src/NSwag.CodeGeneration.CSharp.Tests/ObjectParameterTests.cs index fab28efccd..6b2edcdd2d 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/ObjectParameterTests.cs +++ b/src/NSwag.CodeGeneration.CSharp.Tests/ObjectParameterTests.cs @@ -1,4 +1,3 @@ -using System.Threading.Tasks; using Xunit; namespace NSwag.CodeGeneration.CSharp.Tests diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/OptionalParameterTests.cs b/src/NSwag.CodeGeneration.CSharp.Tests/OptionalParameterTests.cs index 80382129b9..99386876d3 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/OptionalParameterTests.cs +++ b/src/NSwag.CodeGeneration.CSharp.Tests/OptionalParameterTests.cs @@ -1,9 +1,5 @@ -using System; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using NJsonSchema; -using NJsonSchema.Generation; using NJsonSchema.NewtonsoftJson.Generation; using NSwag.Generation.WebApi; using Xunit; diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/ParameterTests.cs b/src/NSwag.CodeGeneration.CSharp.Tests/ParameterTests.cs index ce575c703f..229f303aef 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/ParameterTests.cs +++ b/src/NSwag.CodeGeneration.CSharp.Tests/ParameterTests.cs @@ -1,6 +1,4 @@ -using System; -using System.Threading.Tasks; -using NJsonSchema; +using NJsonSchema; using Xunit; namespace NSwag.CodeGeneration.CSharp.Tests diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/PlainResponseTests.cs b/src/NSwag.CodeGeneration.CSharp.Tests/PlainResponseTests.cs index d73b3c6c71..2e997f979b 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/PlainResponseTests.cs +++ b/src/NSwag.CodeGeneration.CSharp.Tests/PlainResponseTests.cs @@ -1,9 +1,4 @@ -using System; -using System.Net.Http; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using NSwag.Generation.WebApi; -using Xunit; +using Xunit; namespace NSwag.CodeGeneration.CSharp.Tests { diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/PlainTextBodyTests.cs b/src/NSwag.CodeGeneration.CSharp.Tests/PlainTextBodyTests.cs index 7c489c6bdb..bb5ff04312 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/PlainTextBodyTests.cs +++ b/src/NSwag.CodeGeneration.CSharp.Tests/PlainTextBodyTests.cs @@ -1,5 +1,4 @@ -using System.Threading.Tasks; -using Xunit; +using Xunit; namespace NSwag.CodeGeneration.CSharp.Tests { diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/QueryParameterTests.cs b/src/NSwag.CodeGeneration.CSharp.Tests/QueryParameterTests.cs index 6d18a52803..50d3ec5d11 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/QueryParameterTests.cs +++ b/src/NSwag.CodeGeneration.CSharp.Tests/QueryParameterTests.cs @@ -1,5 +1,4 @@ -using System.Threading.Tasks; -using Xunit; +using Xunit; namespace NSwag.CodeGeneration.CSharp.Tests { diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/ResponseTests.cs b/src/NSwag.CodeGeneration.CSharp.Tests/ResponseTests.cs index b460c002bb..b6c9eeba56 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/ResponseTests.cs +++ b/src/NSwag.CodeGeneration.CSharp.Tests/ResponseTests.cs @@ -1,5 +1,4 @@ -using System.Threading.Tasks; -using Xunit; +using Xunit; namespace NSwag.CodeGeneration.CSharp.Tests { diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/UseCancellationTokenTests.cs b/src/NSwag.CodeGeneration.CSharp.Tests/UseCancellationTokenTests.cs index 43b334a792..4ee370e2e7 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/UseCancellationTokenTests.cs +++ b/src/NSwag.CodeGeneration.CSharp.Tests/UseCancellationTokenTests.cs @@ -1,7 +1,4 @@ -using System; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using NJsonSchema.Generation; +using Microsoft.AspNetCore.Mvc; using NJsonSchema.NewtonsoftJson.Generation; using NSwag.CodeGeneration.CSharp.Models; using NSwag.Generation.WebApi; diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/WrapResponsesTests.cs b/src/NSwag.CodeGeneration.CSharp.Tests/WrapResponsesTests.cs index f2fe7a81ce..e1aa72435a 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/WrapResponsesTests.cs +++ b/src/NSwag.CodeGeneration.CSharp.Tests/WrapResponsesTests.cs @@ -1,7 +1,4 @@ -using System; -using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; -using NJsonSchema.Generation; using NJsonSchema.NewtonsoftJson.Generation; using NSwag.Generation.WebApi; using Xunit; diff --git a/src/NSwag.CodeGeneration.CSharp/Models/CSharpParameterModel.cs b/src/NSwag.CodeGeneration.CSharp/Models/CSharpParameterModel.cs index b71ca9c4aa..ea6b4b1842 100644 --- a/src/NSwag.CodeGeneration.CSharp/Models/CSharpParameterModel.cs +++ b/src/NSwag.CodeGeneration.CSharp/Models/CSharpParameterModel.cs @@ -40,10 +40,10 @@ public CSharpParameterModel( } /// Gets a value indicating whether the type is a Nullable<>. - public bool IsSystemNullable => Type.EndsWith("?"); + public bool IsSystemNullable => Type.EndsWith('?'); /// Gets the type of the parameter when used in a controller interface where we can set default values before calling. - public string TypeInControllerInterface => HasDefault ? Type.EndsWith("?") ? Type.Substring(0, Type.Length - 1) : Type : Type; + public string TypeInControllerInterface => HasDefault ? Type.EndsWith('?') ? Type.Substring(0, Type.Length - 1) : Type : Type; /// Gets a value indicating whether the parameter name is a valid CSharp identifier. public bool IsValidIdentifier => Name.Equals(VariableName, StringComparison.OrdinalIgnoreCase); diff --git a/src/NSwag.CodeGeneration.CSharp/NSwag.CodeGeneration.CSharp.csproj b/src/NSwag.CodeGeneration.CSharp/NSwag.CodeGeneration.CSharp.csproj index be24928503..ddfe5057c7 100644 --- a/src/NSwag.CodeGeneration.CSharp/NSwag.CodeGeneration.CSharp.csproj +++ b/src/NSwag.CodeGeneration.CSharp/NSwag.CodeGeneration.CSharp.csproj @@ -6,6 +6,7 @@ + @@ -15,4 +16,5 @@ + \ No newline at end of file diff --git a/src/NSwag.CodeGeneration.Tests/CodeGenerationTests.cs b/src/NSwag.CodeGeneration.Tests/CodeGenerationTests.cs index 7b255103cd..6e7254c682 100644 --- a/src/NSwag.CodeGeneration.Tests/CodeGenerationTests.cs +++ b/src/NSwag.CodeGeneration.Tests/CodeGenerationTests.cs @@ -1,9 +1,5 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Text.RegularExpressions; -using System.Threading.Tasks; using NJsonSchema; using NJsonSchema.CodeGeneration.TypeScript; using NJsonSchema.Generation; diff --git a/src/NSwag.CodeGeneration.TypeScript.Tests/AngularJSTests.cs b/src/NSwag.CodeGeneration.TypeScript.Tests/AngularJSTests.cs index 5e7191c585..2c5fdeefc8 100644 --- a/src/NSwag.CodeGeneration.TypeScript.Tests/AngularJSTests.cs +++ b/src/NSwag.CodeGeneration.TypeScript.Tests/AngularJSTests.cs @@ -1,8 +1,6 @@ -using System.Threading.Tasks; -using Xunit; +using Xunit; using NSwag.Generation.WebApi; using Microsoft.AspNetCore.Mvc; -using NJsonSchema.Generation; using NJsonSchema; using NJsonSchema.NewtonsoftJson.Generation; diff --git a/src/NSwag.CodeGeneration.TypeScript.Tests/AngularTests.cs b/src/NSwag.CodeGeneration.TypeScript.Tests/AngularTests.cs index 7f23589e1d..9ea6574c29 100644 --- a/src/NSwag.CodeGeneration.TypeScript.Tests/AngularTests.cs +++ b/src/NSwag.CodeGeneration.TypeScript.Tests/AngularTests.cs @@ -1,9 +1,7 @@ -using System.Threading.Tasks; -using Xunit; +using Xunit; using NSwag.Generation.WebApi; using Microsoft.AspNetCore.Mvc; using System.ComponentModel.DataAnnotations; -using NJsonSchema.Generation; using NJsonSchema; using NJsonSchema.NewtonsoftJson.Generation; diff --git a/src/NSwag.CodeGeneration.TypeScript.Tests/ArrayParameterTests.cs b/src/NSwag.CodeGeneration.TypeScript.Tests/ArrayParameterTests.cs index 8e4bb474bc..9bf692ecfa 100644 --- a/src/NSwag.CodeGeneration.TypeScript.Tests/ArrayParameterTests.cs +++ b/src/NSwag.CodeGeneration.TypeScript.Tests/ArrayParameterTests.cs @@ -1,5 +1,4 @@ -using System.Threading.Tasks; -using Xunit; +using Xunit; namespace NSwag.CodeGeneration.TypeScript.Tests { diff --git a/src/NSwag.CodeGeneration.TypeScript.Tests/AxiosTests.cs b/src/NSwag.CodeGeneration.TypeScript.Tests/AxiosTests.cs index f23def4523..9ba3d13574 100644 --- a/src/NSwag.CodeGeneration.TypeScript.Tests/AxiosTests.cs +++ b/src/NSwag.CodeGeneration.TypeScript.Tests/AxiosTests.cs @@ -1,8 +1,6 @@ -using System.Threading.Tasks; -using Xunit; +using Xunit; using NSwag.Generation.WebApi; using Microsoft.AspNetCore.Mvc; -using NJsonSchema.Generation; using NJsonSchema; using NJsonSchema.NewtonsoftJson.Generation; diff --git a/src/NSwag.CodeGeneration.TypeScript.Tests/BinaryTests.cs b/src/NSwag.CodeGeneration.TypeScript.Tests/BinaryTests.cs index a16bd4a69d..4284ae23b5 100644 --- a/src/NSwag.CodeGeneration.TypeScript.Tests/BinaryTests.cs +++ b/src/NSwag.CodeGeneration.TypeScript.Tests/BinaryTests.cs @@ -1,5 +1,4 @@ -using System.Threading.Tasks; -using Xunit; +using Xunit; namespace NSwag.CodeGeneration.TypeScript.Tests { diff --git a/src/NSwag.CodeGeneration.TypeScript.Tests/FetchTests.cs b/src/NSwag.CodeGeneration.TypeScript.Tests/FetchTests.cs index e63973ad83..fadcc1d773 100644 --- a/src/NSwag.CodeGeneration.TypeScript.Tests/FetchTests.cs +++ b/src/NSwag.CodeGeneration.TypeScript.Tests/FetchTests.cs @@ -1,9 +1,7 @@ -using System.Threading.Tasks; -using Xunit; +using Xunit; using NSwag.Generation.WebApi; using Microsoft.AspNetCore.Mvc; using NJsonSchema; -using NJsonSchema.Generation; using NJsonSchema.NewtonsoftJson.Generation; namespace NSwag.CodeGeneration.TypeScript.Tests diff --git a/src/NSwag.CodeGeneration.TypeScript.Tests/InheritanceTests.cs b/src/NSwag.CodeGeneration.TypeScript.Tests/InheritanceTests.cs index c3d84cf174..9f324c21d1 100644 --- a/src/NSwag.CodeGeneration.TypeScript.Tests/InheritanceTests.cs +++ b/src/NSwag.CodeGeneration.TypeScript.Tests/InheritanceTests.cs @@ -1,5 +1,4 @@ -using System.Threading.Tasks; -using Xunit; +using Xunit; namespace NSwag.CodeGeneration.TypeScript.Tests { diff --git a/src/NSwag.CodeGeneration.TypeScript.Tests/JQueryCallbacksTests.cs b/src/NSwag.CodeGeneration.TypeScript.Tests/JQueryCallbacksTests.cs index a66b174bb9..dba038aead 100644 --- a/src/NSwag.CodeGeneration.TypeScript.Tests/JQueryCallbacksTests.cs +++ b/src/NSwag.CodeGeneration.TypeScript.Tests/JQueryCallbacksTests.cs @@ -1,8 +1,6 @@ -using System.Threading.Tasks; -using Xunit; +using Xunit; using NSwag.Generation.WebApi; using Microsoft.AspNetCore.Mvc; -using NJsonSchema.Generation; using NJsonSchema; using NJsonSchema.NewtonsoftJson.Generation; diff --git a/src/NSwag.CodeGeneration.TypeScript.Tests/JQueryPromisesTests.cs b/src/NSwag.CodeGeneration.TypeScript.Tests/JQueryPromisesTests.cs index 09c13d23a6..a344126cb9 100644 --- a/src/NSwag.CodeGeneration.TypeScript.Tests/JQueryPromisesTests.cs +++ b/src/NSwag.CodeGeneration.TypeScript.Tests/JQueryPromisesTests.cs @@ -1,7 +1,5 @@ -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using NJsonSchema; -using NJsonSchema.Generation; using NJsonSchema.NewtonsoftJson.Generation; using NSwag.Generation.WebApi; using Xunit; diff --git a/src/NSwag.CodeGeneration.TypeScript.Tests/ObjectParameterTests.cs b/src/NSwag.CodeGeneration.TypeScript.Tests/ObjectParameterTests.cs index e00b8a0c3c..a3c8bcc3aa 100644 --- a/src/NSwag.CodeGeneration.TypeScript.Tests/ObjectParameterTests.cs +++ b/src/NSwag.CodeGeneration.TypeScript.Tests/ObjectParameterTests.cs @@ -1,5 +1,4 @@ -using System.Threading.Tasks; -using Xunit; +using Xunit; namespace NSwag.CodeGeneration.TypeScript.Tests { diff --git a/src/NSwag.CodeGeneration.TypeScript.Tests/OperationParameterTests.cs b/src/NSwag.CodeGeneration.TypeScript.Tests/OperationParameterTests.cs index 3209b823e4..51fa37593e 100644 --- a/src/NSwag.CodeGeneration.TypeScript.Tests/OperationParameterTests.cs +++ b/src/NSwag.CodeGeneration.TypeScript.Tests/OperationParameterTests.cs @@ -1,14 +1,9 @@ -using System; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using NJsonSchema; using NSwag.Generation.WebApi; -using System.Collections.Generic; using Xunit; -using NJsonSchema.Generation; using NJsonSchema.NewtonsoftJson.Generation; namespace NSwag.CodeGeneration.TypeScript.Tests diff --git a/src/NSwag.CodeGeneration.TypeScript.Tests/TypeScriptDiscriminatorTests.cs b/src/NSwag.CodeGeneration.TypeScript.Tests/TypeScriptDiscriminatorTests.cs index fa786c18d3..c466101b8f 100644 --- a/src/NSwag.CodeGeneration.TypeScript.Tests/TypeScriptDiscriminatorTests.cs +++ b/src/NSwag.CodeGeneration.TypeScript.Tests/TypeScriptDiscriminatorTests.cs @@ -1,13 +1,10 @@ -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; using NJsonSchema.CodeGeneration.TypeScript; using NSwag.Generation.WebApi; -using System.Collections.Generic; using System.Runtime.Serialization; using Xunit; using NJsonSchema.NewtonsoftJson.Converters; -using NJsonSchema.Generation; using NJsonSchema; using NJsonSchema.NewtonsoftJson.Generation; diff --git a/src/NSwag.CodeGeneration.TypeScript.Tests/TypeScriptOperationParameterTests.cs b/src/NSwag.CodeGeneration.TypeScript.Tests/TypeScriptOperationParameterTests.cs index 6800448f47..7c6f38c8f0 100644 --- a/src/NSwag.CodeGeneration.TypeScript.Tests/TypeScriptOperationParameterTests.cs +++ b/src/NSwag.CodeGeneration.TypeScript.Tests/TypeScriptOperationParameterTests.cs @@ -1,8 +1,6 @@ -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using NJsonSchema; using NJsonSchema.CodeGeneration.TypeScript; -using NJsonSchema.Generation; using NJsonSchema.NewtonsoftJson.Generation; using NSwag.Generation.WebApi; using Xunit; diff --git a/src/NSwag.CodeGeneration/ClientGeneratorBase.cs b/src/NSwag.CodeGeneration/ClientGeneratorBase.cs index ec2c2e7472..eccc67c2dd 100644 --- a/src/NSwag.CodeGeneration/ClientGeneratorBase.cs +++ b/src/NSwag.CodeGeneration/ClientGeneratorBase.cs @@ -170,7 +170,7 @@ private List GetOperations(OpenApiDocument document) operationName = operationName.Replace(".", "_"); } - if (operationName.EndsWith("Async")) + if (operationName.EndsWith("Async", StringComparison.Ordinal)) { operationName = operationName.Substring(0, operationName.Length - "Async".Length); } diff --git a/src/NSwag.CodeGeneration/Models/OperationModelBase.cs b/src/NSwag.CodeGeneration/Models/OperationModelBase.cs index f8a2d14845..34f7232f1c 100644 --- a/src/NSwag.CodeGeneration/Models/OperationModelBase.cs +++ b/src/NSwag.CodeGeneration/Models/OperationModelBase.cs @@ -202,7 +202,7 @@ public TParameterModel ContentParameter public IEnumerable HeaderParameters => Parameters.Where(p => p.Kind == OpenApiParameterKind.Header); /// Gets or sets a value indicating whether the accept header is defined in a parameter. - public bool HasAcceptHeaderParameterParameter => HeaderParameters.Any(p => p.Name.ToLowerInvariant() == "accept"); + public bool HasAcceptHeaderParameterParameter => HeaderParameters.Any(p => p.Name.Equals("accept", StringComparison.OrdinalIgnoreCase)); /// Gets a value indicating whether the operation has form parameters. public bool HasFormParameters => Parameters.Any(p => p.Kind == OpenApiParameterKind.FormData); diff --git a/src/NSwag.Commands/Commands/Document/ExecuteDocumentCommand.cs b/src/NSwag.Commands/Commands/Document/ExecuteDocumentCommand.cs index 5bde415d9e..c7f485993b 100644 --- a/src/NSwag.Commands/Commands/Document/ExecuteDocumentCommand.cs +++ b/src/NSwag.Commands/Commands/Document/ExecuteDocumentCommand.cs @@ -24,7 +24,7 @@ public class ExecuteDocumentCommand : IConsoleCommand public async Task RunAsync(CommandLineProcessor processor, IConsoleHost host) { // input can be nix-like file path starting with / - if (!string.IsNullOrEmpty(Input) && (!Input.StartsWith("/") || File.Exists(Input) || Input.EndsWith("nswag.json")) && !Input.StartsWith("-")) + if (!string.IsNullOrEmpty(Input) && (!Input.StartsWith('/') || File.Exists(Input) || Input.EndsWith("nswag.json", StringComparison.OrdinalIgnoreCase)) && !Input.StartsWith('-')) { await ExecuteDocumentAsync(host, Input); } diff --git a/src/NSwag.Commands/Commands/Generation/AspNetCore/AspNetCoreToOpenApiCommand.cs b/src/NSwag.Commands/Commands/Generation/AspNetCore/AspNetCoreToOpenApiCommand.cs index f2b944b69a..555a66ce46 100644 --- a/src/NSwag.Commands/Commands/Generation/AspNetCore/AspNetCoreToOpenApiCommand.cs +++ b/src/NSwag.Commands/Commands/Generation/AspNetCore/AspNetCoreToOpenApiCommand.cs @@ -141,7 +141,7 @@ public override async Task RunAsync(CommandLineProcessor processor, ICon } if (projectMetadata.TargetFrameworkIdentifier == ".NETCoreApp" || - projectMetadata.TargetFrameworkIdentifier.StartsWith("net")) + projectMetadata.TargetFrameworkIdentifier.StartsWith("net", StringComparison.Ordinal)) { executable = "dotnet"; args.Add("exec"); diff --git a/src/NSwag.Commands/Commands/Generation/AspNetCore/Exe.cs b/src/NSwag.Commands/Commands/Generation/AspNetCore/Exe.cs index 6255bb734d..7f985a7263 100644 --- a/src/NSwag.Commands/Commands/Generation/AspNetCore/Exe.cs +++ b/src/NSwag.Commands/Commands/Generation/AspNetCore/Exe.cs @@ -78,7 +78,7 @@ private static string ToArguments(IReadOnlyList args) var argument = args[i]; if (i != 0) { - builder.Append(" "); + builder.Append(' '); } if (argument.IndexOf(' ') == -1) @@ -88,7 +88,7 @@ private static string ToArguments(IReadOnlyList args) continue; } - builder.Append("\""); + builder.Append('"'); var pendingBackslashs = 0; for (var j = 0; j < argument.Length; j++) @@ -113,7 +113,7 @@ private static string ToArguments(IReadOnlyList args) { if (pendingBackslashs == 1) { - builder.Append("\\"); + builder.Append('\\'); } else { @@ -133,7 +133,7 @@ private static string ToArguments(IReadOnlyList args) builder.Append('\\', pendingBackslashs * 2); } - builder.Append("\""); + builder.Append('"'); } return builder.ToString(); diff --git a/src/NSwag.Commands/Commands/OutputCommandBase.cs b/src/NSwag.Commands/Commands/OutputCommandBase.cs index 2c452de6c8..86e9b36b82 100644 --- a/src/NSwag.Commands/Commands/OutputCommandBase.cs +++ b/src/NSwag.Commands/Commands/OutputCommandBase.cs @@ -27,7 +27,7 @@ protected static Task ReadSwaggerDocumentAsync(string input) { if (!IsJson(input) && !IsYaml(input)) { - if (input.StartsWith("http://") || input.StartsWith("https://")) + if (input.StartsWith("http://", StringComparison.OrdinalIgnoreCase) || input.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) { if (input.EndsWith(".yaml", StringComparison.OrdinalIgnoreCase) || input.EndsWith(".yml", StringComparison.OrdinalIgnoreCase)) @@ -67,12 +67,12 @@ protected static Task ReadSwaggerDocumentAsync(string input) protected static bool IsJson(string data) { - return data.StartsWith("{"); + return data.StartsWith('{'); } protected static bool IsYaml(string data) { - return !IsJson(data) && data.Contains("\n"); + return !IsJson(data) && data.Contains('\n'); } protected Task TryWriteFileOutputAsync(IConsoleHost host, Func generator) diff --git a/src/NSwag.Commands/NSwag.Commands.csproj b/src/NSwag.Commands/NSwag.Commands.csproj index ac9c285766..0142c8b67a 100644 --- a/src/NSwag.Commands/NSwag.Commands.csproj +++ b/src/NSwag.Commands/NSwag.Commands.csproj @@ -45,4 +45,8 @@ + + + + diff --git a/src/NSwag.Commands/NSwagDocument.cs b/src/NSwag.Commands/NSwagDocument.cs index c024fdafd3..cbdab1cd65 100644 --- a/src/NSwag.Commands/NSwagDocument.cs +++ b/src/NSwag.Commands/NSwagDocument.cs @@ -138,7 +138,7 @@ public async Task ExecuteCommandLineAsync(bool r /// The absolute path. protected override string ConvertToAbsolutePath(string pathToConvert) { - if (!string.IsNullOrEmpty(pathToConvert) && !System.IO.Path.IsPathRooted(pathToConvert) && !pathToConvert.Contains("%")) + if (!string.IsNullOrEmpty(pathToConvert) && !System.IO.Path.IsPathRooted(pathToConvert) && !pathToConvert.Contains('%')) { return PathUtilities.MakeAbsolutePath(pathToConvert, GetDocumentDirectory()); } @@ -151,7 +151,7 @@ protected override string ConvertToAbsolutePath(string pathToConvert) /// The relative path. protected override string ConvertToRelativePath(string pathToConvert) { - if (!string.IsNullOrEmpty(pathToConvert) && !pathToConvert.Contains("C:\\Program Files\\") && !pathToConvert.Contains("%")) + if (!string.IsNullOrEmpty(pathToConvert) && !pathToConvert.Contains("C:\\Program Files\\") && !pathToConvert.Contains('%')) { return PathUtilities.MakeRelativePath(pathToConvert, GetDocumentDirectory())?.Replace("\\", "/"); } @@ -192,17 +192,17 @@ private async Task StartCommandLineProcessAsync(string command) if (process.ExitCode != 0) { - var errorStart = output.IndexOf("..."); + var errorStart = output.IndexOf("...", StringComparison.Ordinal); if (errorStart < 0) { errorStart = Regex.Match(output, "\n[^\n\r]*?Exception: .*", RegexOptions.Singleline)?.Index ?? -1; } var error = errorStart > 0 ? output.Substring(errorStart + 4) : output; - var stackTraceStart = error.IndexOf("Server stack trace: "); + var stackTraceStart = error.IndexOf("Server stack trace: ", StringComparison.Ordinal); if (stackTraceStart < 0) { - stackTraceStart = error.IndexOf(" at "); + stackTraceStart = error.IndexOf(" at ", StringComparison.Ordinal); } var message = stackTraceStart > 0 ? error.Substring(0, stackTraceStart) : error; diff --git a/src/NSwag.Commands/NSwagDocumentBase.cs b/src/NSwag.Commands/NSwagDocumentBase.cs index 9e0bf3640a..86f70be446 100644 --- a/src/NSwag.Commands/NSwagDocumentBase.cs +++ b/src/NSwag.Commands/NSwagDocumentBase.cs @@ -6,6 +6,8 @@ // Rico Suter, mail@rsuter.com //----------------------------------------------------------------------- +#pragma warning disable CA1507 + using System.ComponentModel; using System.Reflection; using System.Runtime.CompilerServices; @@ -308,7 +310,8 @@ private void ConvertToAbsolutePaths() { if (SwaggerGenerators.FromDocumentCommand != null) { - if (!SwaggerGenerators.FromDocumentCommand.Url.StartsWith("http://") && !SwaggerGenerators.FromDocumentCommand.Url.StartsWith("https://")) + if (!SwaggerGenerators.FromDocumentCommand.Url.StartsWith("http://", StringComparison.OrdinalIgnoreCase) + && !SwaggerGenerators.FromDocumentCommand.Url.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) { SwaggerGenerators.FromDocumentCommand.Url = ConvertToAbsolutePath(SwaggerGenerators.FromDocumentCommand.Url); } @@ -372,7 +375,8 @@ private void ConvertToRelativePaths() { if (SwaggerGenerators.FromDocumentCommand != null) { - if (!SwaggerGenerators.FromDocumentCommand.Url.StartsWith("http://") && !SwaggerGenerators.FromDocumentCommand.Url.StartsWith("https://")) + if (!SwaggerGenerators.FromDocumentCommand.Url.StartsWith("http://", StringComparison.OrdinalIgnoreCase) + && !SwaggerGenerators.FromDocumentCommand.Url.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) { SwaggerGenerators.FromDocumentCommand.Url = ConvertToRelativePath(SwaggerGenerators.FromDocumentCommand.Url); } @@ -436,7 +440,7 @@ private static string TransformLegacyDocument(string data, out bool saveFile) saveFile = false; // Swagger to OpenApi rename - if (data.Contains("\"typeScriptVersion\":") && !data.ToLowerInvariant().Contains("ExceptionClass".ToLowerInvariant())) + if (data.Contains("\"typeScriptVersion\":") && !data.Contains("ExceptionClass", StringComparison.OrdinalIgnoreCase)) { data = data.Replace("\"typeScriptVersion\":", "\"exceptionClass\": \"SwaggerException\", \"typeScriptVersion\":"); saveFile = true; @@ -509,7 +513,7 @@ private static string TransformLegacyDocument(string data, out bool saveFile) saveFile = true; } - if (data.Contains("\"noBuild\":") && !data.ToLowerInvariant().Contains("RequireParametersWithoutDefault".ToLowerInvariant())) + if (data.Contains("\"noBuild\":") && !data.Contains("RequireParametersWithoutDefault", StringComparison.OrdinalIgnoreCase)) { data = data.Replace("\"noBuild\":", "\"requireParametersWithoutDefault\": true, \"noBuild\":"); saveFile = true; diff --git a/src/NSwag.Commands/PathUtilities.cs b/src/NSwag.Commands/PathUtilities.cs index 85c73682f9..538fb178a9 100644 --- a/src/NSwag.Commands/PathUtilities.cs +++ b/src/NSwag.Commands/PathUtilities.cs @@ -29,14 +29,14 @@ public static IEnumerable ExpandFileWildcards(IEnumerable paths) var allFiles = new List(); foreach (var path in paths) { - if (path.Contains("*")) + if (path.Contains('*')) { - var starIndex = path.IndexOf("*", StringComparison.Ordinal); + var starIndex = path.IndexOf('*'); - var rootIndex = path.Substring(0, starIndex).LastIndexOf("\\", StringComparison.Ordinal); + var rootIndex = path.Substring(0, starIndex).LastIndexOf('\\'); if (rootIndex == -1) { - rootIndex = path.Substring(0, starIndex).LastIndexOf("/", StringComparison.Ordinal); + rootIndex = path.Substring(0, starIndex).LastIndexOf('/'); } var rootPath = rootIndex >= 0 ? path.Substring(0, rootIndex + 1) : Directory.GetCurrentDirectory(); diff --git a/src/NSwag.Console/Program.cs b/src/NSwag.Console/Program.cs index 443df81c4e..2808c7277b 100644 --- a/src/NSwag.Console/Program.cs +++ b/src/NSwag.Console/Program.cs @@ -1,6 +1,4 @@ -using System; -using System.Threading.Tasks; -using NConsole; +using NConsole; using NSwag.Commands; namespace NSwag diff --git a/src/NSwag.ConsoleCore.Tests/GenerateSampleSpecificationTests.cs b/src/NSwag.ConsoleCore.Tests/GenerateSampleSpecificationTests.cs index 460acad83c..77db1a102d 100644 --- a/src/NSwag.ConsoleCore.Tests/GenerateSampleSpecificationTests.cs +++ b/src/NSwag.ConsoleCore.Tests/GenerateSampleSpecificationTests.cs @@ -1,8 +1,4 @@ using System.Diagnostics; -using System.IO; -using System.Threading.Tasks; -using VerifyXunit; -using Xunit; namespace NSwag.ConsoleCore.Tests { diff --git a/src/NSwag.Core.Tests/DocumentLoadingTests.cs b/src/NSwag.Core.Tests/DocumentLoadingTests.cs index cb37ab648a..bd5860902e 100644 --- a/src/NSwag.Core.Tests/DocumentLoadingTests.cs +++ b/src/NSwag.Core.Tests/DocumentLoadingTests.cs @@ -1,7 +1,4 @@ using System.Globalization; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; using NJsonSchema; using Xunit; diff --git a/src/NSwag.Core.Tests/DocumentReferenceTests.cs b/src/NSwag.Core.Tests/DocumentReferenceTests.cs index a34d30ccbb..463b3155eb 100644 --- a/src/NSwag.Core.Tests/DocumentReferenceTests.cs +++ b/src/NSwag.Core.Tests/DocumentReferenceTests.cs @@ -1,6 +1,4 @@ -using System.Linq; -using System.Threading.Tasks; -using Xunit; +using Xunit; namespace NSwag.Core.Tests { diff --git a/src/NSwag.Core.Tests/HttpLoadingTests.cs b/src/NSwag.Core.Tests/HttpLoadingTests.cs index 6da009c3ed..ba9fca391b 100644 --- a/src/NSwag.Core.Tests/HttpLoadingTests.cs +++ b/src/NSwag.Core.Tests/HttpLoadingTests.cs @@ -1,5 +1,4 @@ -using System.Threading.Tasks; -using Xunit; +using Xunit; namespace NSwag.Core.Tests { diff --git a/src/NSwag.Core.Tests/OperationIdTests.cs b/src/NSwag.Core.Tests/OperationIdTests.cs index 8d5af3423f..a31aa20466 100644 --- a/src/NSwag.Core.Tests/OperationIdTests.cs +++ b/src/NSwag.Core.Tests/OperationIdTests.cs @@ -1,5 +1,4 @@ -using System.Linq; -using Xunit; +using Xunit; namespace NSwag.Core.Tests { diff --git a/src/NSwag.Core.Tests/Serialization/ComponentsSerializationTests.cs b/src/NSwag.Core.Tests/Serialization/ComponentsSerializationTests.cs index 66b3dd9562..90447e56c7 100644 --- a/src/NSwag.Core.Tests/Serialization/ComponentsSerializationTests.cs +++ b/src/NSwag.Core.Tests/Serialization/ComponentsSerializationTests.cs @@ -1,4 +1,3 @@ -using System.Threading.Tasks; using NJsonSchema; using Xunit; diff --git a/src/NSwag.Core.Tests/Serialization/ExampleSerializationTests.cs b/src/NSwag.Core.Tests/Serialization/ExampleSerializationTests.cs index 12d656ad0b..17cba6c76f 100644 --- a/src/NSwag.Core.Tests/Serialization/ExampleSerializationTests.cs +++ b/src/NSwag.Core.Tests/Serialization/ExampleSerializationTests.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; -using System.Threading.Tasks; using NJsonSchema; using Xunit; diff --git a/src/NSwag.Core.Tests/Serialization/ExternalReferenceTests.cs b/src/NSwag.Core.Tests/Serialization/ExternalReferenceTests.cs index 03c0eabf3f..0f5f3e8962 100644 --- a/src/NSwag.Core.Tests/Serialization/ExternalReferenceTests.cs +++ b/src/NSwag.Core.Tests/Serialization/ExternalReferenceTests.cs @@ -1,6 +1,4 @@ -using System.Linq; -using System.Threading.Tasks; -using Xunit; +using Xunit; namespace NSwag.Core.Tests.Serialization { diff --git a/src/NSwag.Core.Tests/Serialization/NullDefinitionTests.cs b/src/NSwag.Core.Tests/Serialization/NullDefinitionTests.cs index fbc96b8656..033ed970c6 100644 --- a/src/NSwag.Core.Tests/Serialization/NullDefinitionTests.cs +++ b/src/NSwag.Core.Tests/Serialization/NullDefinitionTests.cs @@ -1,5 +1,4 @@ -using System.Threading.Tasks; -using Xunit; +using Xunit; namespace NSwag.Core.Tests.Serialization { diff --git a/src/NSwag.Core.Tests/Serialization/PathItemTests.cs b/src/NSwag.Core.Tests/Serialization/PathItemTests.cs index 16affc0735..00ea1a4f53 100644 --- a/src/NSwag.Core.Tests/Serialization/PathItemTests.cs +++ b/src/NSwag.Core.Tests/Serialization/PathItemTests.cs @@ -1,7 +1,4 @@ -using System; -using System.IO; -using System.Reflection; -using System.Threading.Tasks; +using System.Reflection; using Xunit; namespace NSwag.Core.Tests.Serialization diff --git a/src/NSwag.Core.Tests/Serialization/RequestBodySerializationTests.cs b/src/NSwag.Core.Tests/Serialization/RequestBodySerializationTests.cs index 25397e8831..bda4c131db 100644 --- a/src/NSwag.Core.Tests/Serialization/RequestBodySerializationTests.cs +++ b/src/NSwag.Core.Tests/Serialization/RequestBodySerializationTests.cs @@ -1,5 +1,3 @@ -using System.Linq; -using System.Threading.Tasks; using NJsonSchema; using Xunit; diff --git a/src/NSwag.Core.Tests/Serialization/ServersSerializationTests.cs b/src/NSwag.Core.Tests/Serialization/ServersSerializationTests.cs index 4466e3122d..0bc78d3215 100644 --- a/src/NSwag.Core.Tests/Serialization/ServersSerializationTests.cs +++ b/src/NSwag.Core.Tests/Serialization/ServersSerializationTests.cs @@ -1,5 +1,4 @@ -using System.Linq; -using NJsonSchema; +using NJsonSchema; using Xunit; namespace NSwag.Core.Tests.Serialization diff --git a/src/NSwag.Core.Yaml.Tests/References/YamlReferencesTests.cs b/src/NSwag.Core.Yaml.Tests/References/YamlReferencesTests.cs index 69329e7235..dcab0bbc10 100644 --- a/src/NSwag.Core.Yaml.Tests/References/YamlReferencesTests.cs +++ b/src/NSwag.Core.Yaml.Tests/References/YamlReferencesTests.cs @@ -1,7 +1,4 @@ -using System; -using System.IO; -using System.Reflection; -using System.Threading.Tasks; +using System.Reflection; using NJsonSchema; using Xunit; diff --git a/src/NSwag.Core.Yaml.Tests/YamlDocumentTests.cs b/src/NSwag.Core.Yaml.Tests/YamlDocumentTests.cs index 42426884ae..b6c22aa460 100644 --- a/src/NSwag.Core.Yaml.Tests/YamlDocumentTests.cs +++ b/src/NSwag.Core.Yaml.Tests/YamlDocumentTests.cs @@ -1,6 +1,4 @@ -using System.Linq; -using System.Threading.Tasks; -using Newtonsoft.Json.Linq; +using Newtonsoft.Json.Linq; using Xunit; namespace NSwag.Core.Yaml.Tests diff --git a/src/NSwag.Core.Yaml/OpenApiYamlDocument.cs b/src/NSwag.Core.Yaml/OpenApiYamlDocument.cs index 3e8f134a4d..5e9a206dcc 100644 --- a/src/NSwag.Core.Yaml/OpenApiYamlDocument.cs +++ b/src/NSwag.Core.Yaml/OpenApiYamlDocument.cs @@ -6,11 +6,7 @@ // Rico Suter, mail@rsuter.com //----------------------------------------------------------------------- -using System; using System.Dynamic; -using System.IO; -using System.Threading; -using System.Threading.Tasks; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using NJsonSchema; diff --git a/src/NSwag.Core/Collections/ObservableDictionary.cs b/src/NSwag.Core/Collections/ObservableDictionary.cs index 5b28de0418..c2f36476ad 100644 --- a/src/NSwag.Core/Collections/ObservableDictionary.cs +++ b/src/NSwag.Core/Collections/ObservableDictionary.cs @@ -73,7 +73,7 @@ public void AddRange(IDictionary items) { if (items == null) { - throw new ArgumentNullException("items"); + throw new ArgumentNullException(nameof(items)); } if (items.Count > 0) @@ -171,10 +171,10 @@ protected void OnCollectionChanged(NotifyCollectionChangedAction action, IList n private void OnPropertyChanged() { - OnPropertyChanged("Count"); + OnPropertyChanged(nameof(Count)); OnPropertyChanged("Item[]"); - OnPropertyChanged("Keys"); - OnPropertyChanged("Values"); + OnPropertyChanged(nameof(Keys)); + OnPropertyChanged(nameof(Values)); } #region IDictionary interface @@ -215,7 +215,7 @@ public virtual bool Remove(TKey key) { if (key == null) { - throw new ArgumentNullException("key"); + throw new ArgumentNullException(nameof(key)); } var removed = _dictionary.Remove(key); diff --git a/src/NSwag.Core/HttpUtilities.cs b/src/NSwag.Core/HttpUtilities.cs index 2bb356ee4a..3611375e7e 100644 --- a/src/NSwag.Core/HttpUtilities.cs +++ b/src/NSwag.Core/HttpUtilities.cs @@ -16,7 +16,7 @@ public static class HttpUtilities /// true if success. public static bool IsSuccessStatusCode(string statusCode) { - return statusCode.Length == 3 && statusCode.StartsWith("2"); + return statusCode.Length == 3 && statusCode.StartsWith("2", StringComparison.Ordinal); } } } diff --git a/src/NSwag.Core/OpenApiDocument.Serialization.cs b/src/NSwag.Core/OpenApiDocument.Serialization.cs index 9f2fdca4ff..8cf0011369 100644 --- a/src/NSwag.Core/OpenApiDocument.Serialization.cs +++ b/src/NSwag.Core/OpenApiDocument.Serialization.cs @@ -148,7 +148,7 @@ public ICollection Schemes _schemes = new ObservableCollection(Servers? .Where(s => s.Url.Contains("://")) - .Select(s => s.Url.StartsWith("http://") ? OpenApiSchema.Http : OpenApiSchema.Https) + .Select(s => s.Url.StartsWith("http://", StringComparison.OrdinalIgnoreCase) ? OpenApiSchema.Http : OpenApiSchema.Https) .Distinct() ?? []); _schemes.CollectionChanged += OnSchemesChanged; diff --git a/src/NSwag.Core/OpenApiDocument.cs b/src/NSwag.Core/OpenApiDocument.cs index 8c5624914b..aa61242a41 100644 --- a/src/NSwag.Core/OpenApiDocument.cs +++ b/src/NSwag.Core/OpenApiDocument.cs @@ -6,7 +6,6 @@ // Rico Suter, mail@rsuter.com //----------------------------------------------------------------------- -using System.Collections.ObjectModel; using System.Reflection; using System.Text.RegularExpressions; using Newtonsoft.Json; @@ -176,14 +175,14 @@ public static async Task FromJsonAsync(string data, string docu var match = Regex.Match(data, pattern, RegexOptions.IgnoreCase); if (match.Success) { - var schemaType = match.Groups["schemaType"].Value.ToLower(); - var schemaVersion = match.Groups["schemaVersion"].Value.ToLower(); + var schemaType = match.Groups["schemaType"].Value.ToLowerInvariant(); + var schemaVersion = match.Groups["schemaVersion"].Value.ToLowerInvariant(); - if (schemaType == "swagger" && schemaVersion.StartsWith("2")) + if (schemaType == "swagger" && schemaVersion.StartsWith("2", StringComparison.Ordinal)) { expectedSchemaType = SchemaType.Swagger2; } - else if (schemaType == "openapi" && schemaVersion.StartsWith("3")) + else if (schemaType == "openapi" && schemaVersion.StartsWith("3", StringComparison.Ordinal)) { expectedSchemaType = SchemaType.OpenApi3; } @@ -297,7 +296,7 @@ public void GenerateOperationIds() { if (group.Count() > 1) { - var methods = group.Select(o => o.Method.ToUpper()).Distinct(); + var methods = group.Select(o => o.Method.ToUpperInvariant()).Distinct(); if (methods.Count() == 1) { continue; @@ -305,7 +304,7 @@ public void GenerateOperationIds() foreach (var o in group) { - o.Operation.OperationId += o.Method.ToUpper(); + o.Operation.OperationId += o.Method.ToUpperInvariant(); } } } diff --git a/src/NSwag.Core/OpenApiServerVariable.cs b/src/NSwag.Core/OpenApiServerVariable.cs index 7c9b0da86c..436c6de2eb 100644 --- a/src/NSwag.Core/OpenApiServerVariable.cs +++ b/src/NSwag.Core/OpenApiServerVariable.cs @@ -7,7 +7,6 @@ //----------------------------------------------------------------------- using Newtonsoft.Json; -using System.Collections.ObjectModel; namespace NSwag { diff --git a/src/NSwag.Core/Polyfills.cs b/src/NSwag.Core/Polyfills.cs new file mode 100644 index 0000000000..8453ce3f50 --- /dev/null +++ b/src/NSwag.Core/Polyfills.cs @@ -0,0 +1,10 @@ +namespace NSwag; + +internal static class Polyfills +{ +#if !NETCOREAPP + public static bool StartsWith(this string str, char c) => str.Length > 0 && str[0] == c; + public static bool EndsWith(this string str, char c) => str.Length > 0 && str[str.Length - 1] == c; + public static bool Contains(this string str, string s, StringComparison comparison) => str.IndexOf(s, comparison) != -1; +#endif +} \ No newline at end of file diff --git a/src/NSwag.Generation.AspNetCore.Tests/Processors/OperationResponseProcessorTest.cs b/src/NSwag.Generation.AspNetCore.Tests/Processors/OperationResponseProcessorTest.cs index 70985fc25a..b9bb6add41 100644 --- a/src/NSwag.Generation.AspNetCore.Tests/Processors/OperationResponseProcessorTest.cs +++ b/src/NSwag.Generation.AspNetCore.Tests/Processors/OperationResponseProcessorTest.cs @@ -9,7 +9,6 @@ using Microsoft.AspNetCore.Mvc.ApiExplorer; using NJsonSchema; using NJsonSchema.NewtonsoftJson.Generation; -using System.Collections.Generic; using System.Reflection; using Xunit; diff --git a/src/NSwag.Generation.AspNetCore.Tests/Responses/ProducesTests.cs b/src/NSwag.Generation.AspNetCore.Tests/Responses/ProducesTests.cs index 45a72ab53f..31bc5d2dc0 100644 --- a/src/NSwag.Generation.AspNetCore.Tests/Responses/ProducesTests.cs +++ b/src/NSwag.Generation.AspNetCore.Tests/Responses/ProducesTests.cs @@ -1,7 +1,6 @@ using System.Linq; using System.Threading.Tasks; using NJsonSchema; -using NJsonSchema.Generation; using NJsonSchema.NewtonsoftJson.Generation; using NSwag.Generation.AspNetCore.Tests.Web.Controllers.Responses; using Xunit; diff --git a/src/NSwag.Generation.AspNetCore.Tests/Responses/WrappedResponseTests.cs b/src/NSwag.Generation.AspNetCore.Tests/Responses/WrappedResponseTests.cs index 57c61ec5bc..beba9b3068 100644 --- a/src/NSwag.Generation.AspNetCore.Tests/Responses/WrappedResponseTests.cs +++ b/src/NSwag.Generation.AspNetCore.Tests/Responses/WrappedResponseTests.cs @@ -1,5 +1,4 @@ -using System; -using System.Linq; +using System.Linq; using System.Threading.Tasks; using Xunit; @@ -8,7 +7,6 @@ using NSwag.Generation.AspNetCore.Tests.Web.Controllers.Responses; using NJsonSchema.NewtonsoftJson.Generation; -using NJsonSchema.Generation; namespace NSwag.Generation.AspNetCore.Tests.Responses { diff --git a/src/NSwag.Generation.AspNetCore.Tests/SystemTextJsonTests.cs b/src/NSwag.Generation.AspNetCore.Tests/SystemTextJsonTests.cs index 3805b6a4e0..669265e91c 100644 --- a/src/NSwag.Generation.AspNetCore.Tests/SystemTextJsonTests.cs +++ b/src/NSwag.Generation.AspNetCore.Tests/SystemTextJsonTests.cs @@ -2,7 +2,6 @@ using Microsoft.Extensions.DependencyInjection; using System.Text.Json.Serialization; using System.Threading.Tasks; -using Newtonsoft.Json.Converters; using NSwag.AspNetCore; using Xunit; using NJsonSchema.Generation; diff --git a/src/NSwag.Generation.AspNetCore/AspNetCoreOpenApiDocumentGenerator.cs b/src/NSwag.Generation.AspNetCore/AspNetCoreOpenApiDocumentGenerator.cs index 2d93811210..08e38d97dc 100644 --- a/src/NSwag.Generation.AspNetCore/AspNetCoreOpenApiDocumentGenerator.cs +++ b/src/NSwag.Generation.AspNetCore/AspNetCoreOpenApiDocumentGenerator.cs @@ -215,7 +215,7 @@ private List GenerateApiGroups( } var path = apiDescription.RelativePath; - if (!path.StartsWith("/", StringComparison.Ordinal)) + if (!path.StartsWith('/')) { path = "/" + path; } @@ -531,8 +531,8 @@ private string GetOperationId(OpenApiDocument document, ApiDescription apiDescri httpMethod[0].ToString().ToUpperInvariant() + httpMethod.Substring(1) + string.Join("", apiDescription.RelativePath .Split('/', '\\', '}', ']', '-', '_') - .Where(t => !t.StartsWith("{")) - .Where(t => !t.StartsWith("[")) + .Where(t => !t.StartsWith('{')) + .Where(t => !t.StartsWith('[')) .Select(t => t.Length > 1 ? t[0].ToString().ToUpperInvariant() + t.Substring(1) : t.ToUpperInvariant())); } @@ -547,7 +547,7 @@ private string GetOperationId(OpenApiDocument document, ApiDescription apiDescri private static string GetActionName(string actionName) { - if (actionName.EndsWith("Async")) + if (actionName.EndsWith("Async", StringComparison.Ordinal)) { actionName = actionName.Substring(0, actionName.Length - 5); } diff --git a/src/NSwag.Generation.AspNetCore/NSwag.Generation.AspNetCore.csproj b/src/NSwag.Generation.AspNetCore/NSwag.Generation.AspNetCore.csproj index 93c97ac420..47b2dad663 100644 --- a/src/NSwag.Generation.AspNetCore/NSwag.Generation.AspNetCore.csproj +++ b/src/NSwag.Generation.AspNetCore/NSwag.Generation.AspNetCore.csproj @@ -27,4 +27,9 @@ + + + + + diff --git a/src/NSwag.Generation.AspNetCore/Processors/OperationParameterProcessor.cs b/src/NSwag.Generation.AspNetCore/Processors/OperationParameterProcessor.cs index 46fd126115..79f38a726d 100644 --- a/src/NSwag.Generation.AspNetCore/Processors/OperationParameterProcessor.cs +++ b/src/NSwag.Generation.AspNetCore/Processors/OperationParameterProcessor.cs @@ -87,7 +87,7 @@ public bool Process(OperationProcessorContext operationProcessorContext) { var parameterDescriptor = apiParameter.TryGetPropertyValue("ParameterDescriptor"); var parameterName = parameterDescriptor?.Name ?? apiParameter.Name; - parameter = methodParameters.FirstOrDefault(m => m.Name.ToLowerInvariant() == parameterName.ToLowerInvariant()); + parameter = methodParameters.FirstOrDefault(m => m.Name.Equals(parameterName, StringComparison.OrdinalIgnoreCase)); if (parameter != null) { extendedApiParameter.ParameterInfo = parameter; @@ -112,8 +112,8 @@ public bool Process(OperationProcessorContext operationProcessorContext) if (apiParameter.Source == BindingSource.Path) { // ignore unused implicit path parameters - if (!httpPath.ToLowerInvariant().Contains("{" + apiParameter.Name.ToLowerInvariant() + ":") && - !httpPath.ToLowerInvariant().Contains("{" + apiParameter.Name.ToLowerInvariant() + "}")) + if (!httpPath.Contains("{" + apiParameter.Name + ":", StringComparison.OrdinalIgnoreCase) && + !httpPath.Contains("{" + apiParameter.Name + "}", StringComparison.OrdinalIgnoreCase)) { continue; } diff --git a/src/NSwag.Generation.AspNetCore/Processors/OperationResponseProcessor.cs b/src/NSwag.Generation.AspNetCore/Processors/OperationResponseProcessor.cs index 63befcf6ae..d2e7573884 100644 --- a/src/NSwag.Generation.AspNetCore/Processors/OperationResponseProcessor.cs +++ b/src/NSwag.Generation.AspNetCore/Processors/OperationResponseProcessor.cs @@ -81,7 +81,7 @@ public bool Process(OperationProcessorContext operationProcessorContext) var nullableXmlAttribute = GetResponseXmlDocsElement(context.MethodInfo, httpStatusCode)?.Attribute("nullable"); var isResponseNullable = nullableXmlAttribute != null ? - nullableXmlAttribute.Value.ToLowerInvariant() == "true" : + nullableXmlAttribute.Value.Equals("true", StringComparison.OrdinalIgnoreCase) : _settings.SchemaSettings.ReflectionService.GetDescription(contextualReturnType, _settings.DefaultResponseReferenceTypeNullHandling, _settings.SchemaSettings).IsNullable; response.IsNullableRaw = isResponseNullable; diff --git a/src/NSwag.Generation.WebApi/Processors/OperationParameterProcessor.cs b/src/NSwag.Generation.WebApi/Processors/OperationParameterProcessor.cs index 984e7795fe..3c9c2bc682 100644 --- a/src/NSwag.Generation.WebApi/Processors/OperationParameterProcessor.cs +++ b/src/NSwag.Generation.WebApi/Processors/OperationParameterProcessor.cs @@ -462,8 +462,8 @@ private OpenApiParameter AddPrimitiveParametersFromUri( InitializeFileParameter(operationParameter, isFileArray); } else if (fromRouteAttribute != null - || httpPath.ToLowerInvariant().Contains("{" + propertyName.ToLower() + "}") - || httpPath.ToLowerInvariant().Contains("{" + propertyName.ToLower() + ":")) + || httpPath.IndexOf("{" + propertyName + "}", StringComparison.OrdinalIgnoreCase) != -1 + || httpPath.IndexOf("{" + propertyName + ":", StringComparison.OrdinalIgnoreCase) != -1) { operationParameter.Kind = OpenApiParameterKind.Path; operationParameter.IsNullableRaw = false; diff --git a/src/NSwag.Generation.WebApi/WebApiOpenApiDocumentGenerator.cs b/src/NSwag.Generation.WebApi/WebApiOpenApiDocumentGenerator.cs index dec729ea78..bbe68da2b8 100644 --- a/src/NSwag.Generation.WebApi/WebApiOpenApiDocumentGenerator.cs +++ b/src/NSwag.Generation.WebApi/WebApiOpenApiDocumentGenerator.cs @@ -34,7 +34,7 @@ public static IEnumerable GetControllerClasses(Assembly assembly) // TODO: Move to IControllerClassLoader interface return assembly.ExportedTypes .Where(t => !t.GetTypeInfo().IsAbstract) - .Where(t => t.Name.EndsWith("Controller") || + .Where(t => t.Name.EndsWith("Controller", StringComparison.Ordinal) || t.InheritsFromTypeName("ApiController", TypeNameStyle.Name) || t.InheritsFromTypeName("ControllerBase", TypeNameStyle.Name)) // in ASP.NET Core, a Web API controller inherits from Controller .Where(t => t.GetTypeInfo().ImplementedInterfaces.All(i => i.FullName != "System.Web.Mvc.IController")) // no MVC controllers (legacy ASP.NET) @@ -281,7 +281,7 @@ private static IEnumerable GetActionMethods(Type controllerType) m.GetCustomAttributes().Select(a => a.GetType()).All(a => !a.IsAssignableToTypeName("SwaggerIgnoreAttribute", TypeNameStyle.Name) && !a.IsAssignableToTypeName("NonActionAttribute", TypeNameStyle.Name)) && - !m.DeclaringType.FullName.StartsWith("Microsoft.AspNet") && // .NET Core (Web API & MVC) + !m.DeclaringType.FullName.StartsWith("Microsoft.AspNet", StringComparison.Ordinal) && // .NET Core (Web API & MVC) m.DeclaringType.FullName != "System.Web.Http.ApiController" && m.DeclaringType.FullName != "System.Web.Mvc.Controller") .Where(m => @@ -320,7 +320,7 @@ private string GetOperationId(OpenApiDocument document, string controllerName, M } else { - if (controllerName.EndsWith("Controller")) + if (controllerName.EndsWith("Controller", StringComparison.Ordinal)) { controllerName = controllerName.Substring(0, controllerName.Length - 10); } @@ -352,7 +352,7 @@ private List GetHttpPaths(Type controllerType, MethodInfo method) { foreach (var attribute in routeAttributes) { - if (attribute.Template.StartsWith("~/")) // ignore route prefixes + if (attribute.Template.StartsWith("~/", StringComparison.Ordinal)) // ignore route prefixes { httpPaths.Add(attribute.Template.Substring(1)); } @@ -362,7 +362,7 @@ private List GetHttpPaths(Type controllerType, MethodInfo method) } else if (routeAttributesOnClass != null) { - if (attribute.Template.StartsWith("/")) + if (attribute.Template.StartsWith("/", StringComparison.Ordinal)) { httpPaths.Add(attribute.Template); } @@ -424,10 +424,10 @@ private static IEnumerable ExpandOptionalHttpPathParameters(string path, for (int i = 0; i < segments.Length; i++) { var segment = segments[i]; - if (segment.EndsWith("?}")) + if (segment.EndsWith("?}", StringComparison.Ordinal)) { // Only expand if optional parameter is available in action method - if (method.GetParameters().Any(p => segment.StartsWith("{" + p.Name + ":") || segment.StartsWith("{" + p.Name + "?"))) + if (method.GetParameters().Any(p => segment.StartsWith("{" + p.Name + ":", StringComparison.Ordinal) || segment.StartsWith("{" + p.Name + "?", StringComparison.Ordinal))) { foreach (var p in ExpandOptionalHttpPathParameters(string.Join("/", segments.Take(i).Concat([segment.Replace("?", "")]).Concat(segments.Skip(i + 1))), method)) { @@ -506,7 +506,7 @@ private static string GetActionName(MethodInfo method) } var methodName = method.Name; - if (methodName.EndsWith("Async")) + if (methodName.EndsWith("Async", StringComparison.Ordinal)) { methodName = methodName.Substring(0, methodName.Length - 5); } diff --git a/src/NSwag.Generation/Processors/OperationResponseProcessorBase.cs b/src/NSwag.Generation/Processors/OperationResponseProcessorBase.cs index f76492c2af..a979aa64c8 100644 --- a/src/NSwag.Generation/Processors/OperationResponseProcessorBase.cs +++ b/src/NSwag.Generation/Processors/OperationResponseProcessorBase.cs @@ -191,7 +191,7 @@ private void ProcessOperationDescriptions(IEnumerable r.IsNullable) && _settings.SchemaSettings.ReflectionService.GetDescription(contextualReturnType, _settings.DefaultResponseReferenceTypeNullHandling, _settings.SchemaSettings).IsNullable; diff --git a/src/NSwag.Generation/Processors/OperationTagsProcessor.cs b/src/NSwag.Generation/Processors/OperationTagsProcessor.cs index 5d3a245c7a..f92d1a5bc7 100644 --- a/src/NSwag.Generation/Processors/OperationTagsProcessor.cs +++ b/src/NSwag.Generation/Processors/OperationTagsProcessor.cs @@ -52,7 +52,7 @@ public virtual bool Process(OperationProcessorContext context) protected virtual void AddControllerNameTag(OperationProcessorContext context) { var controllerName = context.ControllerType.Name; - if (controllerName.EndsWith("Controller")) + if (controllerName.EndsWith("Controller", StringComparison.Ordinal)) { controllerName = controllerName.Substring(0, controllerName.Length - 10); } diff --git a/src/NSwag.Generation/Processors/Security/SecurityDefinitionAppender.cs b/src/NSwag.Generation/Processors/Security/SecurityDefinitionAppender.cs index 877628e0f2..8274358f04 100644 --- a/src/NSwag.Generation/Processors/Security/SecurityDefinitionAppender.cs +++ b/src/NSwag.Generation/Processors/Security/SecurityDefinitionAppender.cs @@ -6,7 +6,6 @@ // Rico Suter, mail@rsuter.com //----------------------------------------------------------------------- -using System.Collections.ObjectModel; using NSwag.Generation.Processors.Contexts; namespace NSwag.Generation.Processors.Security diff --git a/src/NSwag.Sample.NET80/Controllers/ValuesController.cs b/src/NSwag.Sample.NET80/Controllers/ValuesController.cs index 55dc375a18..81b47c9db6 100644 --- a/src/NSwag.Sample.NET80/Controllers/ValuesController.cs +++ b/src/NSwag.Sample.NET80/Controllers/ValuesController.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; namespace NSwag.Sample.NET80.Controllers { diff --git a/src/NSwag.Sample.NET80/Program.cs b/src/NSwag.Sample.NET80/Program.cs index 3a722a0021..54ec290542 100644 --- a/src/NSwag.Sample.NET80/Program.cs +++ b/src/NSwag.Sample.NET80/Program.cs @@ -1,6 +1,3 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; - namespace NSwag.Sample.NET80 { public class Program diff --git a/src/NSwag.Sample.NET80/Startup.cs b/src/NSwag.Sample.NET80/Startup.cs index 081b29c39a..9fa60a6def 100644 --- a/src/NSwag.Sample.NET80/Startup.cs +++ b/src/NSwag.Sample.NET80/Startup.cs @@ -1,8 +1,3 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; using NJsonSchema.Generation; using System.Text.Json.Serialization; diff --git a/src/NSwag.Sample.NET80Minimal/Program.cs b/src/NSwag.Sample.NET80Minimal/Program.cs index 5c1c462178..62f56f6902 100644 --- a/src/NSwag.Sample.NET80Minimal/Program.cs +++ b/src/NSwag.Sample.NET80Minimal/Program.cs @@ -1,8 +1,4 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.DependencyInjection; -using System; var builder = WebApplication.CreateBuilder(args); diff --git a/src/NSwag.Sample.NET90/Controllers/ValuesController.cs b/src/NSwag.Sample.NET90/Controllers/ValuesController.cs index f2f3f1e809..9ae2613dbb 100644 --- a/src/NSwag.Sample.NET90/Controllers/ValuesController.cs +++ b/src/NSwag.Sample.NET90/Controllers/ValuesController.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; namespace NSwag.Sample.NET80.Controllers { diff --git a/src/NSwag.Sample.NET90/Program.cs b/src/NSwag.Sample.NET90/Program.cs index 92efd4267e..063b013ba7 100644 --- a/src/NSwag.Sample.NET90/Program.cs +++ b/src/NSwag.Sample.NET90/Program.cs @@ -1,6 +1,3 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; - namespace NSwag.Sample.NET90 { public class Program diff --git a/src/NSwag.Sample.NET90/Startup.cs b/src/NSwag.Sample.NET90/Startup.cs index 331d4ba83f..582a351fe2 100644 --- a/src/NSwag.Sample.NET90/Startup.cs +++ b/src/NSwag.Sample.NET90/Startup.cs @@ -1,8 +1,3 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; using NJsonSchema.Generation; using System.Text.Json.Serialization; diff --git a/src/NSwag.Sample.NET90Minimal/Program.cs b/src/NSwag.Sample.NET90Minimal/Program.cs index 5e1b3882aa..53ead1cca1 100644 --- a/src/NSwag.Sample.NET90Minimal/Program.cs +++ b/src/NSwag.Sample.NET90Minimal/Program.cs @@ -1,8 +1,4 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.DependencyInjection; -using System; var builder = WebApplication.CreateBuilder(args); diff --git a/src/NSwagStudio/Controls/AvalonEditBehavior.cs b/src/NSwagStudio/Controls/AvalonEditBehavior.cs index 5eb54b7d73..53129793a6 100644 --- a/src/NSwagStudio/Controls/AvalonEditBehavior.cs +++ b/src/NSwagStudio/Controls/AvalonEditBehavior.cs @@ -1,4 +1,3 @@ -using System; using System.Windows; using System.Windows.Interactivity; using ICSharpCode.AvalonEdit; diff --git a/src/NSwagStudio/Controls/TabContent.cs b/src/NSwagStudio/Controls/TabContent.cs index cc0033224a..f6f0bc140d 100644 --- a/src/NSwagStudio/Controls/TabContent.cs +++ b/src/NSwagStudio/Controls/TabContent.cs @@ -1,4 +1,3 @@ -using System; using System.ComponentModel; using System.Windows; using System.Windows.Controls; diff --git a/src/NSwagStudio/Converters/IsValueToVisibilityConverter.cs b/src/NSwagStudio/Converters/IsValueToVisibilityConverter.cs index 86545e3864..fdbd3126cf 100644 --- a/src/NSwagStudio/Converters/IsValueToVisibilityConverter.cs +++ b/src/NSwagStudio/Converters/IsValueToVisibilityConverter.cs @@ -1,5 +1,4 @@ -using System; -using System.Globalization; +using System.Globalization; using System.Windows; using System.Windows.Data; using System.Windows.Markup; diff --git a/src/NSwagStudio/Converters/NumberAdditionConverter.cs b/src/NSwagStudio/Converters/NumberAdditionConverter.cs index 002bd57ca4..1d76bad520 100644 --- a/src/NSwagStudio/Converters/NumberAdditionConverter.cs +++ b/src/NSwagStudio/Converters/NumberAdditionConverter.cs @@ -1,5 +1,4 @@ -using System; -using System.Globalization; +using System.Globalization; using System.Windows.Data; namespace NSwagStudio.Converters diff --git a/src/NSwagStudio/Converters/StringArrayConverter.cs b/src/NSwagStudio/Converters/StringArrayConverter.cs index f42f71124b..0a921b9c0b 100644 --- a/src/NSwagStudio/Converters/StringArrayConverter.cs +++ b/src/NSwagStudio/Converters/StringArrayConverter.cs @@ -1,6 +1,4 @@ -using System; -using System.Globalization; -using System.Linq; +using System.Globalization; using System.Windows.Data; namespace NSwagStudio.Converters diff --git a/src/NSwagStudio/ISwaggerGeneratorView.cs b/src/NSwagStudio/ISwaggerGeneratorView.cs index cb2998bc8f..8ee8472700 100644 --- a/src/NSwagStudio/ISwaggerGeneratorView.cs +++ b/src/NSwagStudio/ISwaggerGeneratorView.cs @@ -6,7 +6,6 @@ // Rico Suter, mail@rsuter.com //----------------------------------------------------------------------- -using System.Threading.Tasks; using NSwag.Commands; namespace NSwagStudio diff --git a/src/NSwagStudio/ViewModels/CodeGenerators/SwaggerOutputViewModel.cs b/src/NSwagStudio/ViewModels/CodeGenerators/SwaggerOutputViewModel.cs index 463409732f..6dc42d6ed5 100644 --- a/src/NSwagStudio/ViewModels/CodeGenerators/SwaggerOutputViewModel.cs +++ b/src/NSwagStudio/ViewModels/CodeGenerators/SwaggerOutputViewModel.cs @@ -6,7 +6,6 @@ // Rico Suter, mail@rsuter.com //----------------------------------------------------------------------- -using System.Threading.Tasks; using NSwag; namespace NSwagStudio.ViewModels.CodeGenerators diff --git a/src/NSwagStudio/ViewModels/CodeGenerators/SwaggerToCSharpClientGeneratorViewModel.cs b/src/NSwagStudio/ViewModels/CodeGenerators/SwaggerToCSharpClientGeneratorViewModel.cs index 2c47873080..5fb1a213ef 100644 --- a/src/NSwagStudio/ViewModels/CodeGenerators/SwaggerToCSharpClientGeneratorViewModel.cs +++ b/src/NSwagStudio/ViewModels/CodeGenerators/SwaggerToCSharpClientGeneratorViewModel.cs @@ -6,8 +6,6 @@ // Rico Suter, mail@rsuter.com //----------------------------------------------------------------------- -using System; -using System.Linq; using NJsonSchema.CodeGeneration.CSharp; using NSwag.Commands; using NSwag.Commands.CodeGeneration; diff --git a/src/NSwagStudio/ViewModels/CodeGenerators/SwaggerToCSharpControllerGeneratorViewModel.cs b/src/NSwagStudio/ViewModels/CodeGenerators/SwaggerToCSharpControllerGeneratorViewModel.cs index 7922e5b787..d624e1452f 100644 --- a/src/NSwagStudio/ViewModels/CodeGenerators/SwaggerToCSharpControllerGeneratorViewModel.cs +++ b/src/NSwagStudio/ViewModels/CodeGenerators/SwaggerToCSharpControllerGeneratorViewModel.cs @@ -6,8 +6,6 @@ // Rico Suter, mail@rsuter.com //----------------------------------------------------------------------- -using System; -using System.Linq; using NJsonSchema.CodeGeneration.CSharp; using NSwag.CodeGeneration.CSharp.Models; using NSwag.Commands; diff --git a/src/NSwagStudio/ViewModels/CodeGenerators/SwaggerToTypeScriptClientGeneratorViewModel.cs b/src/NSwagStudio/ViewModels/CodeGenerators/SwaggerToTypeScriptClientGeneratorViewModel.cs index 70a90c40eb..1a8446aa95 100644 --- a/src/NSwagStudio/ViewModels/CodeGenerators/SwaggerToTypeScriptClientGeneratorViewModel.cs +++ b/src/NSwagStudio/ViewModels/CodeGenerators/SwaggerToTypeScriptClientGeneratorViewModel.cs @@ -6,8 +6,6 @@ // Rico Suter, mail@rsuter.com //----------------------------------------------------------------------- -using System; -using System.Linq; using NJsonSchema.CodeGeneration.TypeScript; using NSwag.CodeGeneration.TypeScript; using NSwag.Commands; diff --git a/src/NSwagStudio/ViewModels/DocumentModel.cs b/src/NSwagStudio/ViewModels/DocumentModel.cs index caaca02933..b00fc808d1 100644 --- a/src/NSwagStudio/ViewModels/DocumentModel.cs +++ b/src/NSwagStudio/ViewModels/DocumentModel.cs @@ -1,9 +1,6 @@ -using System.Collections.Generic; using System.ComponentModel; -using System.Linq; using MyToolkit.Model; using NSwag.Commands; -using NSwag.Commands.Generation; using NSwagStudio.Views.CodeGenerators; using NSwagStudio.Views.SwaggerGenerators; diff --git a/src/NSwagStudio/ViewModels/DocumentViewModel.cs b/src/NSwagStudio/ViewModels/DocumentViewModel.cs index 39dfc4f69a..51006c5576 100644 --- a/src/NSwagStudio/ViewModels/DocumentViewModel.cs +++ b/src/NSwagStudio/ViewModels/DocumentViewModel.cs @@ -1,7 +1,4 @@ -using System; using System.Diagnostics; -using System.Linq; -using System.Threading.Tasks; using System.Windows; using MyToolkit.Command; using MyToolkit.Utilities; diff --git a/src/NSwagStudio/ViewModels/MainWindowModel.cs b/src/NSwagStudio/ViewModels/MainWindowModel.cs index b28047bbdb..9bd943fccd 100644 --- a/src/NSwagStudio/ViewModels/MainWindowModel.cs +++ b/src/NSwagStudio/ViewModels/MainWindowModel.cs @@ -8,8 +8,6 @@ using System.Collections.ObjectModel; using System.IO; -using System.Linq; -using System.Threading.Tasks; using System.Windows.Forms; using MyToolkit.Command; using MyToolkit.Storage; diff --git a/src/NSwagStudio/ViewModels/SwaggerGenerators/AspNetCoreToSwaggerGeneratorViewModel.cs b/src/NSwagStudio/ViewModels/SwaggerGenerators/AspNetCoreToSwaggerGeneratorViewModel.cs index eb25ad04f2..b966bb908e 100644 --- a/src/NSwagStudio/ViewModels/SwaggerGenerators/AspNetCoreToSwaggerGeneratorViewModel.cs +++ b/src/NSwagStudio/ViewModels/SwaggerGenerators/AspNetCoreToSwaggerGeneratorViewModel.cs @@ -6,10 +6,6 @@ // Rico Suter, mail@rsuter.com //----------------------------------------------------------------------- -using System; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.Win32; using NJsonSchema; using NJsonSchema.Generation; using NSwag; diff --git a/src/NSwagStudio/ViewModels/SwaggerGenerators/SwaggerInputViewModel.cs b/src/NSwagStudio/ViewModels/SwaggerGenerators/SwaggerInputViewModel.cs index c7b3aef600..adedee584e 100644 --- a/src/NSwagStudio/ViewModels/SwaggerGenerators/SwaggerInputViewModel.cs +++ b/src/NSwagStudio/ViewModels/SwaggerGenerators/SwaggerInputViewModel.cs @@ -1,7 +1,4 @@ -using System; using System.IO; -using System.Threading; -using System.Threading.Tasks; using System.Windows.Input; using MyToolkit.Command; using Newtonsoft.Json; diff --git a/src/NSwagStudio/ViewModels/ViewModelBase.cs b/src/NSwagStudio/ViewModels/ViewModelBase.cs index 683bc772f5..cf9228ce36 100644 --- a/src/NSwagStudio/ViewModels/ViewModelBase.cs +++ b/src/NSwagStudio/ViewModels/ViewModelBase.cs @@ -6,8 +6,6 @@ // Rico Suter, mail@rsuter.com //----------------------------------------------------------------------- -using System; -using System.Linq; using System.Windows; using MyToolkit.Dialogs; diff --git a/src/NSwagStudio/Views/DocumentView.xaml.cs b/src/NSwagStudio/Views/DocumentView.xaml.cs index 42ecd60f28..d451d2b104 100644 --- a/src/NSwagStudio/Views/DocumentView.xaml.cs +++ b/src/NSwagStudio/Views/DocumentView.xaml.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; +using System.ComponentModel; using System.Windows; using System.Windows.Controls; using MyToolkit.Mvvm; diff --git a/src/NSwagStudio/Views/MainWindow.xaml.cs b/src/NSwagStudio/Views/MainWindow.xaml.cs index 1a5e274bfc..9654e8dee9 100644 --- a/src/NSwagStudio/Views/MainWindow.xaml.cs +++ b/src/NSwagStudio/Views/MainWindow.xaml.cs @@ -1,7 +1,5 @@ -using System; -using System.ComponentModel; +using System.ComponentModel; using System.Diagnostics; -using System.Linq; using System.Windows; using System.Windows.Documents; using System.Windows.Input; diff --git a/src/NSwagStudio/Views/SwaggerGenerators/AspNetCoreToSwaggerGeneratorView.xaml.cs b/src/NSwagStudio/Views/SwaggerGenerators/AspNetCoreToSwaggerGeneratorView.xaml.cs index 66e7ab9cda..95a4a6b027 100644 --- a/src/NSwagStudio/Views/SwaggerGenerators/AspNetCoreToSwaggerGeneratorView.xaml.cs +++ b/src/NSwagStudio/Views/SwaggerGenerators/AspNetCoreToSwaggerGeneratorView.xaml.cs @@ -1,7 +1,4 @@ -using System.Linq; -using System.Threading.Tasks; -using System.Windows.Controls; -using MyToolkit.Mvvm; +using MyToolkit.Mvvm; using NSwag.Commands; using NSwag.Commands.Generation.AspNetCore; using NSwagStudio.ViewModels.SwaggerGenerators; diff --git a/src/NSwagStudio/Views/SwaggerGenerators/JsonSchemaInputView.xaml.cs b/src/NSwagStudio/Views/SwaggerGenerators/JsonSchemaInputView.xaml.cs index fca17d1709..0b596e182c 100644 --- a/src/NSwagStudio/Views/SwaggerGenerators/JsonSchemaInputView.xaml.cs +++ b/src/NSwagStudio/Views/SwaggerGenerators/JsonSchemaInputView.xaml.cs @@ -1,6 +1,4 @@ -using System; -using System.Threading.Tasks; -using System.Windows; +using System.Windows; using NSwag.Commands; using NSwag.Commands.CodeGeneration; diff --git a/src/NSwagStudio/Views/SwaggerGenerators/SwaggerInputView.xaml.cs b/src/NSwagStudio/Views/SwaggerGenerators/SwaggerInputView.xaml.cs index f75ed05f36..3b017f50ef 100644 --- a/src/NSwagStudio/Views/SwaggerGenerators/SwaggerInputView.xaml.cs +++ b/src/NSwagStudio/Views/SwaggerGenerators/SwaggerInputView.xaml.cs @@ -1,5 +1,4 @@ -using System.Threading.Tasks; -using NSwag.Commands; +using NSwag.Commands; using NSwag.Commands.Generation; using NSwagStudio.ViewModels.SwaggerGenerators;