Skip to content

Commit

Permalink
refactor: split a one-liner
Browse files Browse the repository at this point in the history
  • Loading branch information
Dorus authored and shpaass committed Sep 18, 2024
1 parent c43b01d commit db4390f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Yafc.Model/Serialization/PropertySerializers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ internal sealed class ValuePropertySerializer<TOwner, TPropertyType>(PropertyInf

private static readonly ValueSerializer<TPropertyType> ValueSerializer = ValueSerializer<TPropertyType>.Default;

private void setter(TOwner owner, TPropertyType? value)
// TODO (yafc-ce/issues/256): unwrap this one-liner
=> _setter(owner ?? throw new ArgumentNullException(nameof(owner)),
value ?? (CanBeNull
? default
: throw new InvalidOperationException($"{property.DeclaringType}.{propertyName} must not be set to null.")));
private void setter(TOwner owner, TPropertyType? value) => _setter(NullCheckOwner(owner), NullCheckValue(value));

private static TOwner NullCheckOwner(TOwner owner) => owner ?? throw new ArgumentNullException(nameof(owner));

private TPropertyType? NullCheckValue(TPropertyType? value)
=> value ?? (CanBeNull ? default : throw new InvalidOperationException($"{property.DeclaringType}.{propertyName} must not be set to null."));

private new TPropertyType? getter(TOwner owner) {
ArgumentNullException.ThrowIfNull(owner, nameof(owner));
Expand Down

0 comments on commit db4390f

Please sign in to comment.