Skip to content

Commit

Permalink
Change 'type' to 'inputType' on serialize methods (dotnet/corefx#40372)
Browse files Browse the repository at this point in the history
Commit migrated from dotnet/corefx@9217d33
  • Loading branch information
steveharter authored and ahsonkhan committed Aug 19, 2019
1 parent 7698294 commit 59dde05
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
8 changes: 4 additions & 4 deletions src/libraries/System.Text.Json/ref/System.Text.Json.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,11 @@ public static partial class JsonSerializer
public static TValue Deserialize<TValue>(System.ReadOnlySpan<byte> utf8Json, System.Text.Json.JsonSerializerOptions options = null) { throw null; }
public static TValue Deserialize<TValue>(string json, System.Text.Json.JsonSerializerOptions options = null) { throw null; }
public static TValue Deserialize<TValue>(ref System.Text.Json.Utf8JsonReader reader, System.Text.Json.JsonSerializerOptions options = null) { throw null; }
public static string Serialize(object value, System.Type type, System.Text.Json.JsonSerializerOptions options = null) { throw null; }
public static void Serialize(System.Text.Json.Utf8JsonWriter writer, object value, System.Type type, System.Text.Json.JsonSerializerOptions options = null) { }
public static System.Threading.Tasks.Task SerializeAsync(System.IO.Stream utf8Json, object value, System.Type type, System.Text.Json.JsonSerializerOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public static string Serialize(object value, System.Type inputType, System.Text.Json.JsonSerializerOptions options = null) { throw null; }
public static void Serialize(System.Text.Json.Utf8JsonWriter writer, object value, System.Type inputType, System.Text.Json.JsonSerializerOptions options = null) { }
public static System.Threading.Tasks.Task SerializeAsync(System.IO.Stream utf8Json, object value, System.Type inputType, System.Text.Json.JsonSerializerOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public static System.Threading.Tasks.Task SerializeAsync<TValue>(System.IO.Stream utf8Json, TValue value, System.Text.Json.JsonSerializerOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public static byte[] SerializeToUtf8Bytes(object value, System.Type type, System.Text.Json.JsonSerializerOptions options = null) { throw null; }
public static byte[] SerializeToUtf8Bytes(object value, System.Type inputType, System.Text.Json.JsonSerializerOptions options = null) { throw null; }
public static byte[] SerializeToUtf8Bytes<TValue>(TValue value, System.Text.Json.JsonSerializerOptions options = null) { throw null; }
public static void Serialize<TValue>(System.Text.Json.Utf8JsonWriter writer, TValue value, System.Text.Json.JsonSerializerOptions options = null) { }
public static string Serialize<TValue>(TValue value, System.Text.Json.JsonSerializerOptions options = null) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ public static byte[] SerializeToUtf8Bytes<TValue>(TValue value, JsonSerializerOp
/// </summary>
/// <returns>A UTF-8 representation of the value.</returns>
/// <param name="value">The value to convert.</param>
/// <param name="type">The type of the <paramref name="value"/> to convert.</param>
/// <param name="inputType">The type of the <paramref name="value"/> to convert.</param>
/// <param name="options">Options to control the conversion behavior.</param>
public static byte[] SerializeToUtf8Bytes(object value, Type type, JsonSerializerOptions options = null)
public static byte[] SerializeToUtf8Bytes(object value, Type inputType, JsonSerializerOptions options = null)
{
VerifyValueAndType(value, type);
return WriteCoreBytes(value, type, options);
VerifyValueAndType(value, inputType);
return WriteCoreBytes(value, inputType, options);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ public static Task SerializeAsync<TValue>(Stream utf8Json, TValue value, JsonSer
/// <returns>A task that represents the asynchronous write operation.</returns>
/// <param name="utf8Json">The UTF-8 <see cref="System.IO.Stream"/> to write to.</param>
/// <param name="value">The value to convert.</param>
/// <param name="type">The type of the <paramref name="value"/> to convert.</param>
/// <param name="inputType">The type of the <paramref name="value"/> to convert.</param>
/// <param name="options">Options to control the conversion behavior.</param>
/// <param name="cancellationToken">The <see cref="System.Threading.CancellationToken"/> which may be used to cancel the write operation.</param>
public static Task SerializeAsync(Stream utf8Json, object value, Type type, JsonSerializerOptions options = null, CancellationToken cancellationToken = default)
public static Task SerializeAsync(Stream utf8Json, object value, Type inputType, JsonSerializerOptions options = null, CancellationToken cancellationToken = default)
{
if (utf8Json == null)
throw new ArgumentNullException(nameof(utf8Json));

VerifyValueAndType(value, type);
VerifyValueAndType(value, inputType);

return WriteAsyncCore(utf8Json, value, type, options, cancellationToken);
return WriteAsyncCore(utf8Json, value, inputType, options, cancellationToken);
}

private static async Task WriteAsyncCore(Stream utf8Json, object value, Type type, JsonSerializerOptions options, CancellationToken cancellationToken)
private static async Task WriteAsyncCore(Stream utf8Json, object value, Type inputType, JsonSerializerOptions options, CancellationToken cancellationToken)
{
if (options == null)
{
Expand All @@ -64,13 +64,13 @@ private static async Task WriteAsyncCore(Stream utf8Json, object value, Type typ
return;
}

if (type == null)
if (inputType == null)
{
type = value.GetType();
inputType = value.GetType();
}

WriteStack state = default;
state.Current.Initialize(type, options);
state.Current.Initialize(inputType, options);
state.Current.CurrentValue = value;

bool isFinalBlock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ public static string Serialize<TValue>(TValue value, JsonSerializerOptions optio
/// </summary>
/// <returns>A <see cref="string"/> representation of the value.</returns>
/// <param name="value">The value to convert.</param>
/// <param name="type">The type of the <paramref name="value"/> to convert.</param>
/// <param name="inputType">The type of the <paramref name="value"/> to convert.</param>
/// <param name="options">Options to control the conversion behavior.</param>
/// <remarks>Using a <see cref="string"/> is not as efficient as using UTF-8
/// encoding since the implementation internally uses UTF-8. See also <see cref="SerializeToUtf8Bytes"/>
/// and <see cref="SerializeAsync"/>.
/// </remarks>
public static string Serialize(object value, Type type, JsonSerializerOptions options = null)
public static string Serialize(object value, Type inputType, JsonSerializerOptions options = null)
{
VerifyValueAndType(value, type);
VerifyValueAndType(value, inputType);

return ToStringInternal(value, type, options);
return ToStringInternal(value, inputType, options);
}

private static string ToStringInternal(object value, Type type, JsonSerializerOptions options)
private static string ToStringInternal(object value, Type inputType, JsonSerializerOptions options)
{
return WriteCoreString(value, type, options);
return WriteCoreString(value, inputType, options);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ public static void Serialize<TValue>(Utf8JsonWriter writer, TValue value, JsonSe
/// </summary>
/// <param name="writer"></param>
/// <param name="value">The value to convert and write.</param>
/// <param name="type">The type of the <paramref name="value"/> to convert.</param>
/// <param name="inputType">The type of the <paramref name="value"/> to convert.</param>
/// <param name="options">Options to control the behavior.</param>
public static void Serialize(Utf8JsonWriter writer, object value, Type type, JsonSerializerOptions options = null)
public static void Serialize(Utf8JsonWriter writer, object value, Type inputType, JsonSerializerOptions options = null)
{
VerifyValueAndType(value, type);
WriteValueCore(writer, value, type, options);
VerifyValueAndType(value, inputType);
WriteValueCore(writer, value, inputType, options);
}
}
}

0 comments on commit 59dde05

Please sign in to comment.