mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-05 23:06:10 +00:00
* Added StringEnum<TEnum> * Added tests * Make sure the serializer can work with StringEnum * Use StringEnum for EventInfo.Event * Add convention test to assert that all Response models use StringEnum<> to wrap enum properties * Add Stringnum<> to all response types failing convention test * Handle StringEnum to Enum conversion when Issue response model populates IssueUpdate request model * Fix unit test * Refactor SimpleJsonSerializer to expose the DeserializeEnum strategy so it can be used in StringEnum class * Need to expose/use SerializeEnum functionality too, so we use the correct string representation of enum values that have custom properties (eg ReactionType Plus1 to "+1") * fix unit tests, since the string is now the "correct" upstream api value * Add a couple of tests for the Enum serialize/deserialize when underscores, hyphens and custom property attributes are present * Compare parsed values for equality * add convention test to ensure enum members all have Parameter property set * update test to cover implicit conversions too * this test should work but fails at the moment due to magic hyphen removal in deserializer causing a one way trip from utf-8 to EncodingType.Utf8 with no way to get back * (unsuccesfully) expand event info test to try to catch more cases of unknown event types * fix broken integration test while im here * Fixed build errors after .NET Core merge * Value -> StringValue, ParsedValue -> Value * Don't allow StringValue to be null * Ignore enums not used in request/response models * Added ParameterAttribute to almost all enum values * Ignore Language enum * Fix failing tests * Fix milestone sort parameter and tests * whitespace * fix milestone unit tests * Fix StringEnum.Equals ... This could've been embarrassing! * Change SimpleJsonSerializer Enum handling to only use `[Parameter()]` attributes (no more magic removal of hyphen/underscores from strings) * Tidy up this integration test while im here * Only test request/response enums in convention test * Keep skipping Language * Remove unused method * Remove excluded enum types * Removed unnecessary ParameterAttributes * Remove unused enum * Add StringEnum test for string-comparison of two invalid values * Bring back IssueCommentSort and use it in IssueCommentRequest This reverts commit 38a4a291d1476ef8c992fe0f76956974b6f32a49. * Use assembly instead of namespace for Octokit check * Add failing test to reproduce the issue where only the first enum paramter/value was added to the cache * Fix deserializer enum cache to include all enum members rather than only the first member encountered * Use a static SimpleJsonSerializer in StringEnum * Remove serializer instance in StringEnum * Add some documentation on StringEnum<TEnum> * Fix parameter value to resolve failing integration test
216 lines
6.4 KiB
C#
216 lines
6.4 KiB
C#
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Globalization;
|
|
using Octokit.Internal;
|
|
|
|
namespace Octokit
|
|
{
|
|
/// <summary>
|
|
/// Used to request and filter a list of repositories.
|
|
/// </summary>
|
|
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
|
public class RepositoryRequest : RequestParameters
|
|
{
|
|
/// <summary>
|
|
/// Gets or sets the repository type.
|
|
/// </summary>
|
|
/// <value>
|
|
/// The type.
|
|
/// </value>
|
|
[SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods")]
|
|
public RepositoryType? Type { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the sort property.
|
|
/// </summary>
|
|
/// <value>
|
|
/// The sort.
|
|
/// </value>
|
|
public RepositorySort? Sort { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the sort direction.
|
|
/// </summary>
|
|
/// <value>
|
|
/// The direction.
|
|
/// </value>
|
|
public SortDirection? Direction { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the visibility property.
|
|
/// </summary>
|
|
/// <value>
|
|
/// The visibility.
|
|
/// </value>
|
|
public RepositoryVisibility? Visibility { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the affiliation property.
|
|
/// </summary>
|
|
/// <value>
|
|
/// The affiliation.
|
|
/// </value>
|
|
public RepositoryAffiliation? Affiliation { get; set; }
|
|
|
|
internal string DebuggerDisplay
|
|
{
|
|
get
|
|
{
|
|
var propValues = new List<string>();
|
|
if (Type.HasValue)
|
|
propValues.Add(string.Format(CultureInfo.InvariantCulture, "Type: {0}", Type));
|
|
if (Sort.HasValue)
|
|
propValues.Add(string.Format(CultureInfo.InvariantCulture, "Sort: {0}", Sort));
|
|
if (Direction.HasValue)
|
|
propValues.Add(string.Format(CultureInfo.InvariantCulture, "Direction: {0}", Direction));
|
|
if (Visibility.HasValue)
|
|
propValues.Add(string.Format(CultureInfo.InvariantCulture, "Visibility: {0}", Visibility));
|
|
if (Affiliation.HasValue)
|
|
propValues.Add(string.Format(CultureInfo.InvariantCulture, "Affiliation: {0}", Affiliation));
|
|
|
|
return string.Join(", ", propValues);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// The properties that repositories can be filtered by.
|
|
/// </summary>
|
|
public enum RepositoryType
|
|
{
|
|
/// <summary>
|
|
/// Return all repositories.
|
|
/// </summary>
|
|
[Parameter(Value = "all")]
|
|
All,
|
|
|
|
/// <summary>
|
|
/// Return repositories that the current authenticated user owns.
|
|
/// </summary>
|
|
[Parameter(Value = "owner")]
|
|
Owner,
|
|
|
|
/// <summary>
|
|
/// Returns public repositories.
|
|
/// </summary>
|
|
[Parameter(Value = "public")]
|
|
Public,
|
|
|
|
/// <summary>
|
|
/// The privateReturn private repositories.
|
|
/// </summary>
|
|
[Parameter(Value = "private")]
|
|
Private,
|
|
|
|
/// <summary>
|
|
/// Return repositories for which the current authenticated user is a member of the org or team.
|
|
/// </summary>
|
|
[Parameter(Value = "member")]
|
|
Member
|
|
}
|
|
|
|
/// <summary>
|
|
/// The properties that repositories can be sorted by.
|
|
/// </summary>
|
|
public enum RepositorySort
|
|
{
|
|
/// <summary>
|
|
/// Sort by the date the repository was created.
|
|
/// </summary>
|
|
[Parameter(Value = "created")]
|
|
Created,
|
|
|
|
/// <summary>
|
|
/// Sort by the date the repository was last updated.
|
|
/// </summary>
|
|
[Parameter(Value = "updated")]
|
|
Updated,
|
|
|
|
/// <summary>
|
|
/// Sort by the date the repository was last pushed.
|
|
/// </summary>
|
|
[Parameter(Value = "pushed")]
|
|
Pushed,
|
|
|
|
/// <summary>
|
|
/// Sort by the repository name.
|
|
/// </summary>
|
|
[Parameter(Value = "full_name")]
|
|
FullName
|
|
}
|
|
|
|
/// <summary>
|
|
/// The properties that repositories can be visible by.
|
|
/// </summary>
|
|
public enum RepositoryVisibility
|
|
{
|
|
/// <summary>
|
|
/// Returns only public repositories
|
|
/// </summary>
|
|
[Parameter(Value = "public")]
|
|
Public,
|
|
|
|
/// <summary>
|
|
/// Returns only private repositories
|
|
/// </summary>
|
|
[Parameter(Value = "private")]
|
|
Private,
|
|
|
|
/// <summary>
|
|
/// Return both public and private repositories
|
|
/// </summary>
|
|
[Parameter(Value = "all")]
|
|
All
|
|
}
|
|
|
|
/// <summary>
|
|
/// The properties that repositories can be affiliated by.
|
|
/// </summary>
|
|
public enum RepositoryAffiliation
|
|
{
|
|
/// <summary>
|
|
/// Repositories that are owned by the authenticated user
|
|
/// </summary>
|
|
[Parameter(Value = "owner")]
|
|
Owner,
|
|
|
|
/// <summary>
|
|
/// Repositories that the user has been added to as a collaborator.
|
|
/// </summary>
|
|
[Parameter(Value = "collaborator")]
|
|
Collaborator,
|
|
|
|
/// <summary>
|
|
/// Repositories that the user has access to through being a member of an organization.
|
|
/// This includes every repository on every team that the user is on.
|
|
/// </summary>
|
|
[Parameter(Value = "organization_member")]
|
|
OrganizationMember,
|
|
|
|
/// <summary>
|
|
/// Return repositories that are owned by authenticated user and added to as a collaborator.
|
|
/// </summary>
|
|
[Parameter(Value = "owner, collaborator")]
|
|
OwnerAndCollaborator,
|
|
|
|
/// <summary>
|
|
/// Return repositories that are owned by authenticated user or user is a organization member.
|
|
/// </summary>
|
|
[Parameter(Value = "owner, organization_member")]
|
|
OwnerAndOrganizationMember,
|
|
|
|
/// <summary>
|
|
/// Return repositories that user has been added as collaborator or user is a organization member.
|
|
/// </summary>
|
|
[Parameter(Value = "collaborator, organization_member")]
|
|
CollaboratorAndOrganizationMember,
|
|
|
|
/// <summary>
|
|
/// Returns all repositories where user is owner,collaborator or organization member.
|
|
/// </summary>
|
|
[Parameter(Value = "owner, collaborator, organization_member")]
|
|
All
|
|
}
|
|
}
|