Gorse.NET fixes and package updates#23
Gorse.NET fixes and package updates#23IbrahimHabibeh wants to merge 13 commits intogorse-io:mainfrom
Conversation
There was a problem hiding this comment.
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
GorseClientand updates API partial classes/tests accordingly. - Aligns model naming/types (e.g.,
TimeStamp→Timestamp,Feedback.TimestamptoDateTime) 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.
| /// <summary> | ||
| /// Insert feedback. Duplicate feedback will have their values summed. | ||
| /// Use UpsertFeedbackAsync for overwrite semantics. | ||
| /// </summary> |
There was a problem hiding this comment.
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.
Gorse.NET/API/RecommendationAPI.cs
Outdated
| public string[]? GetRecommend(string userId, int? n = 10) | ||
| { | ||
| return _client.Request<string[], Object>(Method.Get, $"api/recommend/{userId}?n={n}", null); | ||
| } |
There was a problem hiding this comment.
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).
Gorse.NET/API/RecommendationAPI.cs
Outdated
| public Task<List<UserScore>> GetRecommendLatestAsync(int? n = 10) | ||
| { | ||
| return _client.RequestAsync<List<UserScore>, object>(Method.Get, $"api/latest?n={n}", null)!; | ||
| } |
There was a problem hiding this comment.
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.
Gorse.NET/API/FeedbackAPI.cs
Outdated
| public Result UpsertFeedback(Feedback[] feedbacks) | ||
| { | ||
| return _client.Request<Result, Feedback[]>(Method.Put, "api/feedback", feedbacks)!; | ||
| } | ||
|
|
There was a problem hiding this comment.
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.
Gorse.NET/Gorse.cs
Outdated
| public partial class GorseClient | ||
| { | ||
| private readonly RequestClient _client; | ||
| public Gorse(string endpoint, string apiKey) | ||
| public GorseClient(string endpoint, string apiKey) | ||
| { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Though GorseClient is a better name, but i suggest keep Gorse to avoid break changes.
| <TargetFramework>net9.0</TargetFramework> | ||
| <ImplicitUsings>enable</ImplicitUsings> |
There was a problem hiding this comment.
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).
| /// <summary> | ||
| /// Upsert feedback. Duplicate feedback will be overwritten (not summed). | ||
| /// Use InsertFeedbackAsync for additive/sum semantics. | ||
| /// </summary> |
There was a problem hiding this comment.
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.
Gorse.NET/API/RecommendationAPI.cs
Outdated
| public Task<List<UserScore>> GetRecommendLatestAsync(int? n = 10) | ||
| { | ||
| return _client.RequestAsync<List<UserScore>, object>(Method.Get, $"api/latest?n={n}", null)!; | ||
| } |
There was a problem hiding this comment.
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.
Gorse.NET/API/FeedbackAPI.cs
Outdated
| /// Use UpsertFeedbackAsync for overwrite semantics. | ||
| /// </summary> | ||
| public Task<Result> InsertFeedbackAsync(List<Feedback> feedbacks) | ||
| { | ||
| return _client.RequestAsync<Result, List<Feedback>>(Method.Post, "api/feedback", feedbacks)!; |
There was a problem hiding this comment.
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>).
Gorse.NET/Gorse.cs
Outdated
| public partial class GorseClient | ||
| { | ||
| private readonly RequestClient _client; | ||
| public Gorse(string endpoint, string apiKey) | ||
| public GorseClient(string endpoint, string apiKey) | ||
| { |
There was a problem hiding this comment.
Though GorseClient is a better name, but i suggest keep Gorse to avoid break changes.
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.