Skip to content

Commit 4c1f05f

Browse files
committed
Feat: Some auto cleanup
1 parent 35f9dc4 commit 4c1f05f

16 files changed

+90
-88
lines changed

.editorconfig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ dotnet_naming_symbols.private_instance_fields_symbols.resharper_applicable_kinds
7171
dotnet_naming_symbols.private_instance_fields_symbols.resharper_required_modifiers = instance
7272
dotnet_naming_symbols.private_instance_fields_symbols_1.applicable_accessibilities = private
7373
dotnet_naming_symbols.private_instance_fields_symbols_1.applicable_kinds = field
74-
dotnet_naming_symbols.private_instance_fields_symbols_1.resharper_applicable_kinds = field,readonly_field
74+
dotnet_naming_symbols.private_instance_fields_symbols_1.resharper_applicable_kinds = field, readonly_field
7575
dotnet_naming_symbols.private_instance_fields_symbols_1.resharper_required_modifiers = instance
7676
dotnet_naming_symbols.private_static_fields_symbols.applicable_accessibilities = private
7777
dotnet_naming_symbols.private_static_fields_symbols.applicable_kinds = field
@@ -84,11 +84,11 @@ dotnet_naming_symbols.private_static_readonly_symbols.required_modifiers = reado
8484
dotnet_naming_symbols.private_static_readonly_symbols.resharper_applicable_kinds = readonly_field
8585
dotnet_naming_symbols.private_static_readonly_symbols.resharper_required_modifiers = static
8686
dotnet_naming_symbols.unity_serialized_field_symbols.applicable_accessibilities = *
87-
dotnet_naming_symbols.unity_serialized_field_symbols.applicable_kinds =
87+
dotnet_naming_symbols.unity_serialized_field_symbols.applicable_kinds =
8888
dotnet_naming_symbols.unity_serialized_field_symbols.resharper_applicable_kinds = unity_serialised_field
8989
dotnet_naming_symbols.unity_serialized_field_symbols.resharper_required_modifiers = instance
9090
dotnet_naming_symbols.unity_serialized_field_symbols_1.applicable_accessibilities = *
91-
dotnet_naming_symbols.unity_serialized_field_symbols_1.applicable_kinds =
91+
dotnet_naming_symbols.unity_serialized_field_symbols_1.applicable_kinds =
9292
dotnet_naming_symbols.unity_serialized_field_symbols_1.resharper_applicable_kinds = unity_serialised_field
9393
dotnet_naming_symbols.unity_serialized_field_symbols_1.resharper_required_modifiers = instance
9494
dotnet_sort_system_directives_first = false
@@ -143,7 +143,7 @@ resharper_formatter_tags_enabled = true
143143
resharper_indent_preprocessor_if = usual_indent
144144
resharper_indent_preprocessor_other = do_not_change
145145
resharper_indent_raw_literal_string = indent
146-
resharper_instance_members_qualify_declared_in =
146+
resharper_instance_members_qualify_declared_in =
147147
resharper_keep_existing_attribute_arrangement = true
148148
resharper_keep_existing_declaration_block_arrangement = true
149149
resharper_keep_existing_embedded_block_arrangement = true

CodeOfChaos.Twitch.sln

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{AF1A203C
1212
EndProject
1313
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tools.CodeOfChaos.Twitch", "src\Tools.CodeOfChaos.Twitch\Tools.CodeOfChaos.Twitch.csproj", "{ADEADD97-0AFA-4D9E-970B-9FFB932949B3}"
1414
EndProject
15+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".generated-files", ".generated-files", "{7240E885-FD94-4503-973B-C730D3D6256F}"
16+
ProjectSection(SolutionItems) = preProject
17+
generated-files\twitch-api.xml = generated-files\twitch-api.xml
18+
EndProjectSection
19+
EndProject
1520
Global
1621
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1722
Debug|Any CPU = Debug|Any CPU

src/CodeOfChaos.Twitch/CodeOfChaos.Twitch.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="AterraEngine.Unions" Version="3.8.0" />
12-
<PackageReference Include="AterraEngine.Unions.Generators" Version="3.8.0">
13-
<PrivateAssets>all</PrivateAssets>
14-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
15-
</PackageReference>
16-
<PackageReference Include="RestSharp" Version="112.1.0" />
11+
<PackageReference Include="AterraEngine.Unions" Version="3.8.0"/>
12+
<PackageReference Include="AterraEngine.Unions.Generators" Version="3.8.0">
13+
<PrivateAssets>all</PrivateAssets>
14+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
15+
</PackageReference>
16+
<PackageReference Include="RestSharp" Version="112.1.0"/>
1717
</ItemGroup>
1818

1919
</Project>

src/CodeOfChaos.Twitch/TwitchApiClient.cs

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,29 @@
66
using System.Net;
77

88
namespace CodeOfChaos.Twitch;
9-
109
// ---------------------------------------------------------------------------------------------------------------------
1110
// Code
1211
// ---------------------------------------------------------------------------------------------------------------------
13-
public class TwitchApiClient(string clientId, string clientSecret ) {
12+
public class TwitchApiClient(string clientId, string clientSecret) {
1413
private readonly RestClient _client = new(new RestClientOptions("https://api.twitch.tv/helix/"));
1514

1615
public async ValueTask<StartCommercialResult> StartCommercialAsync(string broadcasterId, int length, CancellationToken ct = default) {
17-
var request = new RestRequest("channels/commercial", Method.Get)
16+
RestRequest request = new RestRequest("channels/commercial")
1817
.AddHeader("Client-ID", clientId)
1918
.AddHeader("Authorization", $"Bearer {clientSecret}");
20-
21-
request.AddJsonBody(new Dictionary<string,string> {
19+
20+
request.AddJsonBody(new Dictionary<string, string> {
2221
["broadcaster_id"] = broadcasterId,
23-
["length"]= length.ToString()
22+
["length"] = length.ToString()
2423
});
25-
24+
2625
RestResponse<StartCommercialResponse> response = await _client.ExecuteAsync<StartCommercialResponse>(request, ct);
2726
return response switch {
2827
{ IsSuccessful: true, Data: not null } => new Ok<StartCommercialResponse>(response.Data),
2928
{ StatusCode : HttpStatusCode.Unauthorized } => new Unauthorized(),
3029
{ StatusCode : HttpStatusCode.NotFound } => new NotFound(),
3130
{ StatusCode : HttpStatusCode.TooManyRequests } => new TooManyRequests(),
32-
31+
3332
// Undocumented response
3433
_ => throw new NotImplementedException(response.Content)
3534
};
@@ -40,15 +39,20 @@ public record StartCommercialResponse(int Length, string Message, int RetryAfter
4039

4140
public record struct Ok<T>(T Value) : IValue<T>;
4241

43-
public record struct BadRequest();
44-
public record struct Unauthorized();
45-
public record struct Forbidden();
46-
public record struct NotFound();
47-
public record struct InternalServerError();
48-
public record struct ServiceUnavailable();
49-
public record struct GatewayTimeout();
50-
public record struct TooManyRequests();
51-
52-
public readonly partial record struct StartCommercialResult() : IUnion<Ok<StartCommercialResponse>, BadRequest, Unauthorized, NotFound, TooManyRequests> {
53-
54-
}
42+
public record struct BadRequest;
43+
44+
public record struct Unauthorized;
45+
46+
public record struct Forbidden;
47+
48+
public record struct NotFound;
49+
50+
public record struct InternalServerError;
51+
52+
public record struct ServiceUnavailable;
53+
54+
public record struct GatewayTimeout;
55+
56+
public record struct TooManyRequests;
57+
58+
public readonly partial record struct StartCommercialResult() : IUnion<Ok<StartCommercialResponse>, BadRequest, Unauthorized, NotFound, TooManyRequests> {}

src/Tools.CodeOfChaos.Twitch/Commands/TwitchApiReferenceScraper/Dto/RequestBodyParameter.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ namespace Tools.CodeOfChaos.Twitch.Commands.TwitchApiReferenceScraper.Dto;
77
// ---------------------------------------------------------------------------------------------------------------------
88
// Code
99
// ---------------------------------------------------------------------------------------------------------------------
10-
public class RequestBodyParameter() {
11-
[XmlAttribute] public string Name { get; init; }
12-
[XmlAttribute] public string Type { get; init; }
13-
[XmlText] public string Description { get; init; }
10+
public class RequestBodyParameter {
11+
[XmlAttribute] public string Name { get; init; } = string.Empty;
12+
[XmlAttribute] public string Type { get; init; } = string.Empty;
13+
[XmlText] public string Description { get; init; } = string.Empty;
1414
}

src/Tools.CodeOfChaos.Twitch/Commands/TwitchApiReferenceScraper/Dto/RequestQueryParameter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ namespace Tools.CodeOfChaos.Twitch.Commands.TwitchApiReferenceScraper.Dto;
88
// Code
99
// ---------------------------------------------------------------------------------------------------------------------
1010
public class RequestQueryParameter {
11-
[XmlAttribute] public string Name { get; init; }
12-
[XmlAttribute] public string Type { get; init; }
11+
[XmlAttribute] public string Name { get; init; } = string.Empty;
12+
[XmlAttribute] public string Type { get; init; } = string.Empty;
1313
[XmlAttribute] public bool Required { get; init; }
14-
[XmlText] public string Description { get; init; }
14+
[XmlText] public string Description { get; init; } = string.Empty;
1515
}

src/Tools.CodeOfChaos.Twitch/Commands/TwitchApiReferenceScraper/Dto/ResponseBodyParameter.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
using System.Xml.Serialization;
55

66
namespace Tools.CodeOfChaos.Twitch.Commands.TwitchApiReferenceScraper.Dto;
7-
87
// ---------------------------------------------------------------------------------------------------------------------
98
// Code
109
// ---------------------------------------------------------------------------------------------------------------------
11-
public class ResponseBodyParameter() {
12-
[XmlAttribute]public string Name { get; init; }
13-
[XmlAttribute]public string Type { get; init; }
14-
[XmlText]public string Description { get; init; }
10+
public class ResponseBodyParameter {
11+
[XmlAttribute] public string Name { get; init; } = string.Empty;
12+
[XmlAttribute] public string Type { get; init; } = string.Empty;
13+
[XmlText] public string Description { get; init; } = string.Empty;
1514
}
Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
// ---------------------------------------------------------------------------------------------------------------------
22
// Imports
33
// ---------------------------------------------------------------------------------------------------------------------
4-
using System.Xml.Serialization;
5-
64
namespace Tools.CodeOfChaos.Twitch.Commands.TwitchApiReferenceScraper.Dto;
7-
85
// ---------------------------------------------------------------------------------------------------------------------
96
// Code
107
// ---------------------------------------------------------------------------------------------------------------------
11-
public class TwitchApiDocumentation() {
12-
public string Name { get; init; }
13-
public string RestCommand { get; init; }
14-
public string Url { get; init; }
15-
public string[] AuthScopes { get; init; }
8+
public class TwitchApiDocumentation {
9+
public string Name { get; init; } = string.Empty;
10+
public string RestCommand { get; init; } = string.Empty;
11+
public string Url { get; init; } = string.Empty;
12+
public string[] AuthScopes { get; init; } = [];
1613
public bool RequiresOAuth { get; init; }
17-
public RequestQueryParameter[] QueryParameters { get; init; }
18-
public RequestBodyParameter[] BodyParameters { get; init; }
19-
public ResponseBodyParameter[] ResponseParameters { get; init; }
20-
public string Description { get; init; }
14+
public RequestQueryParameter[] QueryParameters { get; init; } = [];
15+
public RequestBodyParameter[] BodyParameters { get; init; } = [];
16+
public ResponseBodyParameter[] ResponseParameters { get; init; } = [];
17+
public string Description { get; init; } = string.Empty;
2118
}

src/Tools.CodeOfChaos.Twitch/Commands/TwitchApiReferenceScraper/Dto/TwitchApiQuickLookup.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Imports
33
// ---------------------------------------------------------------------------------------------------------------------
44
namespace Tools.CodeOfChaos.Twitch.Commands.TwitchApiReferenceScraper.Dto;
5-
65
// ---------------------------------------------------------------------------------------------------------------------
76
// Code
87
// ---------------------------------------------------------------------------------------------------------------------

src/Tools.CodeOfChaos.Twitch/Commands/TwitchApiReferenceScraper/Dto/TwitchApiReference.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
using System.Xml.Serialization;
55

66
namespace Tools.CodeOfChaos.Twitch.Commands.TwitchApiReferenceScraper.Dto;
7-
87
// ---------------------------------------------------------------------------------------------------------------------
98
// Code
109
// ---------------------------------------------------------------------------------------------------------------------
1110
[XmlRoot]
12-
public class TwitchApiReference() {
11+
public class TwitchApiReference {
1312
[XmlArray] public TwitchApiDocumentation[] Documentation { get; set; } = [];
1413
[XmlElement] public string Timestamp { get; set; } = DateTime.UtcNow.ToString("o");
1514
}

0 commit comments

Comments
 (0)