Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Modrinth.Net/Endpoints/Project/IProjectEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Task<SearchResponse> SearchAsync(
/// <returns></returns>
/// <exception cref="ModrinthApiException"> Thrown when the API returns an error or the request fails </exception>
Task AddGalleryImageAsync(string slugOrId, string imagePath, bool featured, string? title = null,
string? description = null, int? ordering = null, CancellationToken cancellationToken = default);
string? description = null, long? ordering = null, CancellationToken cancellationToken = default);

/// <summary>
/// Modifies an existing gallery image
Expand All @@ -147,7 +147,7 @@ Task AddGalleryImageAsync(string slugOrId, string imagePath, bool featured, stri
/// <returns></returns>
/// <exception cref="ModrinthApiException"> Thrown when the API returns an error or the request fails </exception>
Task ModifyGalleryImageAsync(string slugOrId, string url, bool? featured = null, string? title = null,
string? description = null, int? ordering = null, CancellationToken cancellationToken = default);
string? description = null, long? ordering = null, CancellationToken cancellationToken = default);

/// <summary>
/// Deletes an existing gallery image
Expand Down
4 changes: 2 additions & 2 deletions src/Modrinth.Net/Endpoints/Project/ProjectEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public async Task ChangeIconAsync(string slugOrId, string iconPath, Cancellation

/// <inheritdoc />
public async Task AddGalleryImageAsync(string slugOrId, string imagePath, bool featured, string? title = null,
string? description = null, int? ordering = null, CancellationToken cancellationToken = default)
string? description = null, long? ordering = null, CancellationToken cancellationToken = default)
{
if (!File.Exists(imagePath)) throw new FileNotFoundException("Image not found", imagePath);

Expand Down Expand Up @@ -193,7 +193,7 @@ public async Task AddGalleryImageAsync(string slugOrId, string imagePath, bool f

/// <inheritdoc />
public async Task ModifyGalleryImageAsync(string slugOrId, string url, bool? featured = null, string? title = null,
string? description = null, int? ordering = null, CancellationToken cancellationToken = default)
string? description = null, long? ordering = null, CancellationToken cancellationToken = default)
{
if (ordering < 0)
throw new ArgumentOutOfRangeException(nameof(ordering), "Ordering must be greater than or equal to 0");
Expand Down
2 changes: 1 addition & 1 deletion src/Modrinth.Net/Models/Gallery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ public class Gallery
/// <summary>
/// The order of the gallery image. Gallery images are sorted by this field and then alphabetically by title.
/// </summary>
public int Ordering { get; set; }
public long Ordering { get; set; }
}
49 changes: 49 additions & 0 deletions test/Modrinth.Net.Test/RequesterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Text;
using Modrinth.Exceptions;
using Modrinth.Http;
using Modrinth.Models;

namespace Modrinth.Net.Test;

Expand Down Expand Up @@ -166,4 +167,52 @@ public async Task SendAsync_ReleasesSemaphoreAfterFailureOrCancellation()
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
Assert.That(handler.Calls, Is.EqualTo(2));
}

[Test]
public async Task GetJsonAsync_GalleryOrderingAboveInt32Max_DeserializesSuccessfully()
{
const long expectedOrdering = 6844313514;
var json =
"[{\"url\":\"https://example.com/image.png\",\"featured\":false,\"title\":\"t\",\"description\":\"d\",\"created\":\"2026-01-01T00:00:00Z\",\"ordering\":" +
expectedOrdering + "}]";

var handler = new DelegateMessageHandler((_, _) =>
Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent(json, Encoding.UTF8, "application/json")
}));

using var requester = CreateRequester(handler);
var request = new HttpRequestMessage(HttpMethod.Get, "http://test.com");

var galleries = await requester.GetJsonAsync<Gallery[]>(request);

using (Assert.EnterMultipleScope())
{
Assert.That(galleries, Has.Length.EqualTo(1));
Assert.That(galleries[0].Ordering, Is.EqualTo(expectedOrdering));
}
}

[Test]
public async Task GetJsonAsync_GalleryOrderingHugeInt64_DeserializesSuccessfully()
{
const long expectedOrdering = 68541332132131350;
var json =
"[{\"url\":\"https://example.com/image.png\",\"featured\":true,\"title\":\"t\",\"description\":\"d\",\"created\":\"2026-01-01T00:00:00Z\",\"ordering\":" +
expectedOrdering + "}]";

var handler = new DelegateMessageHandler((_, _) =>
Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent(json, Encoding.UTF8, "application/json")
}));

using var requester = CreateRequester(handler);
var request = new HttpRequestMessage(HttpMethod.Get, "http://test.com");

var galleries = await requester.GetJsonAsync<Gallery[]>(request);

Assert.That(galleries[0].Ordering, Is.EqualTo(expectedOrdering));
}
}
Loading