Skip to content

Commit

Permalink
remove redundant CheckArguments
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Oct 8, 2023
1 parent 2690da5 commit 9937565
Showing 1 changed file with 8 additions and 29 deletions.
37 changes: 8 additions & 29 deletions src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static void WriteProperty(this IOpenApiWriter writer, string name, string
return;
}

CheckArguments(writer, name);
Utils.CheckArgumentNullOrEmpty(name);
writer.WritePropertyName(name);
writer.WriteValue(value);
}
Expand All @@ -40,7 +40,7 @@ public static void WriteProperty(this IOpenApiWriter writer, string name, string
/// <param name="value">The property value.</param>
public static void WriteRequiredProperty(this IOpenApiWriter writer, string name, string value)
{
CheckArguments(writer, name);
Utils.CheckArgumentNullOrEmpty(name);
writer.WritePropertyName(name);
if (value == null)
{
Expand All @@ -66,7 +66,7 @@ public static void WriteProperty(this IOpenApiWriter writer, string name, bool v
return;
}

CheckArguments(writer, name);
Utils.CheckArgumentNullOrEmpty(name);
writer.WritePropertyName(name);
writer.WriteValue(value);
}
Expand All @@ -89,7 +89,7 @@ public static void WriteProperty(
return;
}

CheckArguments(writer, name);
Utils.CheckArgumentNullOrEmpty(name);
writer.WritePropertyName(name);
writer.WriteValue(value.Value);
}
Expand Down Expand Up @@ -120,7 +120,7 @@ public static void WriteProperty<T>(this IOpenApiWriter writer, string name, T?
public static void WriteProperty<T>(this IOpenApiWriter writer, string name, T value)
where T : struct
{
CheckArguments(writer, name);
Utils.CheckArgumentNullOrEmpty(name);
writer.WritePropertyName(name);
writer.WriteValue(value);
}
Expand Down Expand Up @@ -166,7 +166,7 @@ public static void WriteRequiredObject<T>(
Action<IOpenApiWriter, T> action)
where T : IOpenApiElement
{
CheckArguments(writer, name, action);
Utils.CheckArgumentNull(action);

writer.WritePropertyName(name);
if (value != null)
Expand Down Expand Up @@ -339,7 +339,7 @@ private static void WriteCollectionInternal<T>(
IEnumerable<T> elements,
Action<IOpenApiWriter, T> action)
{
CheckArguments(writer, name, action);
Utils.CheckArgumentNull(action);

writer.WritePropertyName(name);
writer.WriteStartArray();
Expand Down Expand Up @@ -376,7 +376,7 @@ private static void WriteMapInternal<T>(
IDictionary<string, T> elements,
Action<IOpenApiWriter, string, T> action)
{
CheckArguments(writer, name, action);
Utils.CheckArgumentNull(action);

writer.WritePropertyName(name);
writer.WriteStartObject();
Expand All @@ -399,26 +399,5 @@ private static void WriteMapInternal<T>(

writer.WriteEndObject();
}

private static void CheckArguments<T>(IOpenApiWriter writer, string name, Action<IOpenApiWriter, T> action)
{
CheckArguments(writer, name);

Utils.CheckArgumentNull(action);
}

private static void CheckArguments<T>(IOpenApiWriter writer, string name, Action<IOpenApiWriter, string, T> action)
{
CheckArguments(writer, name);

Utils.CheckArgumentNull(action);
}

private static void CheckArguments(IOpenApiWriter writer, string name)
{
Utils.CheckArgumentNull(writer);

Utils.CheckArgumentNullOrEmpty(name);
}
}
}

0 comments on commit 9937565

Please sign in to comment.