Add various property validation in EmbedBuilder (#711)

* Add various property validation in EmbedBuilder

* Embed URI changes

Changes property types for any URLs in Embeds to System.URI.
Adding field name/value null/empty checks.

* including property names in argumentexceptions

* Adds overall embed length check
This commit is contained in:
Pat Murphy
2017-06-23 07:29:55 -07:00
committed by RogueException
parent 5f04e2beba
commit 5601d00285
16 changed files with 163 additions and 69 deletions

View File

@@ -13,7 +13,7 @@ namespace Discord.API
[JsonProperty("description")]
public string Description { get; set; }
[JsonProperty("url")]
public string Url { get; set; }
public Uri Url { get; set; }
[JsonProperty("color")]
public uint? Color { get; set; }
[JsonProperty("timestamp")]

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using System;
using Newtonsoft.Json;
namespace Discord.API
{
@@ -7,10 +8,10 @@ namespace Discord.API
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("url")]
public string Url { get; set; }
public Uri Url { get; set; }
[JsonProperty("icon_url")]
public string IconUrl { get; set; }
public Uri IconUrl { get; set; }
[JsonProperty("proxy_icon_url")]
public string ProxyIconUrl { get; set; }
public Uri ProxyIconUrl { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using System;
using Newtonsoft.Json;
namespace Discord.API
{
@@ -7,8 +8,8 @@ namespace Discord.API
[JsonProperty("text")]
public string Text { get; set; }
[JsonProperty("icon_url")]
public string IconUrl { get; set; }
public Uri IconUrl { get; set; }
[JsonProperty("proxy_icon_url")]
public string ProxyIconUrl { get; set; }
public Uri ProxyIconUrl { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
#pragma warning disable CS1591
using System;
using Newtonsoft.Json;
namespace Discord.API
@@ -6,9 +7,9 @@ namespace Discord.API
internal class EmbedImage
{
[JsonProperty("url")]
public string Url { get; set; }
public Uri Url { get; set; }
[JsonProperty("proxy_url")]
public string ProxyUrl { get; set; }
public Uri ProxyUrl { get; set; }
[JsonProperty("height")]
public Optional<int> Height { get; set; }
[JsonProperty("width")]

View File

@@ -1,4 +1,5 @@
#pragma warning disable CS1591
using System;
using Newtonsoft.Json;
namespace Discord.API
@@ -8,6 +9,6 @@ namespace Discord.API
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("url")]
public string Url { get; set; }
public Uri Url { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
#pragma warning disable CS1591
using System;
using Newtonsoft.Json;
namespace Discord.API
@@ -6,9 +7,9 @@ namespace Discord.API
internal class EmbedThumbnail
{
[JsonProperty("url")]
public string Url { get; set; }
public Uri Url { get; set; }
[JsonProperty("proxy_url")]
public string ProxyUrl { get; set; }
public Uri ProxyUrl { get; set; }
[JsonProperty("height")]
public Optional<int> Height { get; set; }
[JsonProperty("width")]

View File

@@ -1,4 +1,5 @@
#pragma warning disable CS1591
using System;
using Newtonsoft.Json;
namespace Discord.API
@@ -6,7 +7,7 @@ namespace Discord.API
internal class EmbedVideo
{
[JsonProperty("url")]
public string Url { get; set; }
public Uri Url { get; set; }
[JsonProperty("height")]
public Optional<int> Height { get; set; }
[JsonProperty("width")]