-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
15 changed files
with
170 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Helpers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Diagnostics; | ||
using System.Text.Json.Serialization; | ||
using System.Text.Json.Serialization.Metadata; | ||
|
||
namespace System.Text.Json | ||
{ | ||
public static partial class JsonSerializer | ||
{ | ||
private static JsonTypeInfo GetTypeInfo(Type runtimeType, JsonSerializerOptions? options) | ||
{ | ||
options ??= JsonSerializerOptions.s_defaultOptions; | ||
options.RootBuiltInConvertersAndTypeInfoCreator(); | ||
return options.GetOrAddClassForRootType(runtimeType); | ||
} | ||
|
||
private static JsonTypeInfo GetTypeInfo(JsonSerializerContext context, Type type) | ||
{ | ||
Debug.Assert(context != null); | ||
Debug.Assert(type != null); | ||
|
||
JsonTypeInfo? info = context.GetTypeInfo(type); | ||
if (info == null) | ||
{ | ||
ThrowHelper.ThrowInvalidOperationException_NoMetadataForType(type); | ||
} | ||
|
||
return info; | ||
} | ||
|
||
internal static bool IsValidNumberHandlingValue(JsonNumberHandling handling) => | ||
JsonHelpers.IsInRangeInclusive((int)handling, 0, | ||
(int)( | ||
JsonNumberHandling.Strict | | ||
JsonNumberHandling.AllowReadingFromString | | ||
JsonNumberHandling.WriteAsString | | ||
JsonNumberHandling.AllowNamedFloatingPointLiterals)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.