From 79d5d634ef889d54777f8f061a8cb59949136542 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Thu, 14 Nov 2024 21:17:54 +1100 Subject: [PATCH] use field keyword --- src/Argon/Serialization/JsonContract.cs | 12 +++++------- src/Argon/Serialization/JsonObjectContract.cs | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Argon/Serialization/JsonContract.cs b/src/Argon/Serialization/JsonContract.cs index 2075e5c4e..550913b11 100644 --- a/src/Argon/Serialization/JsonContract.cs +++ b/src/Argon/Serialization/JsonContract.cs @@ -19,8 +19,6 @@ public abstract class JsonContract internal bool IsSealed; internal bool IsInstantiable; - Type createdType; - /// /// Gets the underlying type for the contract. /// @@ -31,13 +29,13 @@ public abstract class JsonContract /// public Type CreatedType { - get => createdType; + get; set { - createdType = value; + field = value; - IsSealed = createdType.IsSealed; - IsInstantiable = !(createdType.IsInterface || createdType.IsAbstract); + IsSealed = field.IsSealed; + IsInstantiable = !(field.IsInterface || field.IsAbstract); } } @@ -87,7 +85,7 @@ internal JsonContract(Type underlyingType) NonNullableUnderlyingType = underlyingType; } - createdType = CreatedType = NonNullableUnderlyingType; + CreatedType = CreatedType = NonNullableUnderlyingType; IsConvertible = NonNullableUnderlyingType.IsConvertible(); IsEnum = NonNullableUnderlyingType.IsEnum; diff --git a/src/Argon/Serialization/JsonObjectContract.cs b/src/Argon/Serialization/JsonObjectContract.cs index b64e4bdf1..8eedfa275 100644 --- a/src/Argon/Serialization/JsonObjectContract.cs +++ b/src/Argon/Serialization/JsonObjectContract.cs @@ -37,7 +37,8 @@ public class JsonObjectContract : JsonContainerContract /// /// Gets a collection of instances that define the parameters used with . /// - public JsonPropertyCollection CreatorParameters => creatorParameters ??= new(UnderlyingType); + [field: AllowNull, MaybeNull] + public JsonPropertyCollection CreatorParameters => field ??= new(UnderlyingType); /// /// Gets or sets the function used to create the object. When set this function will override . @@ -48,7 +49,6 @@ public class JsonObjectContract : JsonContainerContract internal ObjectConstructor? ParameterizedCreator { get; set; } bool? hasRequiredOrDefaultValueProperties; - JsonPropertyCollection? creatorParameters; internal bool HasRequiredOrDefaultValueProperties {