From 6a5366469e6cd054632f104a21e0a7b5e704b172 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 16 Apr 2020 22:34:15 +1000 Subject: [PATCH] fixes null checks in ctor --- src/Umbraco.Core/Models/RelationType.cs | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/Umbraco.Core/Models/RelationType.cs b/src/Umbraco.Core/Models/RelationType.cs index 5def14a0c5..16e689f719 100644 --- a/src/Umbraco.Core/Models/RelationType.cs +++ b/src/Umbraco.Core/Models/RelationType.cs @@ -20,12 +20,17 @@ namespace Umbraco.Core.Models [Obsolete("This constructor is no longer used and will be removed in future versions, use one of the other constructors instead")] public RelationType(string alias, string name) - : this(name, alias, false, null, null) + : this(name: name, alias: alias, false, null, null) { } public RelationType(string name, string alias, bool isBidrectional, Guid? parentObjectType, Guid? childObjectType) { + if (name == null) throw new ArgumentNullException(nameof(alias)); + if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(name)); + if (alias == null) throw new ArgumentNullException(nameof(alias)); + if (string.IsNullOrWhiteSpace(alias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(alias)); + _name = name; _alias = alias; _isBidirectional = isBidrectional; @@ -35,24 +40,14 @@ namespace Umbraco.Core.Models [Obsolete("This constructor is no longer used and will be removed in future versions, use one of the other constructors instead")] public RelationType(Guid childObjectType, Guid parentObjectType, string alias) - { - if (alias == null) throw new ArgumentNullException(nameof(alias)); - if (string.IsNullOrWhiteSpace(alias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(alias)); - - _childObjectType = childObjectType; - _parentObjectType = parentObjectType; - _alias = alias; - Name = _alias; + : this(name: alias, alias: alias, false, parentObjectType: parentObjectType, childObjectType: childObjectType) + { } [Obsolete("This constructor is no longer used and will be removed in future versions, use one of the other constructors instead")] public RelationType(Guid childObjectType, Guid parentObjectType, string alias, string name) - : this(childObjectType, parentObjectType, alias) + : this(name: name, alias: alias, false, parentObjectType: parentObjectType, childObjectType: childObjectType) { - if (name == null) throw new ArgumentNullException(nameof(name)); - if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(name)); - - Name = name; } ///