-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix string usage problems reported by analyzers (#5050)
- Loading branch information
Showing
34 changed files
with
112 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
// <author>Rico Suter, [email protected]</author> | ||
//----------------------------------------------------------------------- | ||
|
||
using System.Globalization; | ||
using System.Net; | ||
|
||
namespace NSwag.Annotations | ||
|
@@ -37,7 +38,7 @@ public ResponseTypeAttribute(string httpStatusCode, Type responseType) | |
/// <param name="responseType">The JSON result type of the MVC or Web API action method.</param> | ||
public ResponseTypeAttribute(int httpStatusCode, Type responseType) | ||
{ | ||
HttpStatusCode = httpStatusCode.ToString(); | ||
HttpStatusCode = httpStatusCode.ToString(CultureInfo.InvariantCulture); | ||
ResponseType = responseType; | ||
} | ||
|
||
|
@@ -46,7 +47,7 @@ public ResponseTypeAttribute(int httpStatusCode, Type responseType) | |
/// <param name="responseType">The JSON result type of the MVC or Web API action method.</param> | ||
public ResponseTypeAttribute(HttpStatusCode httpStatusCode, Type responseType) | ||
{ | ||
HttpStatusCode = ((int)httpStatusCode).ToString(); | ||
HttpStatusCode = ((int)httpStatusCode).ToString(CultureInfo.InvariantCulture); | ||
ResponseType = responseType; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
// <author>Rico Suter, [email protected]</author> | ||
//----------------------------------------------------------------------- | ||
|
||
using System.Globalization; | ||
using System.Net; | ||
|
||
namespace NSwag.Annotations | ||
|
@@ -37,7 +38,7 @@ public SwaggerResponseAttribute(string httpStatusCode, Type responseType) | |
/// <param name="responseType">The JSON result type of the MVC or Web API action method.</param> | ||
public SwaggerResponseAttribute(int httpStatusCode, Type responseType) | ||
{ | ||
StatusCode = httpStatusCode.ToString(); | ||
StatusCode = httpStatusCode.ToString(CultureInfo.InvariantCulture); | ||
Type = responseType; | ||
} | ||
|
||
|
@@ -46,7 +47,7 @@ public SwaggerResponseAttribute(int httpStatusCode, Type responseType) | |
/// <param name="responseType">The JSON result type of the MVC or Web API action method.</param> | ||
public SwaggerResponseAttribute(HttpStatusCode httpStatusCode, Type responseType) | ||
{ | ||
StatusCode = ((int)httpStatusCode).ToString(); | ||
StatusCode = ((int)httpStatusCode).ToString(CultureInfo.InvariantCulture); | ||
Type = responseType; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ | |
// <author>Rico Suter, [email protected]</author> | ||
//----------------------------------------------------------------------- | ||
|
||
#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; | ||
|
Oops, something went wrong.