Commits

rimmington  committed d84f8d8 Draft

List<T>.Shuffle() extension method checks for null

  • Participants
  • Parent commits b12aff6

Comments (0)

Files changed (2)

File Cineraria.Convenience/GlobalSuppressions.cs

 [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Scope = "member", Target = "Cineraria.Convenience.StringExtensions.#ToUILower(System.String)")]
 [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ahsb", Scope = "member", Target = "Cineraria.Convenience.ColorHelper.#FromAhsb(System.Int32,System.Single,System.Single,System.Single)")]
 [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes", Scope = "type", Target = "Cineraria.Convenience.ElementIndex`1")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Scope = "member", Target = "Cineraria.Convenience.EnumerableExtensions.#WithIndex`1(System.Collections.Generic.IEnumerable`1<!!0>)")]

File Cineraria.Convenience/ListExtensions.cs

         /// <param name="list">The list to shuffle.</param>
         public static void Shuffle<T>(this List<T> list)
         {
+            if (list == null)
+            {
+                return;
+            }
+
             Random rng = new Random();
             int n = list.Count;
             while (n > 1)