From eda605040daccd5d849b2cf47abefd99875440cf Mon Sep 17 00:00:00 2001 From: rdc64 Date: Thu, 8 Feb 2018 16:35:06 -0500 Subject: [PATCH 1/6] Added visibility field to EmailAddress response model --- Octokit/Models/Response/EmailAddress.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Octokit/Models/Response/EmailAddress.cs b/Octokit/Models/Response/EmailAddress.cs index de5aaec3ff..6348166b0c 100644 --- a/Octokit/Models/Response/EmailAddress.cs +++ b/Octokit/Models/Response/EmailAddress.cs @@ -12,11 +12,12 @@ public class EmailAddress { public EmailAddress() { } - public EmailAddress(string email, bool verified, bool primary) + public EmailAddress(string email, bool verified, bool primary, string visibility) { Email = email; Verified = verified; Primary = primary; + Visibility = visibility; } /// @@ -34,6 +35,11 @@ public EmailAddress(string email, bool verified, bool primary) /// public bool Primary { get; protected set; } + /// + /// private if the email is private; otherwise null + /// + public string Visibility { get; protected set; } + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Used by DebuggerDisplayAttribute")] internal string DebuggerDisplay @@ -41,7 +47,7 @@ internal string DebuggerDisplay get { return string.Format(CultureInfo.InvariantCulture, - "EmailAddress: Email: {0}; Primary: {1}, Verified: {2}", Email, Primary, Verified); + "EmailAddress: Email: {0}; Primary: {1}, Verified: {2}, Visibility: {3}", Email, Primary, Verified, Visibility); } } } From 3aae51e5ddc7f858a0ba8d9100b96c3b59801062 Mon Sep 17 00:00:00 2001 From: rdc64 Date: Thu, 8 Feb 2018 16:37:29 -0500 Subject: [PATCH 2/6] quote private in comment to indicate string value --- Octokit/Models/Response/EmailAddress.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Models/Response/EmailAddress.cs b/Octokit/Models/Response/EmailAddress.cs index 6348166b0c..fd7abdc972 100644 --- a/Octokit/Models/Response/EmailAddress.cs +++ b/Octokit/Models/Response/EmailAddress.cs @@ -36,7 +36,7 @@ public EmailAddress(string email, bool verified, bool primary, string visibility public bool Primary { get; protected set; } /// - /// private if the email is private; otherwise null + /// "private" if the email is private; otherwise null /// public string Visibility { get; protected set; } From 1c29a0d4fbea742d4cc79d9f50f63a910326a135 Mon Sep 17 00:00:00 2001 From: rdc64 Date: Mon, 12 Feb 2018 15:26:29 -0800 Subject: [PATCH 3/6] Create EmailVisibility enum; change visibility to be StringEnum --- Octokit/Models/Response/EmailAddress.cs | 36 +++++++++++++++++++++---- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/Octokit/Models/Response/EmailAddress.cs b/Octokit/Models/Response/EmailAddress.cs index fd7abdc972..1081442d2c 100644 --- a/Octokit/Models/Response/EmailAddress.cs +++ b/Octokit/Models/Response/EmailAddress.cs @@ -1,6 +1,7 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; +using Octokit.Internal; namespace Octokit { @@ -12,7 +13,7 @@ public class EmailAddress { public EmailAddress() { } - public EmailAddress(string email, bool verified, bool primary, string visibility) + public EmailAddress(string email, bool verified, bool primary, EmailVisibility visibility) { Email = email; Verified = verified; @@ -26,19 +27,20 @@ public EmailAddress(string email, bool verified, bool primary, string visibility public string Email { get; protected set; } /// - /// true if the email is verified; otherwise false + /// True if the email is verified; otherwise false /// public bool Verified { get; protected set; } /// - /// true if this is the users primary email; otherwise false + /// True if this is the users primary email; otherwise false /// public bool Primary { get; protected set; } /// - /// "private" if the email is private; otherwise null + /// "private" or "public" if the email address is the primary; + /// otherwise null /// - public string Visibility { get; protected set; } + public StringEnum Visibility { get; protected set; } [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Used by DebuggerDisplayAttribute")] @@ -51,4 +53,28 @@ internal string DebuggerDisplay } } } + + /// + /// Represents the visibility of an email address. + /// + public enum EmailVisibility + { + /// + /// Primary email address and is public + /// + [Parameter(Value = "public")] + Public, + + /// + /// Primary email address and is private + /// + [Parameter(Value = "private")] + Private, + + /// + /// Email is not the primary address + /// + [Parameter(Value = "null")] + All + } } \ No newline at end of file From e7b3c271b4e453e1af1cd55ec41e856e184aea96 Mon Sep 17 00:00:00 2001 From: rdc64 Date: Tue, 13 Feb 2018 09:57:08 -0800 Subject: [PATCH 4/6] Change EmailVisibility to be nullable, remove null option from enum --- Octokit/Models/Response/EmailAddress.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Octokit/Models/Response/EmailAddress.cs b/Octokit/Models/Response/EmailAddress.cs index 1081442d2c..37728070b0 100644 --- a/Octokit/Models/Response/EmailAddress.cs +++ b/Octokit/Models/Response/EmailAddress.cs @@ -40,7 +40,7 @@ public EmailAddress(string email, bool verified, bool primary, EmailVisibility v /// "private" or "public" if the email address is the primary; /// otherwise null /// - public StringEnum Visibility { get; protected set; } + public StringEnum? Visibility { get; protected set; } [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Used by DebuggerDisplayAttribute")] @@ -69,12 +69,6 @@ public enum EmailVisibility /// Primary email address and is private /// [Parameter(Value = "private")] - Private, - - /// - /// Email is not the primary address - /// - [Parameter(Value = "null")] - All + Private } } \ No newline at end of file From 76d49c8ef0352d1198ccb008fb106ce28cc62cbc Mon Sep 17 00:00:00 2001 From: rdc64 Date: Tue, 13 Feb 2018 10:02:54 -0800 Subject: [PATCH 5/6] Fixed closing tag on Visibility property summary --- Octokit/Models/Response/EmailAddress.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Models/Response/EmailAddress.cs b/Octokit/Models/Response/EmailAddress.cs index 37728070b0..0ae7e3cbb4 100644 --- a/Octokit/Models/Response/EmailAddress.cs +++ b/Octokit/Models/Response/EmailAddress.cs @@ -39,7 +39,7 @@ public EmailAddress(string email, bool verified, bool primary, EmailVisibility v /// /// "private" or "public" if the email address is the primary; /// otherwise null - /// + /// public StringEnum? Visibility { get; protected set; } [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", From 972d4324009ef7c8570b4a2a2b201bceaeb0ca36 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sun, 18 Feb 2018 13:41:42 +1000 Subject: [PATCH 6/6] unskip email integration test as it seems to work now --- Octokit.Tests.Integration/Clients/UserEmailsClientTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit.Tests.Integration/Clients/UserEmailsClientTests.cs b/Octokit.Tests.Integration/Clients/UserEmailsClientTests.cs index 492132ceda..9a2c2ef5e2 100644 --- a/Octokit.Tests.Integration/Clients/UserEmailsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/UserEmailsClientTests.cs @@ -44,7 +44,7 @@ public async Task ReturnsCorrectCountOfEmailsWithoutStart() const string testEmailAddress = "hahaha-not-a-real-email@foo.com"; - [IntegrationTest(Skip = "this isn't passing in CI - i hate past me right now")] + [IntegrationTest] public async Task CanAddAndDeleteEmail() { var github = Helper.GetAuthenticatedClient();