Skip to content

Commit

Permalink
Merge branch 'develop' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
upsilon committed Jul 24, 2022
2 parents 73ae7c1 + 6f2696d commit 9c23a89
Show file tree
Hide file tree
Showing 243 changed files with 14,266 additions and 10,810 deletions.
98 changes: 98 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
[*.cs]
indent_style = space
tab_width = 4

# StyleCop.Analyzer

# SA0001: XML comment analysis is disabled due to project configuration
dotnet_diagnostic.SA0001.severity = none

# SA1009: Closing parenthesis should not be preceded by a space
dotnet_diagnostic.SA1009.severity = none

# SA1100: Do not prefix calls with base unless local implementation exists
dotnet_diagnostic.SA1100.severity = none

# SA1108: Block statements should not contain embedded comments
dotnet_diagnostic.SA1108.severity = none

# SA1111: Closing parenthesis should be on line of last parameter
dotnet_diagnostic.SA1111.severity = none

# SA1114: Parameter list should follow declaration
dotnet_diagnostic.SA1114.severity = none

# SA1115: The parameter should begin on the line after the previous parameter
dotnet_diagnostic.SA1115.severity = none

# SA1116: The parameters should begin on the line after the declaration, whenever the parameter span across multiple lines
dotnet_diagnostic.SA1116.severity = none

# SA1122:Use string.Empty for empty strings
dotnet_diagnostic.SA1122.severity = none

# SA1124: Do not use regions
dotnet_diagnostic.SA1124.severity = none

# SA1129: Do not use default value type constructor
dotnet_diagnostic.SA1129.severity = none

# SA1201: Elements must appear in the correct order
dotnet_diagnostic.SA1201.severity = none

# SA1202: Elements must be ordered by access
dotnet_diagnostic.SA1202.severity = none

# SA1203: Constants must appear before fields
dotnet_diagnostic.SA1203.severity = none

# SA1204: Static members should appear before non-static members
dotnet_diagnostic.SA1204.severity = none

# SA1214: Readonly fields should appear before non-readonly fields
dotnet_diagnostic.SA1214.severity = none

# SA1401: Field should be private
dotnet_diagnostic.SA1401.severity = none

# SA1402: File may only contain a single type
dotnet_diagnostic.SA1402.severity = none

# SA1404: Code analysis suppression should have justification
dotnet_diagnostic.SA1404.severity = none

# SA1407: Arithmetic expressions should declare precedence
dotnet_diagnostic.SA1407.severity = none

# SA1408: Conditional expressions should declare precedence
dotnet_diagnostic.SA1408.severity = none

# SA1503: Braces should not be omitted
dotnet_diagnostic.SA1503.severity = none

# SA1512: Single-line comments should not be followed by blank line
dotnet_diagnostic.SA1512.severity = none

# SA1513: Closing brace should be followed by blank line
dotnet_diagnostic.SA1513.severity = none

# SA1515: Single-line comment should be preceded by blank line
dotnet_diagnostic.SA1515.severity = none

# SA1623: PropertySummaryDocumentation must match accessors
dotnet_diagnostic.SA1623.severity = none

# SA1627: The documentation text within the 'exception' tag should not be empty
dotnet_diagnostic.SA1627.severity = none

# SA1629: Documentation text should end with a period
dotnet_diagnostic.SA1629.severity = none

# SA1633: The file header XML is invalid
dotnet_diagnostic.SA1633.severity = none

# conflict with StyleCop rules
dotnet_style_qualification_for_field = true
dotnet_style_qualification_for_property = true
dotnet_style_qualification_for_method = true
dotnet_style_qualification_for_event = true
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/*/bin
/*/obj
/.vs
/__Instrumented
/coverage.xml
Thumbs.db
TestResult.xml
*.VisualState.xml
2 changes: 1 addition & 1 deletion OpenTween.Tests/AnyOrderComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace OpenTween
internal class AnyOrderComparer<T> : IEqualityComparer<IEnumerable<T>>
where T : IEquatable<T>
{
public static readonly AnyOrderComparer<T> Instance = new AnyOrderComparer<T>();
public static readonly AnyOrderComparer<T> Instance = new();

public bool Equals(IEnumerable<T> x, IEnumerable<T> y)
{
Expand Down
4 changes: 2 additions & 2 deletions OpenTween.Tests/Api/ApiLimitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace OpenTween.Api
{
public class ApiLimitTest
{
public static readonly TheoryData<object?, bool> Equals_TestCase = new TheoryData<object?, bool>
public static readonly TheoryData<object?, bool> EqualsTestCase = new()
{
{ new ApiLimit(150, 100, new DateTimeUtc(2013, 1, 1, 0, 0, 0)), true },
{ new ApiLimit(350, 100, new DateTimeUtc(2013, 1, 1, 0, 0, 0)), false },
Expand All @@ -41,7 +41,7 @@ public class ApiLimitTest
};

[Theory]
[MemberData(nameof(Equals_TestCase))]
[MemberData(nameof(EqualsTestCase))]
public void EqualsTest(object? obj2, bool expected)
{
var obj1 = new ApiLimit(150, 100, new DateTimeUtc(2013, 1, 1, 0, 0, 0));
Expand Down
2 changes: 1 addition & 1 deletion OpenTween.Tests/Api/MobypictureApiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

namespace OpenTween.Api
{
public class MobypictureApiText
public class MobypictureApiTest
{
[Fact]
public async Task UploadFileAsync_Test()
Expand Down
41 changes: 24 additions & 17 deletions OpenTween.Tests/Api/TwitterApiStatusTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,34 +49,38 @@ public void ResetTest()
Assert.Equal(TwitterApiAccessLevel.Anonymous, apiStatus.AccessLevel);
}

public static readonly TheoryData<Dictionary<string, string>, ApiLimit?> ParseRateLimit_TestCase = new TheoryData<Dictionary<string, string>, ApiLimit?>
public static readonly TheoryData<Dictionary<string, string>, ApiLimit?> ParseRateLimitTestCase = new()
{
{
new Dictionary<string, string> {
new Dictionary<string, string>
{
["X-RateLimit-Limit"] = "150",
["X-RateLimit-Remaining"] = "100",
["X-RateLimit-Reset"] = "1356998400",
},
new ApiLimit(150, 100, new DateTimeUtc(2013, 1, 1, 0, 0, 0))
},
{
new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) {
new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{
["x-ratelimit-limit"] = "150",
["x-ratelimit-remaining"] = "100",
["x-ratelimit-reset"] = "1356998400",
},
new ApiLimit(150, 100, new DateTimeUtc(2013, 1, 1, 0, 0, 0))
},
{
new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) {
new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{
["X-RateLimit-Limit"] = "150",
["X-RateLimit-Remaining"] = "100",
["X-RateLimit-Reset"] = "hogehoge",
},
null
},
{
new Dictionary<string, string> {
new Dictionary<string, string>
{
["X-RateLimit-Limit"] = "150",
["X-RateLimit-Remaining"] = "100",
},
Expand All @@ -85,33 +89,36 @@ public void ResetTest()
};

[Theory]
[MemberData(nameof(ParseRateLimit_TestCase))]
[MemberData(nameof(ParseRateLimitTestCase))]
public void ParseRateLimitTest(IDictionary<string, string> header, ApiLimit? expected)
{
var limit = TwitterApiStatus.ParseRateLimit(header, "X-RateLimit-");
Assert.Equal(expected, limit);
}

public static readonly TheoryData<Dictionary<string, string>, ApiLimit?> ParseMediaRateLimit_TestCase = new TheoryData<Dictionary<string, string>, ApiLimit?>
public static readonly TheoryData<Dictionary<string, string>, ApiLimit?> ParseMediaRateLimitTestCase = new()
{
{
new Dictionary<string, string> {
new Dictionary<string, string>
{
["X-MediaRateLimit-Limit"] = "30",
["X-MediaRateLimit-Remaining"] = "20",
["X-MediaRateLimit-Reset"] = "1234567890",
},
new ApiLimit(30, 20, new DateTimeUtc(2009, 2, 13, 23, 31, 30))
},
{
new Dictionary<string, string> {
new Dictionary<string, string>
{
["X-MediaRateLimit-Limit"] = "30",
["X-MediaRateLimit-Remaining"] = "20",
["X-MediaRateLimit-Reset"] = "hogehoge",
},
null
},
{
new Dictionary<string, string> {
new Dictionary<string, string>
{
["X-MediaRateLimit-Limit"] = "30",
["X-MediaRateLimit-Remaining"] = "20",
},
Expand All @@ -120,29 +127,29 @@ public void ParseRateLimitTest(IDictionary<string, string> header, ApiLimit? exp
};

[Theory]
[MemberData(nameof(ParseMediaRateLimit_TestCase))]
[MemberData(nameof(ParseMediaRateLimitTestCase))]
public void ParseMediaRateLimitTest(IDictionary<string, string> header, ApiLimit? expected)
{
var limit = TwitterApiStatus.ParseRateLimit(header, "X-MediaRateLimit-");
Assert.Equal(expected, limit);
}

public static readonly TheoryData<Dictionary<string, string>, TwitterApiAccessLevel?> ParseAccessLevel_TestCase = new TheoryData<Dictionary<string, string>, TwitterApiAccessLevel?>
public static readonly TheoryData<Dictionary<string, string>, TwitterApiAccessLevel?> ParseAccessLevelTestCase = new()
{
{
new Dictionary<string, string> { {"X-Access-Level", "read"} },
new Dictionary<string, string> { { "X-Access-Level", "read" } },
TwitterApiAccessLevel.Read
},
{
new Dictionary<string, string> { {"X-Access-Level", "read-write"} },
new Dictionary<string, string> { { "X-Access-Level", "read-write" } },
TwitterApiAccessLevel.ReadWrite
},
{
new Dictionary<string, string> { {"X-Access-Level", "read-write-directmessages"} },
new Dictionary<string, string> { { "X-Access-Level", "read-write-directmessages" } },
TwitterApiAccessLevel.ReadWriteAndDirectMessage
},
{
new Dictionary<string, string> { {"X-Access-Level", ""} }, // 何故かたまに出てくるやつ
new Dictionary<string, string> { { "X-Access-Level", "" } }, // 何故かたまに出てくるやつ
null
},
{
Expand All @@ -152,7 +159,7 @@ public void ParseMediaRateLimitTest(IDictionary<string, string> header, ApiLimit
};

[Theory]
[MemberData(nameof(ParseAccessLevel_TestCase))]
[MemberData(nameof(ParseAccessLevelTestCase))]
public void ParseAccessLevelTest(IDictionary<string, string> header, TwitterApiAccessLevel? expected)
{
var accessLevel = TwitterApiStatus.ParseAccessLevel(header, "X-Access-Level");
Expand Down
Loading

0 comments on commit 9c23a89

Please sign in to comment.