Skip to content

Commit 9d753c6

Browse files
committed
small cleanup [ci skip]
1 parent 6f74364 commit 9d753c6

2 files changed

Lines changed: 8 additions & 14 deletions

File tree

src/Server/Services/GitLab/GitLabService.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
11
using System.Text.Json;
22
using System.Text.Json.Serialization.Metadata;
33
using NGitLab;
4+
using Ryujinx.Systems.Update.Common;
45
using Ryujinx.Systems.Update.Server.Helpers.Http;
56

67
namespace Ryujinx.Systems.Update.Server.Services.GitLab;
78

89
public class GitLabService
910
{
10-
private static readonly GitLabReleaseJsonResponseSerializerContext ReleaseSerializerContext =
11-
new();
12-
1311
private readonly IHttpClientProxy _http;
1412
public GitLabClient Client { get; }
1513

16-
private readonly ILogger<GitLabService> _logger;
17-
18-
public GitLabService(IConfiguration config, ILogger<GitLabService> logger, DefaultHttpClientProxy httpClient)
14+
public GitLabService(IConfiguration config, DefaultHttpClientProxy httpClient)
1915
{
20-
_logger = logger;
21-
2216
var gitlabSection = config.GetSection("GitLab");
2317

2418
if (!gitlabSection.Exists())
@@ -32,12 +26,12 @@ public GitLabService(IConfiguration config, ILogger<GitLabService> logger, Defau
3226
_http = httpClient;
3327
}
3428

35-
private async ValueTask<T?> HandleNotFoundAsync<T>(HttpResponseMessage response, JsonTypeInfo<T> typeInfo)
29+
private async ValueTask<T?> HandleNotFoundAsync<T>(HttpResponseMessage response, JsonTypeInfo<T> typeInfo) where T : class
3630
{
3731
var contentString = await response.Content.ReadAsStringAsync();
3832

3933
if (contentString is """{"message":"404 Not Found"}""")
40-
return default;
34+
return null;
4135

4236
return JsonSerializer.Deserialize(contentString, typeInfo);
4337
}
@@ -48,14 +42,14 @@ public GitLabService(IConfiguration config, ILogger<GitLabService> logger, Defau
4842
public async Task<GitLabReleaseJsonResponse?> GetReleaseAsync(long projectId, string tagName) =>
4943
await HandleNotFoundAsync(
5044
await _http.GetAsync($"api/v4/projects/{projectId}/releases/{tagName}"),
51-
ReleaseSerializerContext.GitLabReleaseJsonResponse
45+
JsonSerializerContexts.Default.GitLabReleaseJsonResponse
5246
);
5347

5448
public PaginatedEndpoint<GitLabReleaseJsonResponse> PageReleases(long projectId)
5549
=> _http.Paginate<GitLabReleaseJsonResponse>(builder => builder
5650
.WithBaseUrl($"api/v4/projects/{projectId}/releases")
5751
.WithPerPageCount(100)
58-
.WithJsonContentParser(ReleaseSerializerContext.IEnumerableGitLabReleaseJsonResponse)
52+
.WithJsonContentParser(JsonSerializerContexts.Default.IEnumerableGitLabReleaseJsonResponse)
5953
.WithQueryStringParameters(
6054
QueryParams.Sort("desc"),
6155
QueryParams.OrderBy("created_at")

src/Server/Services/GitLab/Model/GET_ProjectRelease.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Text.Json.Serialization;
22
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.
33

4-
namespace Ryujinx.Systems.Update.Server.Services.GitLab;
4+
namespace Ryujinx.Systems.Update.Common;
55

66
public class GitLabReleaseJsonResponse
77
{
@@ -42,4 +42,4 @@ public class WebLinks
4242
}
4343

4444
[JsonSerializable(typeof(IEnumerable<GitLabReleaseJsonResponse>))]
45-
internal partial class GitLabReleaseJsonResponseSerializerContext : JsonSerializerContext;
45+
public partial class JsonSerializerContexts : JsonSerializerContext;

0 commit comments

Comments
 (0)