Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi.Readers/ParseNodes/ParseNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi.Readers/ParseNodes/ValueNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
26 changes: 13 additions & 13 deletions src/Microsoft.OpenApi/Validations/Rules/RuleHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -195,7 +195,7 @@ public static void ValidateDataTypeMismatch(

if (type == "number")
{
if (!(value is OpenApiDouble))
if (value is not OpenApiDouble)
{
context.CreateWarning(
ruleName,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -255,7 +255,7 @@ public static void ValidateDataTypeMismatch(

if (type == "string")
{
if (!(value is OpenApiString))
if (value is not OpenApiString)
{
context.CreateWarning(
ruleName,
Expand All @@ -267,7 +267,7 @@ public static void ValidateDataTypeMismatch(

if (type == "boolean")
{
if (!(value is OpenApiBoolean))
if (value is not OpenApiBoolean)
{
context.CreateWarning(
ruleName,
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Validations/ValidationRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static IEnumerable<object[]> 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;
Expand Down