From 8a260e047509b8593ca93047dcdb1dc6f2f244b1 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Mon, 8 Oct 2018 14:53:43 -0400 Subject: [PATCH] refactor: Adding validation to StringUtils.Repeat --- ICD.Common.Utils/StringUtils.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ICD.Common.Utils/StringUtils.cs b/ICD.Common.Utils/StringUtils.cs index 812356c..a0c4ab0 100644 --- a/ICD.Common.Utils/StringUtils.cs +++ b/ICD.Common.Utils/StringUtils.cs @@ -423,7 +423,12 @@ namespace ICD.Common.Utils [PublicAPI] public static string Repeat(string input, int count) { - return count == 0 ? string.Empty : new StringBuilder().Insert(0, input, count).ToString(); + if (count < 0) + throw new ArgumentOutOfRangeException("count"); + + return input == null || count == 0 + ? string.Empty + : new StringBuilder().Insert(0, input, count).ToString(); } ///