From 3345f76fc9a499aca6f49defb345a7926ceb4c87 Mon Sep 17 00:00:00 2001 From: tasadar2 Date: Wed, 25 Apr 2018 07:03:13 -0400 Subject: [PATCH] Adding a convention test to detect whether a model has a constructor exposing all properties (#1798) * Added a convention test to detect a model constructor exposing all properties * add ctors to classes where they are missing * rename ctor parameters that dont match properties * add missing parameters to existing ctors * add specific PunchCard ctor to allow mocking, and update test to resolve call ambiguity * Added base class properties to the convention test Added member exclusion attribute * Updated newly offending classes 2 excludes and 2 ctors * rename exclusion attribute to be a bit shorter --- ...icConstructorWithAllPropertiesException.cs | 22 ++++++++++++ Octokit.Tests.Conventions/ModelTests.cs | 36 +++++++++++++++++++ .../Clients/AuthorizationsClientTests.cs | 4 +-- Octokit.Tests/Models/PunchCardTests.cs | 2 +- .../Reactive/AuthorizationExtensionsTests.cs | 7 ++-- ...ithAllPropertiesConventionTestAttribute.cs | 15 ++++++++ Octokit/Http/RateLimit.cs | 6 ++-- Octokit/Models/Response/Activity.cs | 3 +- .../ActivityPayloads/ActivityPayload.cs | 10 ++++++ .../Response/ApplicationAuthorization.cs | 4 ++- Octokit/Models/Response/Authorization.cs | 5 ++- Octokit/Models/Response/BranchProtection.cs | 7 ++++ .../Models/Response/CollaboratorPermission.cs | 8 +++++ Octokit/Models/Response/Commit.cs | 3 +- Octokit/Models/Response/CommitComment.cs | 6 +++- Octokit/Models/Response/Deployment.cs | 4 ++- Octokit/Models/Response/DeploymentStatus.cs | 4 ++- Octokit/Models/Response/GitTag.cs | 5 +-- Octokit/Models/Response/GpgKey.cs | 18 ++++++++++ Octokit/Models/Response/Issue.cs | 6 +++- Octokit/Models/Response/IssueComment.cs | 6 +++- Octokit/Models/Response/Merge.cs | 3 +- Octokit/Models/Response/Organization.cs | 1 + Octokit/Models/Response/Page.cs | 3 +- .../Response/PullRequestReviewComment.cs | 6 +++- Octokit/Models/Response/PunchCard.cs | 7 +++- Octokit/Models/Response/ReactionSummary.cs | 14 ++++++++ Octokit/Models/Response/Reference.cs | 4 +-- Octokit/Models/Response/RenameInfo.cs | 8 +++++ Octokit/Models/Response/SourceInfo.cs | 10 ++++++ Octokit/Models/Response/Team.cs | 3 +- .../Models/Response/TeamMembershipDetails.cs | 8 +++++ Octokit/Models/Response/User.cs | 1 + Octokit/Models/Response/Verification.cs | 10 ++++++ 34 files changed, 232 insertions(+), 27 deletions(-) create mode 100644 Octokit.Tests.Conventions/Exception/MissingPublicConstructorWithAllPropertiesException.cs create mode 100644 Octokit/Helpers/ExcludeFromCtorWithAllPropertiesConventionTestAttribute.cs diff --git a/Octokit.Tests.Conventions/Exception/MissingPublicConstructorWithAllPropertiesException.cs b/Octokit.Tests.Conventions/Exception/MissingPublicConstructorWithAllPropertiesException.cs new file mode 100644 index 0000000000..671c9422fe --- /dev/null +++ b/Octokit.Tests.Conventions/Exception/MissingPublicConstructorWithAllPropertiesException.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +namespace Octokit.Tests.Conventions +{ + public class MissingPublicConstructorWithAllPropertiesException : Exception + { + public MissingPublicConstructorWithAllPropertiesException(Type modelType, IEnumerable missingProperties) + : base(CreateMessage(modelType, missingProperties)) + { } + + private static string CreateMessage(Type modelType, IEnumerable missingProperties) + { + return string.Format("Model type '{0}' is missing a constructor with all properties. Closest match is missing the following properties: {1}{2}", + modelType.FullName, + Environment.NewLine, + string.Join(Environment.NewLine, missingProperties.Select(prop => prop.Name))); + } + } +} diff --git a/Octokit.Tests.Conventions/ModelTests.cs b/Octokit.Tests.Conventions/ModelTests.cs index d89234f6bd..e6b19e9dfd 100644 --- a/Octokit.Tests.Conventions/ModelTests.cs +++ b/Octokit.Tests.Conventions/ModelTests.cs @@ -52,6 +52,42 @@ public void AllResponseModelsHavePublicParameterlessCtors(Type modelType) } } + [Theory] + [MemberData(nameof(ResponseModelTypes))] + public void AllResponseModelsHavePublicCtorWithAllProperties(Type modelType) + { + var excludedProperties = modelType.GetCustomAttribute()? + .Properties ?? + new string[] { }; + + var constructors = modelType.GetConstructors(); + var properties = modelType.GetProperties() + .Where(prop => prop.CanWrite && + !excludedProperties.Contains(prop.Name)) + .ToList(); + + var missingProperties = properties.ToList(); + foreach (var constructor in constructors) + { + var parameters = constructor.GetParameters(); + + var constructorMissingProperties = properties.Where(property => + !parameters.Any(param => + string.Equals(param.Name, property.Name, StringComparison.InvariantCultureIgnoreCase))) + .ToList(); + + if (constructorMissingProperties.Count < missingProperties.Count) + { + missingProperties = constructorMissingProperties; + } + } + + if (missingProperties.Any()) + { + throw new MissingPublicConstructorWithAllPropertiesException(modelType, missingProperties); + } + } + [Theory] [MemberData(nameof(ResponseModelTypes))] public void ResponseModelsHaveGetterOnlyProperties(Type modelType) diff --git a/Octokit.Tests/Clients/AuthorizationsClientTests.cs b/Octokit.Tests/Clients/AuthorizationsClientTests.cs index cce9b585e1..8314fddafd 100644 --- a/Octokit.Tests/Clients/AuthorizationsClientTests.cs +++ b/Octokit.Tests/Clients/AuthorizationsClientTests.cs @@ -172,7 +172,7 @@ public async Task UsesCallbackToRetrieveTwoFactorCode() "secret", Arg.Any(), "two-factor-code") - .Returns(Task.Factory.StartNew(() => new ApplicationAuthorization("xyz"))); + .Returns(Task.Factory.StartNew(() => new ApplicationAuthorization(0, null, null, null, null, null, null, null, DateTimeOffset.Now, DateTimeOffset.Now, null, "xyz"))); var result = await client.GetOrCreateApplicationAuthentication("clientId", "secret", @@ -204,7 +204,7 @@ public async Task RetriesWhenResendRequested() "secret", Arg.Any(), "two-factor-code") - .Returns(Task.Factory.StartNew(() => new ApplicationAuthorization("OAUTHSECRET"))); + .Returns(Task.Factory.StartNew(() => new ApplicationAuthorization(0, null, null, null, null, null, null, null, DateTimeOffset.Now, DateTimeOffset.Now, null, "OAUTHSECRET"))); var result = await client.GetOrCreateApplicationAuthentication("clientId", "secret", diff --git a/Octokit.Tests/Models/PunchCardTests.cs b/Octokit.Tests/Models/PunchCardTests.cs index 3763d18e2a..781f2ea07f 100644 --- a/Octokit.Tests/Models/PunchCardTests.cs +++ b/Octokit.Tests/Models/PunchCardTests.cs @@ -11,7 +11,7 @@ public class TheConstructor [Fact] public void ThrowsExceptionWithNullPunchCardPoints() { - Assert.Throws(() => new PunchCard(null)); + Assert.Throws(() => new PunchCard((IEnumerable>)null)); } [Fact] diff --git a/Octokit.Tests/Reactive/AuthorizationExtensionsTests.cs b/Octokit.Tests/Reactive/AuthorizationExtensionsTests.cs index 77871409e9..d3a758e98d 100644 --- a/Octokit.Tests/Reactive/AuthorizationExtensionsTests.cs +++ b/Octokit.Tests/Reactive/AuthorizationExtensionsTests.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Reactive.Linq; using System.Threading.Tasks; using NSubstitute; @@ -16,7 +17,7 @@ public async Task UsesCallbackToRetrieveTwoFactorCode() { var firstResponse = new TwoFactorRequiredException(TwoFactorType.AuthenticatorApp); var twoFactorChallengeResult = new TwoFactorChallengeResult("two-factor-code"); - var secondResponse = new ApplicationAuthorization("OAUTHSECRET"); + var secondResponse = new ApplicationAuthorization(0, null, null, null, null, null, null, null, DateTimeOffset.Now, DateTimeOffset.Now, null, "OAUTHSECRET"); var client = Substitute.For(); client.GetOrCreateApplicationAuthentication(Args.String, Args.String, Args.NewAuthorization) @@ -51,7 +52,7 @@ public async Task RetriesWhenResendRequested() TwoFactorChallengeResult.RequestResendCode, new TwoFactorChallengeResult("two-factor-code") }); - var secondResponse = new ApplicationAuthorization("OAUTHSECRET"); + var secondResponse = new ApplicationAuthorization(0, null, null, null, null, null, null, null, DateTimeOffset.Now, DateTimeOffset.Now, null, "OAUTHSECRET"); var client = Substitute.For(); client.GetOrCreateApplicationAuthentication(Args.String, Args.String, Args.NewAuthorization) diff --git a/Octokit/Helpers/ExcludeFromCtorWithAllPropertiesConventionTestAttribute.cs b/Octokit/Helpers/ExcludeFromCtorWithAllPropertiesConventionTestAttribute.cs new file mode 100644 index 0000000000..caad03a933 --- /dev/null +++ b/Octokit/Helpers/ExcludeFromCtorWithAllPropertiesConventionTestAttribute.cs @@ -0,0 +1,15 @@ +using System; + +namespace Octokit +{ + [AttributeUsage(AttributeTargets.Class)] + public sealed class ExcludeFromCtorWithAllPropertiesConventionTestAttribute : Attribute + { + public ExcludeFromCtorWithAllPropertiesConventionTestAttribute(params string[] properties) + { + Properties = properties; + } + + public string[] Properties { get; private set; } + } +} diff --git a/Octokit/Http/RateLimit.cs b/Octokit/Http/RateLimit.cs index a2251b17fb..9a24896b46 100644 --- a/Octokit/Http/RateLimit.cs +++ b/Octokit/Http/RateLimit.cs @@ -32,15 +32,15 @@ public RateLimit(IDictionary responseHeaders) ResetAsUtcEpochSeconds = GetHeaderValueAsInt32Safe(responseHeaders, "X-RateLimit-Reset"); } - public RateLimit(int limit, int remaining, long reset) + public RateLimit(int limit, int remaining, long resetAsUtcEpochSeconds) { Ensure.ArgumentNotNull(limit, nameof(limit)); Ensure.ArgumentNotNull(remaining, nameof(remaining)); - Ensure.ArgumentNotNull(reset, nameof(reset)); + Ensure.ArgumentNotNull(resetAsUtcEpochSeconds, nameof(resetAsUtcEpochSeconds)); Limit = limit; Remaining = remaining; - ResetAsUtcEpochSeconds = reset; + ResetAsUtcEpochSeconds = resetAsUtcEpochSeconds; } /// diff --git a/Octokit/Models/Response/Activity.cs b/Octokit/Models/Response/Activity.cs index 40b6a091cb..5a453ef91d 100644 --- a/Octokit/Models/Response/Activity.cs +++ b/Octokit/Models/Response/Activity.cs @@ -13,7 +13,7 @@ public class Activity { public Activity() { } - public Activity(string type, bool @public, Repository repo, User actor, Organization org, DateTimeOffset createdAt, string id) + public Activity(string type, bool @public, Repository repo, User actor, Organization org, DateTimeOffset createdAt, string id, ActivityPayload payload) { Type = type; Public = @public; @@ -22,6 +22,7 @@ public Activity(string type, bool @public, Repository repo, User actor, Organiza Org = org; CreatedAt = createdAt; Id = id; + Payload = payload; } /// diff --git a/Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs b/Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs index 1a8b8baf9f..ea89c33195 100644 --- a/Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs @@ -5,6 +5,16 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class ActivityPayload { + public ActivityPayload() { } + + + public ActivityPayload(Repository repository, User sender, InstallationId installation) + { + Repository = repository; + Sender = sender; + Installation = installation; + } + public Repository Repository { get; protected set; } public User Sender { get; protected set; } public InstallationId Installation { get; protected set; } diff --git a/Octokit/Models/Response/ApplicationAuthorization.cs b/Octokit/Models/Response/ApplicationAuthorization.cs index ba96244fc4..04c8ab2a31 100644 --- a/Octokit/Models/Response/ApplicationAuthorization.cs +++ b/Octokit/Models/Response/ApplicationAuthorization.cs @@ -1,3 +1,4 @@ +using System; using System.Diagnostics; namespace Octokit @@ -13,7 +14,8 @@ public ApplicationAuthorization() { } - public ApplicationAuthorization(string token) + public ApplicationAuthorization(int id, string url, Application application, string tokenLastEight, string hashedToken, string fingerprint, string note, string noteUrl, DateTimeOffset createdAt, DateTimeOffset updateAt, string[] scopes, string token) + : base(id, url, application, tokenLastEight, hashedToken, fingerprint, note, noteUrl, createdAt, updateAt, scopes) { Token = token; } diff --git a/Octokit/Models/Response/Authorization.cs b/Octokit/Models/Response/Authorization.cs index 6c7bbf1ca5..ea930e08e1 100644 --- a/Octokit/Models/Response/Authorization.cs +++ b/Octokit/Models/Response/Authorization.cs @@ -14,7 +14,7 @@ public class Authorization // TODO: I'd love to not need this public Authorization() { } - public Authorization(int id, string url, Application application, string note, string noteUrl, DateTimeOffset createdAt, DateTimeOffset updateAt, string[] scopes) + public Authorization(int id, string url, Application application, string tokenLastEight, string hashedToken, string fingerprint, string note, string noteUrl, DateTimeOffset createdAt, DateTimeOffset updateAt, string[] scopes) { Id = id; Url = url; @@ -22,6 +22,9 @@ public Authorization(int id, string url, Application application, string note, s // TODO: testable ctor for new values //Token = token; + TokenLastEight = tokenLastEight; + HashedToken = hashedToken; + Fingerprint = fingerprint; Note = note; NoteUrl = noteUrl; diff --git a/Octokit/Models/Response/BranchProtection.cs b/Octokit/Models/Response/BranchProtection.cs index f0012a4959..0b823581ad 100644 --- a/Octokit/Models/Response/BranchProtection.cs +++ b/Octokit/Models/Response/BranchProtection.cs @@ -165,6 +165,13 @@ public class BranchProtectionRequiredReviews { public BranchProtectionRequiredReviews() { } + public BranchProtectionRequiredReviews(BranchProtectionRequiredReviewsDismissalRestrictions dismissalRestrictions, bool dismissStaleReviews, bool requireCodeOwnerReviews) + { + DismissalRestrictions = dismissalRestrictions; + DismissStaleReviews = dismissStaleReviews; + RequireCodeOwnerReviews = requireCodeOwnerReviews; + } + /// /// Specify which users and teams can dismiss pull request reviews. /// diff --git a/Octokit/Models/Response/CollaboratorPermission.cs b/Octokit/Models/Response/CollaboratorPermission.cs index 7136dfb127..4a9b29b102 100644 --- a/Octokit/Models/Response/CollaboratorPermission.cs +++ b/Octokit/Models/Response/CollaboratorPermission.cs @@ -5,6 +5,14 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CollaboratorPermission { + public CollaboratorPermission() { } + + public CollaboratorPermission(PermissionLevel permission, User user) + { + Permission = permission; + User = user; + } + public StringEnum Permission { get; protected set; } public User User { get; protected set; } diff --git a/Octokit/Models/Response/Commit.cs b/Octokit/Models/Response/Commit.cs index 7d85fbc3f8..1623692a48 100644 --- a/Octokit/Models/Response/Commit.cs +++ b/Octokit/Models/Response/Commit.cs @@ -10,7 +10,7 @@ public class Commit : GitReference { public Commit() { } - public Commit(string url, string label, string @ref, string sha, User user, Repository repository, string message, Committer author, Committer committer, GitReference tree, IEnumerable parents, int commentCount) + public Commit(string url, string label, string @ref, string sha, User user, Repository repository, string message, Committer author, Committer committer, GitReference tree, IEnumerable parents, int commentCount, Verification verification) : base(url, label, @ref, sha, user, repository) { Ensure.ArgumentNotNull(parents, nameof(parents)); @@ -21,6 +21,7 @@ public Commit(string url, string label, string @ref, string sha, User user, Repo Tree = tree; Parents = new ReadOnlyCollection(parents.ToList()); CommentCount = commentCount; + Verification = verification; } public string Message { get; protected set; } diff --git a/Octokit/Models/Response/CommitComment.cs b/Octokit/Models/Response/CommitComment.cs index 1178f57e1b..4038f6e4e8 100644 --- a/Octokit/Models/Response/CommitComment.cs +++ b/Octokit/Models/Response/CommitComment.cs @@ -9,7 +9,7 @@ public class CommitComment { public CommitComment() { } - public CommitComment(int id, string url, string htmlUrl, string body, string path, int position, int? line, string commitId, User user, DateTimeOffset createdAt, DateTimeOffset? updatedAt) + public CommitComment(int id, string url, string htmlUrl, string body, string path, int position, int? line, string commitId, User user, DateTimeOffset createdAt, DateTimeOffset? updatedAt, ReactionSummary reactions) { Id = id; Url = url; @@ -22,6 +22,7 @@ public CommitComment(int id, string url, string htmlUrl, string body, string pat User = user; CreatedAt = createdAt; UpdatedAt = updatedAt; + Reactions = reactions; } /// @@ -79,6 +80,9 @@ public CommitComment(int id, string url, string htmlUrl, string body, string pat /// public DateTimeOffset? UpdatedAt { get; protected set; } + /// + /// The reaction summary for this comment. + /// public ReactionSummary Reactions { get; protected set; } internal string DebuggerDisplay diff --git a/Octokit/Models/Response/Deployment.cs b/Octokit/Models/Response/Deployment.cs index b1254dcef8..a9ab8fe2cd 100644 --- a/Octokit/Models/Response/Deployment.cs +++ b/Octokit/Models/Response/Deployment.cs @@ -13,7 +13,7 @@ public class Deployment { public Deployment() { } - public Deployment(int id, string sha, string url, User creator, IReadOnlyDictionary payload, DateTimeOffset createdAt, DateTimeOffset updatedAt, string description, string statusesUrl) + public Deployment(int id, string sha, string url, User creator, IReadOnlyDictionary payload, DateTimeOffset createdAt, DateTimeOffset updatedAt, string description, string statusesUrl, bool transientEnvironment, bool productionEnvironment) { Id = id; Sha = sha; @@ -24,6 +24,8 @@ public Deployment(int id, string sha, string url, User creator, IReadOnlyDiction UpdatedAt = updatedAt; Description = description; StatusesUrl = statusesUrl; + TransientEnvironment = transientEnvironment; + ProductionEnvironment = productionEnvironment; } /// diff --git a/Octokit/Models/Response/DeploymentStatus.cs b/Octokit/Models/Response/DeploymentStatus.cs index 643ca81063..363144da5f 100644 --- a/Octokit/Models/Response/DeploymentStatus.cs +++ b/Octokit/Models/Response/DeploymentStatus.cs @@ -11,7 +11,7 @@ public class DeploymentStatus { public DeploymentStatus() { } - public DeploymentStatus(int id, string url, DeploymentState state, User creator, IReadOnlyDictionary payload, string targetUrl, DateTimeOffset createdAt, DateTimeOffset updatedAt, string description) + public DeploymentStatus(int id, string url, DeploymentState state, User creator, IReadOnlyDictionary payload, string targetUrl, string logUrl, string environmentUrl, DateTimeOffset createdAt, DateTimeOffset updatedAt, string description) { Id = id; Url = url; @@ -19,6 +19,8 @@ public DeploymentStatus(int id, string url, DeploymentState state, User creator, Creator = creator; Payload = payload; TargetUrl = targetUrl; + LogUrl = logUrl; + EnvironmentUrl = environmentUrl; CreatedAt = createdAt; UpdatedAt = updatedAt; Description = description; diff --git a/Octokit/Models/Response/GitTag.cs b/Octokit/Models/Response/GitTag.cs index 157be17f76..5c7e73d5d7 100644 --- a/Octokit/Models/Response/GitTag.cs +++ b/Octokit/Models/Response/GitTag.cs @@ -7,13 +7,14 @@ public class GitTag : GitReference { public GitTag() { } - public GitTag(string url, string label, string @ref, string sha, User user, Repository repository, string tag, string message, Committer tagger, TagObject objectVar) + public GitTag(string url, string label, string @ref, string sha, User user, Repository repository, string tag, string message, Committer tagger, TagObject @object, Verification verification) : base(url, label, @ref, sha, user, repository) { Tag = tag; Message = message; Tagger = tagger; - Object = objectVar; + Object = @object; + Verification = verification; } public string Tag { get; protected set; } diff --git a/Octokit/Models/Response/GpgKey.cs b/Octokit/Models/Response/GpgKey.cs index f55cc02162..311393b4ea 100644 --- a/Octokit/Models/Response/GpgKey.cs +++ b/Octokit/Models/Response/GpgKey.cs @@ -10,6 +10,24 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class GpgKey { + public GpgKey() { } + + public GpgKey(int id, int? primaryKeyId, string keyId, string publicKey, IReadOnlyList emails, IReadOnlyList subkeys, bool canSign, bool canEncryptCommunications, bool canEncryptStorage, bool canCertify, DateTimeOffset createdAt, DateTimeOffset? expiresAt) + { + Id = id; + PrimaryKeyId = primaryKeyId; + KeyId = keyId; + PublicKey = publicKey; + Emails = emails; + Subkeys = subkeys; + CanSign = canSign; + CanEncryptCommunications = canEncryptCommunications; + CanEncryptStorage = canEncryptStorage; + CanCertify = canCertify; + CreatedAt = createdAt; + ExpiresAt = expiresAt; + } + public int Id { get; protected set; } public int? PrimaryKeyId { get; protected set; } public string KeyId { get; protected set; } diff --git a/Octokit/Models/Response/Issue.cs b/Octokit/Models/Response/Issue.cs index bc3007bf6f..2f7b930234 100644 --- a/Octokit/Models/Response/Issue.cs +++ b/Octokit/Models/Response/Issue.cs @@ -11,7 +11,7 @@ public class Issue { public Issue() { } - public Issue(string url, string htmlUrl, string commentsUrl, string eventsUrl, int number, ItemState state, string title, string body, User closedBy, User user, IReadOnlyList public string PullRequestUrl { get; protected set; } + /// + /// The reaction summary for this comment. + /// public ReactionSummary Reactions { get; protected set; } /// diff --git a/Octokit/Models/Response/PunchCard.cs b/Octokit/Models/Response/PunchCard.cs index 4aea7bab63..ae84674ba5 100644 --- a/Octokit/Models/Response/PunchCard.cs +++ b/Octokit/Models/Response/PunchCard.cs @@ -16,7 +16,12 @@ public PunchCard(IEnumerable> punchCardData) { Ensure.ArgumentNotNull(punchCardData, nameof(punchCardData)); PunchPoints = new ReadOnlyCollection( - punchCardData.Select(point => new PunchCardPoint(point)).ToList()); + punchCardData.Select(point => new PunchCardPoint(point)).ToList()); + } + + public PunchCard(IEnumerable punchPoints) + { + PunchPoints = punchPoints?.ToList(); } /// diff --git a/Octokit/Models/Response/ReactionSummary.cs b/Octokit/Models/Response/ReactionSummary.cs index 9468a298ad..96ef77a8de 100644 --- a/Octokit/Models/Response/ReactionSummary.cs +++ b/Octokit/Models/Response/ReactionSummary.cs @@ -7,6 +7,20 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class ReactionSummary { + public ReactionSummary() { } + + public ReactionSummary(int totalCount, int plus1, int minus1, int laugh, int confused, int heart, int hooray, string url) + { + TotalCount = totalCount; + Plus1 = plus1; + Minus1 = minus1; + Laugh = laugh; + Confused = confused; + Heart = heart; + Hooray = hooray; + Url = url; + } + public int TotalCount { get; protected set; } [Parameter(Key = "+1")] public int Plus1 { get; protected set; } diff --git a/Octokit/Models/Response/Reference.cs b/Octokit/Models/Response/Reference.cs index b2c78bb2de..ce52179868 100644 --- a/Octokit/Models/Response/Reference.cs +++ b/Octokit/Models/Response/Reference.cs @@ -8,11 +8,11 @@ public class Reference { public Reference() { } - public Reference(string @ref, string url, TagObject objectVar) + public Reference(string @ref, string url, TagObject @object) { Ref = @ref; Url = url; - Object = objectVar; + Object = @object; } public string Ref { get; protected set; } diff --git a/Octokit/Models/Response/RenameInfo.cs b/Octokit/Models/Response/RenameInfo.cs index d21f0f3234..baf3bc8b35 100644 --- a/Octokit/Models/Response/RenameInfo.cs +++ b/Octokit/Models/Response/RenameInfo.cs @@ -6,6 +6,14 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class RenameInfo { + public RenameInfo() { } + + public RenameInfo(string from, string to) + { + From = from; + To = to; + } + public string From { get; protected set; } public string To { get; protected set; } diff --git a/Octokit/Models/Response/SourceInfo.cs b/Octokit/Models/Response/SourceInfo.cs index 7e52de169a..06cb292e3b 100644 --- a/Octokit/Models/Response/SourceInfo.cs +++ b/Octokit/Models/Response/SourceInfo.cs @@ -6,6 +6,16 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class SourceInfo { + public SourceInfo() { } + + public SourceInfo(User actor, int id, Issue issue, string url) + { + Actor = actor; + Id = id; + Issue = issue; + Url = url; + } + public User Actor { get; protected set; } public int Id { get; protected set; } public Issue Issue { get; protected set; } diff --git a/Octokit/Models/Response/Team.cs b/Octokit/Models/Response/Team.cs index 33698b9ab9..3b5a8fe374 100644 --- a/Octokit/Models/Response/Team.cs +++ b/Octokit/Models/Response/Team.cs @@ -12,7 +12,7 @@ public class Team { public Team() { } - public Team(string url, int id, string name, string description, TeamPrivacy privacy, Permission permission, int membersCount, int reposCount, Organization organization, string ldapDistinguishedName) + public Team(string url, int id, string name, string description, TeamPrivacy privacy, Permission permission, int membersCount, int reposCount, Organization organization, Team parent, string ldapDistinguishedName) { Url = url; Id = id; @@ -23,6 +23,7 @@ public Team(string url, int id, string name, string description, TeamPrivacy pri MembersCount = membersCount; ReposCount = reposCount; Organization = organization; + Parent = parent; LdapDistinguishedName = ldapDistinguishedName; } diff --git a/Octokit/Models/Response/TeamMembershipDetails.cs b/Octokit/Models/Response/TeamMembershipDetails.cs index 53abf76bfd..dbc1c75de8 100644 --- a/Octokit/Models/Response/TeamMembershipDetails.cs +++ b/Octokit/Models/Response/TeamMembershipDetails.cs @@ -7,6 +7,14 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class TeamMembershipDetails { + public TeamMembershipDetails() { } + + public TeamMembershipDetails(TeamRole role, MembershipState state) + { + Role = role; + State = state; + } + public StringEnum Role { get; protected set; } public StringEnum State { get; protected set; } diff --git a/Octokit/Models/Response/User.cs b/Octokit/Models/Response/User.cs index 423fb27f66..3fcf93ec61 100644 --- a/Octokit/Models/Response/User.cs +++ b/Octokit/Models/Response/User.cs @@ -8,6 +8,7 @@ namespace Octokit /// /// Represents a user on GitHub. /// + [ExcludeFromCtorWithAllPropertiesConventionTest(nameof(Type))] [DebuggerDisplay("{DebuggerDisplay,nq}")] public class User : Account { diff --git a/Octokit/Models/Response/Verification.cs b/Octokit/Models/Response/Verification.cs index 6ac90f451a..e2b9fef363 100644 --- a/Octokit/Models/Response/Verification.cs +++ b/Octokit/Models/Response/Verification.cs @@ -10,6 +10,16 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class Verification { + public Verification() { } + + public Verification(bool verified, VerificationReason reason, string signature, string payload) + { + Verified = verified; + Reason = reason; + Signature = signature; + Payload = payload; + } + /// /// Does GitHub consider the signature in this commit to be verified? ///