Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only null check on public apis #1421

Merged
merged 1 commit into from
Oct 10, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ public static void Serialize<T>(
/// <param name="element">The Open API element.</param>
/// <param name="writer">The output writer.</param>
/// <param name="specVersion">Version of the specification the output should conform to</param>

public static void Serialize<T>(this T element, IOpenApiWriter writer, OpenApiSpecVersion specVersion)
where T : IOpenApiSerializable
{
Expand Down
2 changes: 0 additions & 2 deletions src/Microsoft.OpenApi/Models/OpenApiContact.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ public void SerializeAsV2(IOpenApiWriter writer)

private void WriteInternal(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
{
Utils.CheckArgumentNull(writer);

writer.WriteStartObject();

// name
Expand Down
2 changes: 0 additions & 2 deletions src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ public void SerializeAsV2(IOpenApiWriter writer)

private void WriteInternal(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
{
Utils.CheckArgumentNull(writer);

writer.WriteStartObject();

// description
Expand Down
2 changes: 0 additions & 2 deletions src/Microsoft.OpenApi/Models/OpenApiLicense.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ public void SerializeAsV2(IOpenApiWriter writer)

private void WriteInternal(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
{
Utils.CheckArgumentNull(writer);

writer.WriteStartObject();

// name
Expand Down
6 changes: 0 additions & 6 deletions src/Microsoft.OpenApi/Models/OpenApiSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,6 @@ internal void SerializeAsV2(
ISet<string> parentRequiredProperties,
string propertyName)
{
Utils.CheckArgumentNull(writer);

var settings = writer.GetSettings();
var target = this;

Expand Down Expand Up @@ -554,8 +552,6 @@ internal void SerializeAsV2WithoutReference(

internal void WriteAsItemsProperties(IOpenApiWriter writer)
{
Utils.CheckArgumentNull(writer);

// type
writer.WriteProperty(OpenApiConstants.Type, Type);

Expand Down Expand Up @@ -625,8 +621,6 @@ internal void WriteAsSchemaProperties(
ISet<string> parentRequiredProperties,
string propertyName)
{
Utils.CheckArgumentNull(writer);

// format
if (string.IsNullOrEmpty(Format))
{
Expand Down
2 changes: 0 additions & 2 deletions src/Microsoft.OpenApi/Models/OpenApiXml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ public void SerializeAsV2(IOpenApiWriter writer)

private void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
{
Utils.CheckArgumentNull(writer);

writer.WriteStartObject();

// name
Expand Down
2 changes: 0 additions & 2 deletions src/Microsoft.OpenApi/Validations/ValidationRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ internal override Type ElementType

internal override void Evaluate(IValidationContext context, object item)
{
Utils.CheckArgumentNull(context);

if (item == null)
{
return;
Expand Down
9 changes: 0 additions & 9 deletions src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ public static void WriteAny<T>(this IOpenApiWriter writer, T any) where T : IOpe

private static void WriteArray(this IOpenApiWriter writer, OpenApiArray array)
{
Utils.CheckArgumentNull(writer);
Utils.CheckArgumentNull(array);

writer.WriteStartArray();

foreach (var item in array)
Expand All @@ -88,9 +85,6 @@ private static void WriteArray(this IOpenApiWriter writer, OpenApiArray array)

private static void WriteObject(this IOpenApiWriter writer, OpenApiObject entity)
{
Utils.CheckArgumentNull(writer);
Utils.CheckArgumentNull(entity);

writer.WriteStartObject();

foreach (var item in entity)
Expand All @@ -104,9 +98,6 @@ private static void WriteObject(this IOpenApiWriter writer, OpenApiObject entity

private static void WritePrimitive(this IOpenApiWriter writer, IOpenApiPrimitive primitive)
{
Utils.CheckArgumentNull(writer);
Utils.CheckArgumentNull(primitive);

// The Spec version is meaning for the Any type, so it's ok to use the latest one.
primitive.Write(writer, OpenApiSpecVersion.OpenApi3_0);
}
Expand Down
6 changes: 0 additions & 6 deletions src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,22 +402,16 @@ private static void WriteMapInternal<T>(

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);
}
}
Expand Down
Loading