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
4 changes: 2 additions & 2 deletions src/libraries/System.Text.Json/src/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@
<value>Members '{0}' and '{1}' on type '{2}' cannot both bind with parameter '{3}' in constructor '{4}' on deserialization.</value>
</data>
<data name="ConstructorParamIncompleteBinding" xml:space="preserve">
<value>Each parameter in constructor '{0}' on type '{1}' must bind to an object member on deserialization. Each parameter name must be the camel case equivalent of an object member named with the pascal case naming convention.</value>
<value>Each parameter in constructor '{0}' on type '{1}' must bind to an object property or field on deserialization. Each parameter name must match with a property or field on the object. The match can be case-insensitive.</value>
</data>
<data name="ConstructorMaxOf64Parameters" xml:space="preserve">
<value>The constructor '{0}' on type '{1}' may not have more than 64 parameters for deserialization.</value>
Expand Down Expand Up @@ -542,4 +542,4 @@
<data name="NumberHandlingOnPropertyTypeMustBeNumberOrCollection" xml:space="preserve">
<value>When 'JsonNumberHandlingAttribute' is placed on a property or field, the property or field must be a number or a collection. See member '{0}' on type '{1}'.</value>
</data>
</root>
</root>
1 change: 1 addition & 0 deletions src/libraries/System.Text.Json/src/System.Text.Json.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
<Compile Include="System\Text\Json\Serialization\JsonPropertyInfo.cs" />
<Compile Include="System\Text\Json\Serialization\JsonPropertyInfoOfT.cs" />
<Compile Include="System\Text\Json\Serialization\JsonResumableConverterOfT.cs" />
<Compile Include="System\Text\Json\Serialization\JsonSerializer.cs" />
<Compile Include="System\Text\Json\Serialization\JsonSerializer.Read.HandleMetadata.cs" />
<Compile Include="System\Text\Json\Serialization\JsonSerializer.Read.HandlePropertyName.cs" />
<Compile Include="System\Text\Json\Serialization\JsonSerializer.Read.Helpers.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ public bool TryGetSingle(out float value)
throw ThrowHelper.GetInvalidOperationException_ExpectedNumber(TokenType);
}

ReadOnlySpan<byte> span = HasValueSequence ? ValueSequence.ToArray() : ValueSpan;;
ReadOnlySpan<byte> span = HasValueSequence ? ValueSequence.ToArray() : ValueSpan;

if (Utf8Parser.TryParse(span, out float tmp, out int bytesConsumed, _numberFormat)
&& span.Length == bytesConsumed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace System.Text.Json.Serialization
/// The specified converter type must derive from <see cref="JsonConverter"/>.
/// When placed on a property or field, the specified converter will always be used.
/// When placed on a type, the specified converter will be used unless a compatible converter is added to
/// <see cref="JsonSerializerOptions.Converters"/> or there is another <see cref="JsonConverterAttribute"/> on a member
/// <see cref="JsonSerializerOptions.Converters"/> or there is another <see cref="JsonConverterAttribute"/> on a property or field
/// of the same type.
/// </remarks>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace System.Text.Json.Serialization
/// During serializing, the name of the extension data member is not included in the JSON;
/// the data contained within the extension data is serialized as properties of the JSON object.
///
/// If there is more than one extension member on a type, or it the member is not of the correct type,
/// If there is more than one extension member on a type, or the member is not of the correct type,
/// an <see cref="InvalidOperationException"/> is thrown during the first serialization or deserialization of that type.
/// </remarks>
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
namespace System.Text.Json.Serialization
{
/// <summary>
/// Indicates that the member should be included for serialization and deserialization.
/// Indicates that the property or field should be included for serialization and deserialization.
/// </summary>
/// <remarks>
/// When applied to a property, indicates that non-public getters and setters can be used for serialization and deserialization.
/// When applied to a public property, indicates that non-public getters and setters should be used for serialization and deserialization.
///
/// Non-public properties and fields are not allowed when serializing and deserializing. If the attribute is used on a non-public property or field,
/// an <see cref="InvalidOperationException"/> is thrown during the first serialization or deserialization of the declaring type.
/// </remarks>
[AttributeUsage(AttributeTargets.Property | System.AttributeTargets.Field, AllowMultiple = false)]
public sealed class JsonIncludeAttribute : JsonAttribute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ namespace System.Text.Json.Serialization
{
/// <summary>
/// When placed on a type, property, or field, indicates what <see cref="JsonNumberHandling"/>
/// settings should be used when serializing or deserialing numbers.
/// settings should be used when serializing or deserializing numbers.
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
public sealed class JsonNumberHandlingAttribute : JsonAttribute
{
/// <summary>
/// Indicates what settings should be used when serializing or deserialing numbers.
/// Indicates what settings should be used when serializing or deserializing numbers.
/// </summary>
public JsonNumberHandling Handling { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ protected override bool OnWriteResume(Utf8JsonWriter writer, TCollection value,
}
}


return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public enum JsonNumberHandling
/// </summary>
WriteAsString = 0x2,
/// <summary>
/// The "NaN", "Infinity", and "-Infinity" <see cref="JsonTokenType.String"/> tokens can be read as floating-point constants,
/// and the <see cref="float.NaN"/>, <see cref="double.PositiveInfinity"/>, and <see cref="float.NegativeInfinity"/>
/// values will be written as their corresponding JSON string representations.
/// The "NaN", "Infinity", and "-Infinity" <see cref="JsonTokenType.String"/> tokens can be read as
/// floating-point constants, and the <see cref="float"/> and <see cref="double"/> values for these
/// constants will be written as their corresponding JSON string representations.
/// </summary>
AllowNamedFloatingPointLiterals = 0x4
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Text.Json.Serialization;

namespace System.Text.Json
Expand Down Expand Up @@ -36,11 +35,5 @@ private static TValue ReadCore<TValue>(JsonConverter jsonConverter, ref Utf8Json
Debug.Assert(value == null || value is TValue);
return (TValue)value!;
}

internal static bool IsValidNumberHandlingValue(JsonNumberHandling handling)
{
int handlingValue = (int)handling;
return handlingValue >= 0 && handlingValue <= 7;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Text.Json.Serialization;

namespace System.Text.Json
{
public static partial class JsonSerializer
{
internal static bool IsValidNumberHandlingValue(JsonNumberHandling handling)
{
return JsonHelpers.IsInRangeInclusive((int)handling, 0, 7);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void Verify()
}

[Fact]
public static void ExtensioFieldNotUsed()
public static void ExtensionFieldNotUsed()
{
string json = @"{""MyNestedClass"":" + SimpleTestClass.s_json + "}";
ClassWithExtensionField obj = JsonSerializer.Deserialize<ClassWithExtensionField>(json);
Expand Down