Skip to content

Gorse.NET fixes and package updates#23

Open
IbrahimHabibeh wants to merge 13 commits intogorse-io:mainfrom
IbrahimHabibeh:main
Open

Gorse.NET fixes and package updates#23
IbrahimHabibeh wants to merge 13 commits intogorse-io:mainfrom
IbrahimHabibeh:main

Conversation

@IbrahimHabibeh
Copy link

This is a fork of Gorse.NET that I maintain locally. It's updated for .NET 10 and provides some missing implementations for newer Gorse endpoints. Additionally, it fixes a few issues with naming convention and type usage to make it more consistent with Gorse.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Gorse.NET client library with newer endpoint support and naming/type consistency improvements, alongside framework and package updates.

Changes:

  • Renames the main client class to GorseClient and updates API partial classes/tests accordingly.
  • Aligns model naming/types (e.g., TimeStampTimestamp, Feedback.Timestamp to DateTime) and expands feedback/recommendation APIs.
  • Updates target frameworks and bumps RestSharp dependency.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
Gorse.NET/Models/Item.cs Renames TimeStamp to Timestamp on Item.
Gorse.NET/Models/Feedback.cs Changes Timestamp from string to DateTime.
Gorse.NET/Gorse.cs Renames main client type to GorseClient.
Gorse.NET/Gorse.NET.csproj Targets net9.0 and updates RestSharp reference.
Gorse.NET/API/UsersAPI.cs Updates partial class to GorseClient.
Gorse.NET/API/RecommendationAPI.cs Adds optional n to recommend calls and adds latest endpoint method.
Gorse.NET/API/ItemsAPI.cs Updates partial class to GorseClient.
Gorse.NET/API/FeedbackAPI.cs Adds upsert feedback support and changes async signature type.
Gorse.NET.Tests/UnitTests/TestItemsAPI.cs Updates test usage for Timestamp.
Gorse.NET.Tests/UnitTests/TestFeedbackAPI.cs Updates timestamp type usage and async feedback collection type.
Gorse.NET.Tests/GorseTest.cs Updates test client construction to GorseClient.
Gorse.NET.Tests/Gorse.NET.Tests.csproj Targets net9.0.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 10 to 13
/// <summary>
/// Insert feedback. Duplicate feedback will have their values summed.
/// Use UpsertFeedbackAsync for overwrite semantics.
/// </summary>
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These XML docs are on the synchronous InsertFeedback method but reference UpsertFeedbackAsync. This is misleading for callers; the docs should reference the synchronous alternative (UpsertFeedback) or mention both sync/async options consistently.

Copilot uses AI. Check for mistakes.
Comment on lines 8 to 11
public string[]? GetRecommend(string userId, int? n = 10)
{
return _client.Request<string[], Object>(Method.Get, $"api/recommend/{userId}?n={n}", null);
}
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

n is nullable but is always appended into the query string; when n == null this produces ?n= which can cause server-side validation errors. Prefer a non-nullable int n = 10, or omit the n query parameter when it’s null (apply the same fix to the async overload).

Copilot uses AI. Check for mistakes.
Comment on lines 28 to 31
public Task<List<UserScore>> GetRecommendLatestAsync(int? n = 10)
{
return _client.RequestAsync<List<UserScore>, object>(Method.Get, $"api/latest?n={n}", null)!;
}
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetRecommendLatestAsync is newly introduced but currently has no test coverage (the recommendation tests only exercise GetRecommend*). Add a test that calls this method and asserts the response shape/contents to prevent future breaking changes.

Copilot uses AI. Check for mistakes.
Comment on lines 32 to 36
public Result UpsertFeedback(Feedback[] feedbacks)
{
return _client.Request<Result, Feedback[]>(Method.Put, "api/feedback", feedbacks)!;
}

Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New upsert operations were added (UpsertFeedback / UpsertFeedbackAsync), but there are no corresponding tests validating the PUT/overwrite semantics. Please add coverage similar to the existing InsertFeedback tests so regressions in endpoint behavior are caught.

Copilot uses AI. Check for mistakes.
Comment on lines 6 to 10
public partial class GorseClient
{
private readonly RequestClient _client;
public Gorse(string endpoint, string apiKey)
public GorseClient(string endpoint, string apiKey)
{
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renaming the public client type from Gorse to GorseClient is a breaking change for all consumers. Consider keeping a Gorse wrapper/alias (optionally marked [Obsolete]) or bumping the package major version to reflect the breaking API change.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though GorseClient is a better name, but i suggest keep Gorse to avoid break changes.

Comment on lines 3 to 4
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description mentions .NET 10, but the test project targets net9.0. Align the test target framework with the intended supported runtime (or update the PR description if net9 is the goal).

Copilot uses AI. Check for mistakes.
Comment on lines 28 to 31
/// <summary>
/// Upsert feedback. Duplicate feedback will be overwritten (not summed).
/// Use InsertFeedbackAsync for additive/sum semantics.
/// </summary>
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These XML docs are on the synchronous UpsertFeedback method but reference InsertFeedbackAsync. Update the documentation to point to the synchronous InsertFeedback method (or mention both) so callers don’t have to infer the correct API.

Copilot uses AI. Check for mistakes.
Comment on lines 28 to 31
public Task<List<UserScore>> GetRecommendLatestAsync(int? n = 10)
{
return _client.RequestAsync<List<UserScore>, object>(Method.Get, $"api/latest?n={n}", null)!;
}
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as above: GetRecommendLatestAsync accepts nullable n but always includes it in the URL, resulting in ?n= when null. Use a non-nullable int n = 10 or conditionally omit the query parameter.

Copilot uses AI. Check for mistakes.
Comment on lines 21 to 25
/// Use UpsertFeedbackAsync for overwrite semantics.
/// </summary>
public Task<Result> InsertFeedbackAsync(List<Feedback> feedbacks)
{
return _client.RequestAsync<Result, List<Feedback>>(Method.Post, "api/feedback", feedbacks)!;
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InsertFeedback takes Feedback[] while InsertFeedbackAsync takes List<Feedback> (and similarly for upsert). This makes the public API inconsistent and forces callers to change collection types depending on sync/async. Consider using the same parameter type across both (or offering overloads, e.g., IEnumerable<Feedback>).

Copilot uses AI. Check for mistakes.
Comment on lines 6 to 10
public partial class GorseClient
{
private readonly RequestClient _client;
public Gorse(string endpoint, string apiKey)
public GorseClient(string endpoint, string apiKey)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though GorseClient is a better name, but i suggest keep Gorse to avoid break changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants