Skip to content

Commit

Permalink
use field keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Nov 14, 2024
1 parent 248cf28 commit 79d5d63
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
12 changes: 5 additions & 7 deletions src/Argon/Serialization/JsonContract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ public abstract class JsonContract
internal bool IsSealed;
internal bool IsInstantiable;

Type createdType;

/// <summary>
/// Gets the underlying type for the contract.
/// </summary>
Expand All @@ -31,13 +29,13 @@ public abstract class JsonContract
/// </summary>
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);
}
}

Expand Down Expand Up @@ -87,7 +85,7 @@ internal JsonContract(Type underlyingType)
NonNullableUnderlyingType = underlyingType;
}

createdType = CreatedType = NonNullableUnderlyingType;
CreatedType = CreatedType = NonNullableUnderlyingType;

IsConvertible = NonNullableUnderlyingType.IsConvertible();
IsEnum = NonNullableUnderlyingType.IsEnum;
Expand Down
4 changes: 2 additions & 2 deletions src/Argon/Serialization/JsonObjectContract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public class JsonObjectContract : JsonContainerContract
/// <summary>
/// Gets a collection of <see cref="JsonProperty" /> instances that define the parameters used with <see cref="JsonObjectContract.OverrideCreator" />.
/// </summary>
public JsonPropertyCollection CreatorParameters => creatorParameters ??= new(UnderlyingType);
[field: AllowNull, MaybeNull]
public JsonPropertyCollection CreatorParameters => field ??= new(UnderlyingType);

/// <summary>
/// Gets or sets the function used to create the object. When set this function will override <see cref="JsonContract.DefaultCreator" />.
Expand All @@ -48,7 +49,6 @@ public class JsonObjectContract : JsonContainerContract
internal ObjectConstructor? ParameterizedCreator { get; set; }

bool? hasRequiredOrDefaultValueProperties;
JsonPropertyCollection? creatorParameters;

internal bool HasRequiredOrDefaultValueProperties
{
Expand Down

0 comments on commit 79d5d63

Please sign in to comment.