From fab0e06c7f0ec7118fce633c529cd5397559890b Mon Sep 17 00:00:00 2001 From: Andreas Gruenwald Date: Fri, 29 May 2020 17:51:20 +0200 Subject: [PATCH] Replace argument checks with Requires.NotNull() / Requires.NotNullOrWhiteSpace() --- src/NerdBank.GitVersioning/ReleaseManager.cs | 23 ++++---------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/src/NerdBank.GitVersioning/ReleaseManager.cs b/src/NerdBank.GitVersioning/ReleaseManager.cs index 57ac1f27..1749e18e 100644 --- a/src/NerdBank.GitVersioning/ReleaseManager.cs +++ b/src/NerdBank.GitVersioning/ReleaseManager.cs @@ -115,11 +115,7 @@ public ReleaseInfo(ReleaseBranchInfo currentBranch) : this(currentBranch, null) [JsonConstructor] public ReleaseInfo(ReleaseBranchInfo currentBranch, ReleaseBranchInfo newBranch) { - if(currentBranch == null) - { - throw new ArgumentNullException(nameof(currentBranch), $"{nameof(this.CurrentBranch)} can't be empty"); - } - + Requires.NotNull(currentBranch, nameof(currentBranch)); // skip null check for newBranch, it is allowed to be null. this.CurrentBranch = currentBranch; @@ -155,20 +151,9 @@ public class ReleaseBranchInfo /// The version configured in the branch's version.json. public ReleaseBranchInfo(string name, string commit, SemanticVersion version) { - if (string.IsNullOrWhiteSpace(name)) - { - throw new ArgumentNullException(nameof(name), $"{nameof(this.Name)} can't be empty"); - } - - if (string.IsNullOrWhiteSpace(commit)) - { - throw new ArgumentNullException(nameof(commit), $"{nameof(this.Commit)} can't be empty"); - } - - if(version == null) - { - throw new ArgumentNullException(nameof(version), $"{nameof(this.Version)} can't be empty"); - } + Requires.NotNullOrWhiteSpace(name, nameof(name)); + Requires.NotNullOrWhiteSpace(commit, nameof(commit)); + Requires.NotNull(version, nameof(version)); this.Name = name; this.Commit = commit;