mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-06 07:16:09 +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
212 lines
5.6 KiB
C#
212 lines
5.6 KiB
C#
using System;
|
|
using System.Collections.ObjectModel;
|
|
using System.Diagnostics;
|
|
using System.Globalization;
|
|
using Octokit.Internal;
|
|
|
|
namespace Octokit
|
|
{
|
|
/// <summary>
|
|
/// Used to filter a request to list issues.
|
|
/// </summary>
|
|
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
|
public class IssueRequest : RequestParameters
|
|
{
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="IssueRequest"/> class.
|
|
/// </summary>
|
|
public IssueRequest()
|
|
{
|
|
Filter = IssueFilter.Assigned;
|
|
State = ItemStateFilter.Open;
|
|
Labels = new Collection<string>();
|
|
SortProperty = IssueSort.Created;
|
|
SortDirection = SortDirection.Descending;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the <see cref="IssueFilter" /> which indicates which sorts of issues to return.
|
|
/// </summary>
|
|
/// <value>
|
|
/// The filter.
|
|
/// </value>
|
|
public IssueFilter Filter { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the <see cref="ItemStateFilter"/> for the issues to return.
|
|
/// </summary>
|
|
/// <value>
|
|
/// The state.
|
|
/// </value>
|
|
public ItemStateFilter State { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets the labels to filter by. Add labels to the collection to only request issues with those labels.
|
|
/// </summary>
|
|
/// <remarks>Sent as a comma separated list</remarks>
|
|
/// <value>
|
|
/// The labels.
|
|
/// </value>
|
|
public Collection<string> Labels { get; private set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the <see cref="IssueSort"/> property to sort the returned issues by.
|
|
/// Combine this with <see cref="SortDirection"/> to specify sort direction.
|
|
/// </summary>
|
|
/// <value>
|
|
/// The sort property.
|
|
/// </value>
|
|
[Parameter(Key = "sort")]
|
|
public IssueSort SortProperty { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the sort direction.
|
|
/// </summary>
|
|
/// <value>
|
|
/// The sort direction.
|
|
/// </value>
|
|
[Parameter(Key = "direction")]
|
|
public SortDirection SortDirection { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the date for which only issues updated at or after this time are returned.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// This is sent as a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
|
|
/// </remarks>
|
|
/// <value>
|
|
/// The since.
|
|
/// </value>
|
|
public DateTimeOffset? Since { get; set; }
|
|
|
|
internal string DebuggerDisplay
|
|
{
|
|
get
|
|
{
|
|
return string.Format(CultureInfo.InvariantCulture, "Filter: {0} State: {1}", Filter, State);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// The range of filters available for issues.
|
|
/// </summary>
|
|
/// <remarks>http://developer.github.com/v3/issues/#list-issues</remarks>
|
|
public enum IssueFilter
|
|
{
|
|
/// <summary>
|
|
/// Issues assigned to the authenticated user. (Default)
|
|
/// </summary>
|
|
[Parameter(Value = "assigned")]
|
|
Assigned,
|
|
|
|
/// <summary>
|
|
/// Issues created by the authenticated user.
|
|
/// </summary>
|
|
[Parameter(Value = "created")]
|
|
Created,
|
|
|
|
/// <summary>
|
|
/// Issues mentioning the authenticated user.
|
|
/// </summary>
|
|
[Parameter(Value = "mentioned")]
|
|
Mentioned,
|
|
|
|
/// <summary>
|
|
/// Issues the authenticated user is subscribed to for updates.
|
|
/// </summary>
|
|
[Parameter(Value = "subscribed")]
|
|
Subscribed,
|
|
|
|
/// <summary>
|
|
/// All issues the authenticated user can see, regardless of participation or creation.
|
|
/// </summary>
|
|
[Parameter(Value = "all")]
|
|
All
|
|
}
|
|
|
|
/// <summary>
|
|
/// Range of states for Issues, Milestones and PullRequest API.
|
|
/// </summary>
|
|
public enum ItemStateFilter
|
|
{
|
|
/// <summary>
|
|
/// Items that are open.
|
|
/// </summary>
|
|
[Parameter(Value = "open")]
|
|
Open,
|
|
|
|
/// <summary>
|
|
/// Items that are closed.
|
|
/// </summary>
|
|
[Parameter(Value = "closed")]
|
|
Closed,
|
|
|
|
/// <summary>
|
|
/// All the items.
|
|
/// </summary>
|
|
[Parameter(Value = "all")]
|
|
All
|
|
}
|
|
|
|
/// <summary>
|
|
/// Items that are open OR closed
|
|
/// </summary>
|
|
public enum ItemState
|
|
{
|
|
/// <summary>
|
|
/// Items that are open
|
|
/// </summary>
|
|
[Parameter(Value = "open")]
|
|
Open,
|
|
|
|
/// <summary>
|
|
/// Items that are closed
|
|
/// </summary>
|
|
[Parameter(Value = "closed")]
|
|
Closed
|
|
}
|
|
|
|
/// <summary>
|
|
/// The available properties to sort issues by.
|
|
/// </summary>
|
|
public enum IssueSort
|
|
{
|
|
/// <summary>
|
|
/// Sort by create date (default)
|
|
/// </summary>
|
|
[Parameter(Value = "created")]
|
|
Created,
|
|
|
|
/// <summary>
|
|
/// Sort by the date of the last update
|
|
/// </summary>
|
|
[Parameter(Value = "updated")]
|
|
Updated,
|
|
|
|
/// <summary>
|
|
/// Sort by the number of comments
|
|
/// </summary>
|
|
[Parameter(Value = "comments")]
|
|
Comments
|
|
}
|
|
|
|
/// <summary>
|
|
/// The two possible sort directions.
|
|
/// </summary>
|
|
public enum SortDirection
|
|
{
|
|
/// <summary>
|
|
/// Sort ascending
|
|
/// </summary>
|
|
[Parameter(Value = "asc")]
|
|
Ascending,
|
|
|
|
/// <summary>
|
|
/// Sort descending
|
|
/// </summary>
|
|
[Parameter(Value = "desc")]
|
|
Descending
|
|
}
|
|
}
|