From 6a0c57cfe49fabb901317b45dcd863a439b03885 Mon Sep 17 00:00:00 2001 From: RogueException Date: Sat, 8 Apr 2017 17:24:02 -0300 Subject: [PATCH] Add range checks to new overload --- src/Discord.Net.Core/Entities/Roles/Color.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Discord.Net.Core/Entities/Roles/Color.cs b/src/Discord.Net.Core/Entities/Roles/Color.cs index 4c707006c..3250acb2d 100644 --- a/src/Discord.Net.Core/Entities/Roles/Color.cs +++ b/src/Discord.Net.Core/Entities/Roles/Color.cs @@ -32,6 +32,12 @@ namespace Discord } public Color(int r, int g, int b) { + if (r < 0 || r > 255) + throw new ArgumentOutOfRangeException(nameof(r), "Value must be within [0,255]"); + if (g < 0 || g > 255) + throw new ArgumentOutOfRangeException(nameof(g), "Value must be within [0,255]"); + if (b < 0 || b > 255) + throw new ArgumentOutOfRangeException(nameof(b), "Value must be within [0,255]"); RawValue = ((uint)r << 16) | ((uint)g << 8) | @@ -40,11 +46,11 @@ namespace Discord public Color(float r, float g, float b) { if (r < 0.0f || r > 1.0f) - throw new ArgumentOutOfRangeException(nameof(r), "A float value must be within [0,1]"); + throw new ArgumentOutOfRangeException(nameof(r), "Value must be within [0,1]"); if (g < 0.0f || g > 1.0f) - throw new ArgumentOutOfRangeException(nameof(g), "A float value must be within [0,1]"); + throw new ArgumentOutOfRangeException(nameof(g), "Value must be within [0,1]"); if (b < 0.0f || b > 1.0f) - throw new ArgumentOutOfRangeException(nameof(b), "A float value must be within [0,1]"); + throw new ArgumentOutOfRangeException(nameof(b), "Value must be within [0,1]"); RawValue = ((uint)(r * 255.0f) << 16) | ((uint)(g * 255.0f) << 8) |