| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System.Diagnostics; |
| | | 5 | | |
| | | 6 | | namespace System.Text.Json.Serialization.Metadata |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// Represents a strongly-typed parameter to prevent boxing where have less than 4 parameters. |
| | | 10 | | /// Holds relevant state like the default value of the parameter, and the position in the method's parameter list. |
| | | 11 | | /// </summary> |
| | | 12 | | internal sealed class JsonParameterInfo<T> : JsonParameterInfo |
| | | 13 | | { |
| | 0 | 14 | | public new JsonConverter<T> EffectiveConverter => MatchingProperty.EffectiveConverter; |
| | 0 | 15 | | public new JsonPropertyInfo<T> MatchingProperty { get; } |
| | 4494 | 16 | | public new T? EffectiveDefaultValue { get; } |
| | | 17 | | |
| | | 18 | | public JsonParameterInfo(JsonParameterInfoValues parameterInfoValues, JsonPropertyInfo<T> matchingPropertyInfo) |
| | 4494 | 19 | | : base(parameterInfoValues, matchingPropertyInfo) |
| | 4494 | 20 | | { |
| | 4494 | 21 | | Debug.Assert(parameterInfoValues.ParameterType == typeof(T)); |
| | 4494 | 22 | | Debug.Assert(!matchingPropertyInfo.IsConfigured); |
| | | 23 | | |
| | 4494 | 24 | | if (parameterInfoValues is { HasDefaultValue: true, DefaultValue: object defaultValue }) |
| | 0 | 25 | | { |
| | 0 | 26 | | EffectiveDefaultValue = (T)defaultValue; |
| | 0 | 27 | | } |
| | | 28 | | |
| | 4494 | 29 | | MatchingProperty = matchingPropertyInfo; |
| | 4494 | 30 | | base.EffectiveDefaultValue = EffectiveDefaultValue; |
| | 4494 | 31 | | } |
| | | 32 | | } |
| | | 33 | | } |