diff --git a/Directory.Build.props b/Directory.Build.props
index 3745092c5d..d38c7488e8 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -99,12 +99,10 @@
[CA1720] Identifier 'xxx' contains type name
[CA1725] Overriden parameter name mismatch
[CA1805] Member is explicitly initialized to its default value
- [CA1822] Member does not access instance data and can be marked as static
[CA1827] Count() is used where Any() could be used instead to improve performance
[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
- [CA1852] Type can be sealed because it has no subtypes in its containing assembly and is not externally visible
[CA1854] Prefer a 'TryGetValue' call over a Dictionary indexer access
[CA1860] Prefer comparing 'Count' to 0 rather than using 'Any()'
[CA1861] Prefer 'static readonly' fields over constant array arguments
@@ -118,7 +116,7 @@
[SYSLIB0012] 'Assembly.CodeBase' is obsolete
-->
$(NoWarn);IDE0005;IDE0008;IDE0011;IDE0017;IDE0019;IDE0021;IDE0022;IDE0025;IDE0027;IDE0028;IDE0029;IDE0032;IDE0039;IDE0040;IDE0044;IDE0045;IDE0046;IDE0055;IDE0056;IDE0057;IDE0059;IDE0060;IDE0061;IDE0063;IDE0074;IDE0078;IDE0083;IDE0090;IDE0100;IDE0130;IDE0160;IDE0200;IDE0260;IDE0270;IDE0290;IDE0300;IDE0305;IDE0301;IDE0330;IDE1005
- $(NoWarn);CA1200;CA1304;CA1305;CA1310;CA1311;CA1507;CA1510;CA1514;CA1710;CA1716;CA1720;CA1725;CA1805;CA1822;CA1827;CA1834;CA1845;CA1847;CA1852;CA1854;CA1860;CA1861;CA1862;CA1865;CA1866;CA1870;CA2249;CA2263;SYSLIB0012
+ $(NoWarn);CA1200;CA1304;CA1305;CA1310;CA1311;CA1507;CA1510;CA1514;CA1710;CA1716;CA1720;CA1725;CA1805;CA1827;CA1834;CA1845;CA1847;CA1854;CA1860;CA1861;CA1862;CA1865;CA1866;CA1870;CA2249;CA2263;SYSLIB0012
diff --git a/src/NSwag.AspNet.Owin/Middlewares/RedirectToIndexMiddleware.cs b/src/NSwag.AspNet.Owin/Middlewares/RedirectToIndexMiddleware.cs
index 128ad39f69..7be088137a 100644
--- a/src/NSwag.AspNet.Owin/Middlewares/RedirectToIndexMiddleware.cs
+++ b/src/NSwag.AspNet.Owin/Middlewares/RedirectToIndexMiddleware.cs
@@ -12,7 +12,7 @@
namespace NSwag.AspNet.Owin.Middlewares
{
- internal class RedirectToIndexMiddleware : OwinMiddleware
+ internal sealed class RedirectToIndexMiddleware : OwinMiddleware
{
private readonly string _internalUiRoute;
private readonly string _internalSwaggerRoute;
diff --git a/src/NSwag.AspNet.Owin/Middlewares/SwaggerUiIndexMiddleware.cs b/src/NSwag.AspNet.Owin/Middlewares/SwaggerUiIndexMiddleware.cs
index c4b8c9d2b5..c324b404cd 100644
--- a/src/NSwag.AspNet.Owin/Middlewares/SwaggerUiIndexMiddleware.cs
+++ b/src/NSwag.AspNet.Owin/Middlewares/SwaggerUiIndexMiddleware.cs
@@ -7,7 +7,7 @@
namespace NSwag.AspNet.Owin.Middlewares
{
- internal class SwaggerUiIndexMiddleware : OwinMiddleware
+ internal sealed class SwaggerUiIndexMiddleware : OwinMiddleware
where T : OpenApiDocumentGeneratorSettings, new()
{
private readonly string _indexPath;
diff --git a/src/NSwag.AspNet.WebApi/JsonExceptionFilterAttribute.cs b/src/NSwag.AspNet.WebApi/JsonExceptionFilterAttribute.cs
index dee6534b24..142f493c9b 100644
--- a/src/NSwag.AspNet.WebApi/JsonExceptionFilterAttribute.cs
+++ b/src/NSwag.AspNet.WebApi/JsonExceptionFilterAttribute.cs
@@ -79,7 +79,7 @@ public override void OnActionExecuted(HttpActionExecutedContext context)
}
}
- private int GetStatusCode(Exception exception, HttpActionExecutedContext context)
+ private static int GetStatusCode(Exception exception, HttpActionExecutedContext context)
{
if (context.ActionContext.ActionDescriptor is ReflectedHttpActionDescriptor actionDescriptor)
{
@@ -105,7 +105,7 @@ private int GetStatusCode(Exception exception, HttpActionExecutedContext context
return 500;
}
- private JsonSerializerSettings CopySettings(JsonSerializerSettings settings)
+ private static JsonSerializerSettings CopySettings(JsonSerializerSettings settings)
{
var settingsCopy = new JsonSerializerSettings();
diff --git a/src/NSwag.AspNetCore.Launcher/Program.cs b/src/NSwag.AspNetCore.Launcher/Program.cs
index e2c61b6b99..faefff2d55 100644
--- a/src/NSwag.AspNetCore.Launcher/Program.cs
+++ b/src/NSwag.AspNetCore.Launcher/Program.cs
@@ -5,7 +5,7 @@
namespace NSwag.AspNetCore.Launcher
{
- internal class Program
+ internal sealed class Program
{
// Used to load NSwag.Commands into a process running with the app's dependency context
private const string EntryPointType = "NSwag.Commands.Generation.AspNetCore.AspNetCoreToOpenApiGeneratorCommandEntryPoint";
@@ -169,7 +169,7 @@ private static bool TryLoadReferencedAssemblies()
return true;
}
- private class AssemblyLoadInfo
+ private sealed class AssemblyLoadInfo
{
public AssemblyLoadInfo(Version minimumRequiredVersion)
{
diff --git a/src/NSwag.AspNetCore/JsonExceptionFilterAttribute.cs b/src/NSwag.AspNetCore/JsonExceptionFilterAttribute.cs
index 27ac4355ca..e40febea16 100644
--- a/src/NSwag.AspNetCore/JsonExceptionFilterAttribute.cs
+++ b/src/NSwag.AspNetCore/JsonExceptionFilterAttribute.cs
@@ -82,7 +82,7 @@ public override void OnActionExecuted(ActionExecutedContext context)
}
}
- private int GetStatusCode(Exception exception, ActionExecutedContext context)
+ private static int GetStatusCode(Exception exception, ActionExecutedContext context)
{
if (context.ActionDescriptor is ControllerActionDescriptor controllerActionDescriptor)
{
@@ -116,7 +116,7 @@ private int GetStatusCode(Exception exception, ActionExecutedContext context)
return 500;
}
- private JsonSerializerSettings CopySettings(JsonSerializerSettings settings)
+ private static JsonSerializerSettings CopySettings(JsonSerializerSettings settings)
{
var settingsCopy = new JsonSerializerSettings();
diff --git a/src/NSwag.AspNetCore/Middlewares/RedirectToIndexMiddleware.cs b/src/NSwag.AspNetCore/Middlewares/RedirectToIndexMiddleware.cs
index 28136dbc6c..0b0b706bbc 100644
--- a/src/NSwag.AspNetCore/Middlewares/RedirectToIndexMiddleware.cs
+++ b/src/NSwag.AspNetCore/Middlewares/RedirectToIndexMiddleware.cs
@@ -12,7 +12,7 @@
namespace NSwag.AspNetCore.Middlewares
{
- internal class RedirectToIndexMiddleware
+ internal sealed class RedirectToIndexMiddleware
{
private readonly RequestDelegate _nextDelegate;
diff --git a/src/NSwag.AspNetCore/Middlewares/SwaggerUiIndexMiddleware.cs b/src/NSwag.AspNetCore/Middlewares/SwaggerUiIndexMiddleware.cs
index 2889168a43..05efdc10e3 100644
--- a/src/NSwag.AspNetCore/Middlewares/SwaggerUiIndexMiddleware.cs
+++ b/src/NSwag.AspNetCore/Middlewares/SwaggerUiIndexMiddleware.cs
@@ -6,7 +6,7 @@
namespace NSwag.AspNetCore.Middlewares
{
- internal class SwaggerUiIndexMiddleware
+ internal sealed class SwaggerUiIndexMiddleware
{
private readonly RequestDelegate _nextDelegate;
private readonly string _indexPath;
diff --git a/src/NSwag.AspNetCore/OpenApiConfigureMvcOptions.cs b/src/NSwag.AspNetCore/OpenApiConfigureMvcOptions.cs
index 76c8f17940..fc8ab7c231 100644
--- a/src/NSwag.AspNetCore/OpenApiConfigureMvcOptions.cs
+++ b/src/NSwag.AspNetCore/OpenApiConfigureMvcOptions.cs
@@ -11,7 +11,7 @@
namespace NSwag.AspNetCore
{
- internal class OpenApiConfigureMvcOptions : ConfigureOptions
+ internal sealed class OpenApiConfigureMvcOptions : ConfigureOptions
{
public OpenApiConfigureMvcOptions()
: base(options => options.Conventions.Add(new OpenApiMvcApplicationModelConvention()))
diff --git a/src/NSwag.AspNetCore/OpenApiDocumentProvider.cs b/src/NSwag.AspNetCore/OpenApiDocumentProvider.cs
index 2c2585a579..7848fcdfc9 100644
--- a/src/NSwag.AspNetCore/OpenApiDocumentProvider.cs
+++ b/src/NSwag.AspNetCore/OpenApiDocumentProvider.cs
@@ -18,7 +18,7 @@
namespace NSwag.AspNetCore
{
- internal class OpenApiDocumentProvider : IDocumentProvider, IOpenApiDocumentGenerator
+ internal sealed class OpenApiDocumentProvider : IDocumentProvider, IOpenApiDocumentGenerator
{
private readonly IServiceProvider _serviceProvider;
private readonly IEnumerable _documents;
diff --git a/src/NSwag.AspNetCore/OpenApiMvcApplicationModelConvention.cs b/src/NSwag.AspNetCore/OpenApiMvcApplicationModelConvention.cs
index 2b131b5dce..8176f86089 100644
--- a/src/NSwag.AspNetCore/OpenApiMvcApplicationModelConvention.cs
+++ b/src/NSwag.AspNetCore/OpenApiMvcApplicationModelConvention.cs
@@ -2,7 +2,7 @@
namespace NSwag.AspNetCore
{
- internal class OpenApiMvcApplicationModelConvention : IApplicationModelConvention
+ internal sealed class OpenApiMvcApplicationModelConvention : IApplicationModelConvention
{
public void Apply(ApplicationModel application)
{
diff --git a/src/NSwag.AspNetCore/SwaggerUiSettingsBase.cs b/src/NSwag.AspNetCore/SwaggerUiSettingsBase.cs
index ee5df125bd..52d9f300ca 100644
--- a/src/NSwag.AspNetCore/SwaggerUiSettingsBase.cs
+++ b/src/NSwag.AspNetCore/SwaggerUiSettingsBase.cs
@@ -122,7 +122,7 @@ protected string GetCustomScriptHtml(HttpRequest request)
/// Generates the additional objects JavaScript code.
/// The additional settings.
/// The code.
- protected string GenerateAdditionalSettings(IDictionary additionalSettings)
+ protected static string GenerateAdditionalSettings(IDictionary additionalSettings)
{
var code = "";
foreach (var pair in additionalSettings)
diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/ControllerGenerationFormatTests.cs b/src/NSwag.CodeGeneration.CSharp.Tests/ControllerGenerationFormatTests.cs
index 9e59d42f77..75a3397025 100644
--- a/src/NSwag.CodeGeneration.CSharp.Tests/ControllerGenerationFormatTests.cs
+++ b/src/NSwag.CodeGeneration.CSharp.Tests/ControllerGenerationFormatTests.cs
@@ -252,7 +252,7 @@ public void When_the_generation_of_dto_classes_are_disabled_then_file_is_generat
Assert.DoesNotContain("public partial class ComplexTypeResponse", code);
}
- private OpenApiDocument GetOpenApiDocument()
+ private static OpenApiDocument GetOpenApiDocument()
{
JsonSchema complexTypeSchema = new JsonSchema();
complexTypeSchema.Title = "ComplexType";
diff --git a/src/NSwag.Commands/Commands/Document/CreateDocumentCommand.cs b/src/NSwag.Commands/Commands/Document/CreateDocumentCommand.cs
index 1964501515..cdaaf5b56e 100644
--- a/src/NSwag.Commands/Commands/Document/CreateDocumentCommand.cs
+++ b/src/NSwag.Commands/Commands/Document/CreateDocumentCommand.cs
@@ -33,7 +33,7 @@ public async Task