Skip to content

Commit 7ab8344

Browse files
ChaseDRedmonclaudeqodana-cloud[bot]qodana-bot
authored
CatBox Client Abstraction & Error Handling (#4)
* Organize Requests and Clients into subfolders; Rename CreateAlbumRequest.cs to RemoteCreateAlbumRequest.cs. Add LocalCreateAlbumRequest.cs to create albums on catbox while uploading local files. Create abstraction for Local and Remote Requests: AlbumCreationRequest.cs. Begin work on CatBox client abstraction layer and created a method to upload files and create an album in one step. Working on better error handling from the API side of things. * Condense error handling error by creating a Throw helper class for exceptions * Organized request types by File, Url, or Album. Wrote some wrapper methods for uploading files and creating albums. * A little bit of work on the error handling using a HttpClient Delegating Handler * Sealed record requests * Implementation for uploading multiple files and creating an album that doesn't already exist * Added upload images to album method. Bump PolySharp version. Code formatting, variable renaming, etc. Add upload to album request type. Renamed some request types. Trying out AnyOf request type to simplify API usage * Code organization, renaming classes for readability improvements. Tweaks to Delegating Handler for exception throwing * Const string * Add BetterEnum source generator to remove duplicated API String Parameter code. Remove ToRequest methods that converted Enums to API equivalent request values. Add AddHttpClientWithMessageHandler extension method to clean up service registration. Code comments. Code organization. * Moved files * Code organization, remove throw new and replace with Throw helper * Remove CreateAlbum methods and consolidate request methods using AnyOf union type. Add AnyOf dependency. Add IAlbumUploadRequest.cs to abstract CreateAlbumRequest.cs and UploadToAlbumRequest.cs. Remove redundant upload methods in CatBox.cs. Rename Upload methods in CatBoxClient.cs. Change return type CatBoxClient.UplaodImage to IAsyncEnumerable<string?> instead of Task<string?>. * Remove UploadHost because I don't think I'll ever actually use this * Documentation and exception messaging improvements * Consolidate null checks * refactor: consolidate base class naming conventions Standardizes base class naming by adding "Base" suffix to abstract request classes. This improves code clarity by making inheritance hierarchies more explicit. Changes: - Rename AlbumCreationRequest → AlbumCreationRequestBase - Rename Album → AlbumBase - Rename UploadRequest → UploadRequestBase - Rename TemporaryRequest → TemporaryRequestBase - Update all derived classes to reference new base class names 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor: remove client interfaces and adopt concrete implementations Removes interface abstractions for client classes, transitioning to direct concrete type registration. This simplifies the architecture by eliminating unnecessary abstraction layers. Changes: - Remove ICatBox, ICatBoxClient, and ILitterboxClient interfaces - Update DI registration to use concrete types directly - Aligns with modern DI practices where interfaces are only needed for multiple implementations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor: reorganize Throw helper to Client namespace Moves Throw helper class from root namespace to CatBox.NET.Client namespace for better logical organization. The class contains HTTP client-specific validation helpers for file size limits and album operations. Changes: - Move src/CatBox.NET/Throw.cs → src/CatBox.NET/Client/Throw.cs - Add AssemblyInfo.cs with InternalsVisibleTo attribute for test projects - Improves code organization by placing validation helpers near their usage 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor: update client implementations and request handling Refactors client implementation code to utilize the new Throw helper methods, improving error handling consistency. Updates method signatures to work with renamed base classes and enhances validation logic throughout upload and album management operations. Changes: - Update CatBox.cs, CatBoxClient.cs, and LitterboxClient.cs with improved validation - Streamline file processing in both CatBox and Litterbox clients - Enhance error handling consistency using centralized Throw helpers - Update method signatures for renamed base classes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor: modernize enum implementations with Intellenum Removes custom ApiValueAttribute in favor of Intellenum source generator pattern. Refactors RequestType and ExpireAfter enums to use Intellenum's built-in value mapping, eliminating the need for custom attribute reflection. Changes: - Delete src/CatBox.NET/Attributes/ApiValueAttribute.cs - Refactor RequestType and ExpireAfter to use Intellenum - Update RequestParameters enum implementation - Improves performance by leveraging modern C# source generation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor: improve exception handling and messaging Enhances exception classes with more descriptive error messages and improved property names. Updates logger extensions for better diagnostic information and provides clearer feedback when API errors occur. Changes: - Enhance CatBoxAPIExceptions with better error messages - Update exception properties for clarity - Improve logger extensions with better diagnostics - Add detailed messages for file size limit violations and invalid request types 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor: update request models with enhanced validation Updates request model classes with improved validation using the refactored Throw helper. Enhances documentation on request properties and standardizes null checks and parameter validation across all request types. Changes: - Update IAlbumUploadRequest, EditAlbumRequest, and ModifyAlbumImagesRequest - Enhance validation in DeleteFileRequest, FileUploadRequest, and StreamUploadRequest - Update UrlUploadRequest with improved validation - Ensure consistent error messaging for invalid inputs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * chore: update project configuration and dependencies Updates project file with new dependencies and build configuration. Removes TaskAsyncEnumerableExtensions.cs as async enumerable handling is now integrated directly into client methods. Updates options class for improved configuration validation. Changes: - Update CatBox.NET.csproj with dependency changes - Delete Extensions/TaskAsyncEnumerableExtensions.cs (functionality moved to clients) - Update CatboxOptions.cs with improved validation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * test: add comprehensive unit and integration tests Implements comprehensive test coverage including unit tests with mocked HTTP responses and integration tests against live APIs. Adds test helper classes for creating mock HTTP clients and managing test configuration. Changes: - Add CatBoxClientTests.cs and CatBoxClientIntegrationTests.cs - Add LitterboxClientTests.cs and LitterboxClientIntegrationTests.cs - Add CommonTests.cs for utility function testing - Create test helpers (HttpClientTestHelper, IntegrationTestConfig) - Include test image assets (test-file.png, test-file.svg) - Add comprehensive test documentation in README - Remove unused Usings.cs global using directives file - Update test project configuration 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * chore: update sample application with new API patterns Updates the sample application to demonstrate the refactored API. Shows usage of new request patterns, concrete client types, and enhanced error handling. Updates project dependencies to match library changes and provides practical examples of album creation, file uploads, and error scenarios. Changes: - Update Program.cs with examples using refactored API - Demonstrate new request patterns and error handling - Update SampleApp.csproj dependencies - Add practical usage examples for library consumers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * chore: migrate to XML-based solution file Transitions from legacy .sln format to modern XML-based .slnx solution file format. This provides better merge conflict resolution and human-readability for the solution configuration. Changes: - Delete CatBox.NET.sln (legacy format) - Add CatBox.NET.slnx (modern XML format) - Improves version control friendliness 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * chore: add IDE and workspace configuration Adds IDE-specific configuration files for Claude Code, JetBrains Rider, and Visual Studio Code. Configures workspace settings, project structure preferences, and code style rules to improve developer experience across different IDEs. Changes: - Add .claude/settings.local.json for Claude Code configuration - Add .idea/.idea.CatBox.NET/.idea/projectSettingsUpdater.xml for Rider - Add .vscode/settings.json for Visual Studio Code - Standardizes development environment setup 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: update README with API changes and migration guide Updates main README to reflect the architectural changes, including removal of interfaces, new request patterns, and updated usage examples. Documents breaking changes and provides migration guidance for users upgrading from previous versions. Changes: - Update README with refactored API examples - Document breaking changes (interface removal, renamed base classes) - Add migration guidance for existing users - Update usage examples to reflect new patterns 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Add qodana CI checks (#6) * Add qodana.yaml file * Add github workflow file --------- Co-authored-by: Qodana Application <qodana-support@jetbrains.com> * Update runner to run on version 5 * Use Intellenum TypeConverter * Update qodana.yaml * Add slnx file * Reformatting / re-run qodana * Add sln file back to satisfy qodana solution? * Re-run * fixed??? * Test change 2 * fix .net 10 --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: qodana-cloud[bot] <163413896+qodana-cloud[bot]@users.noreply.github.com> Co-authored-by: Qodana Application <qodana-support@jetbrains.com>
1 parent 14c14c4 commit 7ab8344

66 files changed

Lines changed: 4161 additions & 971 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/settings.local.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"mcp__Rider__list_directory_tree",
5+
"mcp__Rider__find_files_by_name_keyword",
6+
"mcp__Rider__get_run_configurations",
7+
"mcp__Rider__search_in_files_by_text",
8+
"Bash(dotnet build:*)",
9+
"mcp__fetch__fetch",
10+
"Bash(dotnet test:*)",
11+
"mcp__Rider__get_file_text_by_path",
12+
"mcp__sequentialthinking__sequentialthinking",
13+
"mcp__MicrosoftLearn__microsoft_docs_search",
14+
"mcp__MicrosoftLearn__microsoft_docs_fetch",
15+
"mcp__Rider__replace_text_in_file",
16+
"Bash(dir:*)",
17+
"WebSearch",
18+
"Bash(dotnet --version:*)",
19+
"WebFetch(domain:github.com)",
20+
"WebFetch(domain:stackoverflow.com)",
21+
"Bash(dotnet add:*)",
22+
"mcp__MicrosoftLearn__microsoft_code_sample_search",
23+
"Bash(del \"C:\\Coding\\CSharp\\Personal\\Libraries\\CatBox.NET\\src\\CatBox.NET\\Client\\Helpers.cs\")",
24+
"Bash(git commit:*)",
25+
"Bash(git reset:*)",
26+
"Bash(git add:*)",
27+
"Bash(dotnet new:*)",
28+
"Bash(cat:*)"
29+
],
30+
"deny": [],
31+
"ask": []
32+
}
33+
}

.editorconfig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
21
[*]
32
charset = utf-8-bom
43
end_of_line = crlf
54
trim_trailing_whitespace = false
65
insert_final_newline = false
76
indent_style = space
8-
indent_size = 4
97

8+
[{*.yml,*.json,*.xml,*.csproj,*.slnx}]
9+
indent_size = 2
10+
11+
[*.{appxmanifest,asax,ascx,aspx,axaml,build,c,c++,cc,cginc,compute,cp,cpp,cs,cshtml,cu,cuh,cxx,dtd,fs,fsi,fsscript,fsx,fx,fxh,h,hh,hlsl,hlsli,hlslinc,hpp,hxx,inc,inl,ino,ipp,ixx,master,ml,mli,mpp,mq4,mq5,mqh,nuspec,paml,razor,resw,resx,shader,skin,tpp,usf,ush,vb,xaml,xamlx,xoml,xsd}]
1012
# Microsoft .NET properties
1113
csharp_new_line_before_members_in_object_initializers = false
1214
csharp_preferred_modifier_order = public, private, protected, internal, file, new, static, abstract, virtual, sealed, readonly, override, extern, unsafe, volatile, async, required:suggestion
@@ -75,7 +77,6 @@ resharper_web_config_module_not_resolved_highlighting = warning
7577
resharper_web_config_type_not_resolved_highlighting = warning
7678
resharper_web_config_wrong_module_highlighting = warning
7779

78-
[*.{appxmanifest,asax,ascx,aspx,axaml,build,c,c++,cc,cginc,compute,cp,cpp,cs,cshtml,cu,cuh,cxx,dtd,fs,fsi,fsscript,fsx,fx,fxh,h,hh,hlsl,hlsli,hlslinc,hpp,hxx,inc,inl,ino,ipp,ixx,master,ml,mli,mpp,mq4,mq5,mqh,nuspec,paml,razor,resw,resx,shader,skin,tpp,usf,ush,vb,xaml,xamlx,xoml,xsd}]
7980
indent_style = space
8081
indent_size = 4
8182
tab_width = 4

.github/workflows/qodana_code_quality.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Test Change 2
12
name: Qodana
23
on:
34
workflow_dispatch:

.idea/.idea.CatBox.NET/.idea/projectSettingsUpdater.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"dotnet.defaultSolution": "CatBox.NET.sln"
3+
}

CatBox.NET.sln

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
Microsoft Visual Studio Solution File, Format Version 12.00
32
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CatBox.NET", "src\CatBox.NET\CatBox.NET.csproj", "{CDEF8297-E053-495F-960C-F3EBAEA7E71F}"
43
EndProject

CatBox.NET.slnx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Solution>
2+
<Folder Name="/samples/">
3+
<Project Path="samples/SampleApp/SampleApp.csproj"/>
4+
</Folder>
5+
<Folder Name="/Solution/">
6+
<File Path=".editorconfig"/>
7+
<File Path=".github/workflows/release.yml"/>
8+
<File Path=".github/workflows/qodana_code_quality.yml"/>
9+
<File Path=".gitignore"/>
10+
<File Path="qodana.yaml"/>
11+
<File Path="CLAUDE.md"/>
12+
<File Path="license.txt"/>
13+
<File Path="readme.md"/>
14+
</Folder>
15+
<Folder Name="/src/">
16+
<Project Path="src/CatBox.NET/CatBox.NET.csproj"/>
17+
</Folder>
18+
<Folder Name="/tests/">
19+
<Project Path="tests/CatBox.Tests/CatBox.Tests.csproj"/>
20+
</Folder>
21+
</Solution>

global.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"sdk": {
3+
"version": "10.0.100",
4+
"rollForward": "latestFeature"
5+
}
6+
}

qodana.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
####################################################################################################################
44

55
version: "1.0"
6-
linter: jetbrains/qodana-cdnet:2025.2
6+
linter: jetbrains/qodana-cdnet:latest
7+
bootstrap: curl -fsSL https://dot.net/v1/dotnet-install.sh | bash -s -- --jsonfile /data/project/global.json -i /usr/share/dotnet
8+
dotnet:
9+
solution: CatBox.NET.sln
710
profile:
811
name: qodana.recommended
912
include:

readme.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,4 @@ CatBox.NET is a library for uploading images to the [CatBox.moe](https://catbox.
1111

1212
## Getting Started
1313

14-
Head over [to our wiki](https://github.com/ChaseDRedmon/CatBox.NET/wiki) to get started on how to use the library.
15-
16-
## Prerequisites
17-
Change your Language Version to C# 11, by adding the following code to your `.csproj` file. Make sure the `<LangVersion>` tag is added under your `<PropertyGroup>`
18-
19-
```csharp
20-
<PropertyGroup>
21-
<LangVersion>11</LangVersion>
22-
</PropertyGroup>
23-
```
14+
Head over [to our wiki](https://github.com/ChaseDRedmon/CatBox.NET/wiki) to get started on how to use the library.

0 commit comments

Comments
 (0)