Skip to content

Commit 9cf2741

Browse files
committed
Fixed IL2026 and IL3050 errors
1 parent 68e7b36 commit 9cf2741

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/services/Elastic.Documentation.Services/Changelog/GitHubPrService.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,18 @@
44

55
using System.Net.Http.Headers;
66
using System.Text.Json;
7+
using System.Text.Json.Serialization;
78
using Microsoft.Extensions.Logging;
89

910
namespace Elastic.Documentation.Services.Changelog;
1011

1112
/// <summary>
1213
/// Service for fetching pull request information from GitHub
1314
/// </summary>
14-
public class GitHubPrService(ILoggerFactory loggerFactory)
15+
public partial class GitHubPrService(ILoggerFactory loggerFactory)
1516
{
1617
private readonly ILogger<GitHubPrService> _logger = loggerFactory.CreateLogger<GitHubPrService>();
1718
private static readonly HttpClient HttpClient = new();
18-
private static readonly JsonSerializerOptions JsonOptions = new()
19-
{
20-
PropertyNameCaseInsensitive = true
21-
};
2219

2320
static GitHubPrService()
2421
{
@@ -63,7 +60,7 @@ static GitHubPrService()
6360
}
6461

6562
var jsonContent = await response.Content.ReadAsStringAsync(ctx);
66-
var prData = JsonSerializer.Deserialize<GitHubPrResponse>(jsonContent, JsonOptions);
63+
var prData = JsonSerializer.Deserialize(jsonContent, GitHubPrJsonContext.Default.GitHubPrResponse);
6764

6865
if (prData == null)
6966
{
@@ -152,6 +149,12 @@ private sealed class GitHubLabel
152149
{
153150
public string Name { get; set; } = string.Empty;
154151
}
152+
153+
[JsonSourceGenerationOptions(PropertyNameCaseInsensitive = true)]
154+
[JsonSerializable(typeof(GitHubPrResponse))]
155+
[JsonSerializable(typeof(GitHubLabel))]
156+
[JsonSerializable(typeof(List<GitHubLabel>))]
157+
private sealed partial class GitHubPrJsonContext : JsonSerializerContext;
155158
}
156159

157160
/// <summary>

0 commit comments

Comments
 (0)