diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs index 034a3e70c..7611eec2d 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs @@ -30,7 +30,7 @@ public MapNode(ParsingContext context, string yamlString) : public MapNode(ParsingContext context, YamlNode node) : base( context) { - if (!(node is YamlMappingNode mapNode)) + if (node is not YamlMappingNode mapNode) { throw new OpenApiReaderException("Expected map.", Context); } diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/ParseNode.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/ParseNode.cs index f57f4927c..be39e0602 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/ParseNode.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/ParseNode.cs @@ -22,7 +22,7 @@ protected ParseNode(ParsingContext parsingContext) public MapNode CheckMapNode(string nodeName) { - if (!(this is MapNode mapNode)) + if (this is not MapNode mapNode) { throw new OpenApiReaderException($"{nodeName} must be a map/object", Context); } diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/ValueNode.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/ValueNode.cs index bbce7a7d3..16bbee41d 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/ValueNode.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/ValueNode.cs @@ -15,7 +15,7 @@ internal class ValueNode : ParseNode public ValueNode(ParsingContext context, YamlNode node) : base( context) { - if (!(node is YamlScalarNode scalarNode)) + if (node is not YamlScalarNode scalarNode) { throw new OpenApiReaderException("Expected a value.", node); } diff --git a/src/Microsoft.OpenApi/Validations/Rules/RuleHelpers.cs b/src/Microsoft.OpenApi/Validations/Rules/RuleHelpers.cs index dc4b6d6c9..504938d75 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/RuleHelpers.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/RuleHelpers.cs @@ -135,7 +135,7 @@ public static void ValidateDataTypeMismatch( if (type == "integer" && format == "int32") { - if (!(value is OpenApiInteger)) + if (value is not OpenApiInteger) { context.CreateWarning( ruleName, @@ -147,7 +147,7 @@ public static void ValidateDataTypeMismatch( if (type == "integer" && format == "int64") { - if (!(value is OpenApiLong)) + if (value is not OpenApiLong) { context.CreateWarning( ruleName, @@ -157,9 +157,9 @@ public static void ValidateDataTypeMismatch( return; } - if (type == "integer" && !(value is OpenApiInteger)) + if (type == "integer" && value is not OpenApiInteger) { - if (!(value is OpenApiInteger)) + if (value is not OpenApiInteger) { context.CreateWarning( ruleName, @@ -171,7 +171,7 @@ public static void ValidateDataTypeMismatch( if (type == "number" && format == "float") { - if (!(value is OpenApiFloat)) + if (value is not OpenApiFloat) { context.CreateWarning( ruleName, @@ -183,7 +183,7 @@ public static void ValidateDataTypeMismatch( if (type == "number" && format == "double") { - if (!(value is OpenApiDouble)) + if (value is not OpenApiDouble) { context.CreateWarning( ruleName, @@ -195,7 +195,7 @@ public static void ValidateDataTypeMismatch( if (type == "number") { - if (!(value is OpenApiDouble)) + if (value is not OpenApiDouble) { context.CreateWarning( ruleName, @@ -207,7 +207,7 @@ public static void ValidateDataTypeMismatch( if (type == "string" && format == "byte") { - if (!(value is OpenApiByte)) + if (value is not OpenApiByte) { context.CreateWarning( ruleName, @@ -219,7 +219,7 @@ public static void ValidateDataTypeMismatch( if (type == "string" && format == "date") { - if (!(value is OpenApiDate)) + if (value is not OpenApiDate) { context.CreateWarning( ruleName, @@ -231,7 +231,7 @@ public static void ValidateDataTypeMismatch( if (type == "string" && format == "date-time") { - if (!(value is OpenApiDateTime)) + if (value is not OpenApiDateTime) { context.CreateWarning( ruleName, @@ -243,7 +243,7 @@ public static void ValidateDataTypeMismatch( if (type == "string" && format == "password") { - if (!(value is OpenApiPassword)) + if (value is not OpenApiPassword) { context.CreateWarning( ruleName, @@ -255,7 +255,7 @@ public static void ValidateDataTypeMismatch( if (type == "string") { - if (!(value is OpenApiString)) + if (value is not OpenApiString) { context.CreateWarning( ruleName, @@ -267,7 +267,7 @@ public static void ValidateDataTypeMismatch( if (type == "boolean") { - if (!(value is OpenApiBoolean)) + if (value is not OpenApiBoolean) { context.CreateWarning( ruleName, diff --git a/src/Microsoft.OpenApi/Validations/ValidationRule.cs b/src/Microsoft.OpenApi/Validations/ValidationRule.cs index fdbf5c330..97a66034d 100644 --- a/src/Microsoft.OpenApi/Validations/ValidationRule.cs +++ b/src/Microsoft.OpenApi/Validations/ValidationRule.cs @@ -59,7 +59,7 @@ internal override void Evaluate(IValidationContext context, object item) return; } - if (!(item is T)) + if (item is not T) { throw Error.Argument(string.Format(SRResource.InputItemShouldBeType, typeof(T).FullName)); } diff --git a/test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs b/test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs index 55a32ff71..8c084eae0 100644 --- a/test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs +++ b/test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs @@ -61,7 +61,7 @@ public static IEnumerable GetSchemas() JToken GetProp(JToken obj, string prop) { - if (!(obj is JObject jObj)) + if (obj is not JObject jObj) return null; if (!jObj.TryGetValue(prop, out var jToken)) return null;