-
Notifications
You must be signed in to change notification settings - Fork 7
chore: update main with recent improvements #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
refactor(tlsclient): simplify platform-specific logic with TlsClientWrapper refactor(wrapper): make TlsClientWrapper static with thread-safe initialization refactor(core): improve error handling and nullability defaults refactor(core): remove legacy code and outdated configurations feat(request): add new configuration options for requests feat(builder): enhance TlsClientBuilder with new configuration options chore(deps): update dependencies and remove unused packages test: improve coverage and simplify test suite
…te usage guides fix(core): correct cookie handling logic in TlsRestClientBuilder docs: update licensing, contribution, and support information chore: fix README file paths in project files and cleanup code/comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR performs a comprehensive refactor and improvement of the TlsClient.NET library, transitioning from Newtonsoft.Json to System.Text.Json, simplifying the architecture, and updating documentation. The changes modernize the codebase while improving thread safety and performance.
- Replaced Newtonsoft.Json with System.Text.Json throughout the codebase
- Refactored TlsClientWrapper from instance-based to static with centralized initialization
- Updated test structure with new test files and removed obsolete ones
- Comprehensive documentation updates with new README files for each package
Reviewed Changes
Copilot reviewed 48 out of 48 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/TlsClient.RestSharp.Tests/TlsClient.RestSharp.Tests.csproj | Updated package versions and added build configurations |
| tests/TlsClient.RestSharp.Tests/StatusTests.cs | Simplified tests with centralized initialization |
| tests/TlsClient.RestSharp.Tests/MethodTests.cs | New test file for HTTP method validation |
| tests/TlsClient.RestSharp.Tests/CustomClientTests.cs | Removed obsolete custom client tests |
| tests/TlsClient.RestSharp.Tests/CookieTests.cs | New comprehensive cookie handling tests |
| tests/TlsClient.RestSharp.Tests/BodyTests.cs | Simplified body handling tests |
| tests/TlsClient.Issues/TlsClient.Issues.csproj | Removed issues project file |
| tests/TlsClient.Issues/Issue4.cs | Removed issues test file |
| tests/TlsClient.Core.Tests/TlsClient.Core.Tests.csproj | Updated package versions |
| tests/TlsClient.Core.Tests/TLSTests.cs | Renamed and expanded TLS functionality tests |
| tests/TlsClient.Core.Tests/StatusTests.cs | Simplified status code tests with centralized initialization |
| tests/TlsClient.Core.Tests/PerformanceTests.cs | Enhanced performance and memory leak tests |
| tests/TlsClient.Core.Tests/MethodTests.cs | New HTTP method tests for core client |
| tests/TlsClient.Core.Tests/HeaderTests.cs | Simplified header handling tests |
| tests/TlsClient.Core.Tests/CustomClientTests.cs | Removed obsolete custom client tests |
| tests/TlsClient.Core.Tests/CookieTests.cs | Enhanced cookie handling tests |
| tests/TlsClient.Core.Tests/ClientTests.cs | New client lifecycle and initialization tests |
| tests/TlsClient.Core.Tests/BuilderTests.cs | New builder pattern tests |
| tests/TlsClient.Core.Tests/BodyTests.cs | New body handling tests including file uploads |
| src/TlsClient.RestSharp/TlsClient.RestSharp.csproj | Updated README path reference |
| src/TlsClient.RestSharp/README.md | New package-specific documentation |
| src/TlsClient.RestSharp/Helpers/Builders/TlsRestClientBuilder.cs | Improved builder with better validation and cookie handling |
| src/TlsClient.HttpClient/TlsClientHandler.cs | Added cookie jar handling and improved error handling |
| src/TlsClient.HttpClient/TlsClient.HttpClient.csproj | Updated README path reference |
| src/TlsClient.HttpClient/README.md | New package-specific documentation |
| src/TlsClient.Core/TlsClient.cs | Major refactor to use static wrapper and sync methods |
| src/TlsClient.Core/TlsClient.Core.csproj | Removed Newtonsoft.Json dependency, updated System.Text.Json |
| src/TlsClient.Core/README.md | Comprehensive new documentation |
| src/TlsClient.Core/Models/Responses/GetCookiesFromSessionResponse.cs | Added default list initialization |
| src/TlsClient.Core/Models/Requests/Request.cs | Migrated to System.Text.Json attributes and improved property initialization |
| src/TlsClient.Core/Models/Requests/GetCookiesFromSessionRequest.cs | Added default string initialization |
| src/TlsClient.Core/Models/Requests/AddCookiesToSessionRequest.cs | Added default string initialization |
| src/TlsClient.Core/Models/Entities/TlsClientOptions.cs | Enhanced options with new properties and nullable TlsClientIdentifier |
| src/TlsClient.Core/Models/Entities/TlsClientIdentifier.cs | Removed Newtonsoft.Json dependency |
| src/TlsClient.Core/Models/Entities/TlsClientCookie.cs | Improved cookie model with nullable properties and constructors |
| src/TlsClient.Core/Helpers/Wrappers/TlsClientWrapper.cs | Major refactor from instance to static class with improved thread safety |
| src/TlsClient.Core/Helpers/RequestHelpers.cs | Migrated from Newtonsoft.Json to System.Text.Json |
| src/TlsClient.Core/Helpers/Natives/NativeLoader.cs | Namespace correction and parameter validation |
| src/TlsClient.Core/Helpers/Natives/NativeLinuxMethods.cs | Modernized string operations |
| src/TlsClient.Core/Helpers/Extensions/TlsClientExtensions.cs | New extension methods for async operations |
| src/TlsClient.Core/Helpers/Converters/JsonStringConverter.cs | Migrated converter to System.Text.Json |
| src/TlsClient.Core/Helpers/Builders/TlsClientBuilder.cs | Enhanced builder with new methods and improved validation |
| src/TlsClient.Core/Helpers/Builders/RequestBuilder.cs | Migrated to System.Text.Json and added new builder methods |
| readme.md | Complete documentation rewrite with improved structure |
| examples/TlsClient.Examples.Console/TlsClient.Examples.Console.csproj | Updated target framework and added DotNetEnv |
| examples/TlsClient.Examples.Console/Properties/launchSettings.json | New launch settings with environment variables |
| examples/TlsClient.Examples.Console/Program.cs | Simplified example using environment variables |
| TlsClient.sln | Removed TlsClient.Issues project |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| { | ||
| static TlsTests() | ||
| { | ||
| TlsClient.Initialize("D:\\Tools\\TlsClient\\tls-client-windows-64-1.11.0.dll"); |
Copilot
AI
Sep 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard-coded Windows-specific file path makes tests non-portable across operating systems. Consider using environment variables or a configuration mechanism to specify the library path.
| TlsClient.Initialize("D:\\Tools\\TlsClient\\tls-client-windows-64-1.11.0.dll"); | |
| var dllPath = Environment.GetEnvironmentVariable("TLS_CLIENT_DLL_PATH"); | |
| if (string.IsNullOrEmpty(dllPath)) | |
| { | |
| throw new InvalidOperationException("TLS_CLIENT_DLL_PATH environment variable is not set. Please set it to the path of the tls-client DLL."); | |
| } | |
| TlsClient.Initialize(dllPath); |
|
|
||
| restResponse.StatusCode.Should().Be(0); | ||
| restResponse.ResponseStatus.Should().Be(ResponseStatus.TimedOut); | ||
| Core.TlsClient.Initialize("D:\\Tools\\TlsClient\\tls-client-windows-64-1.10.0.dll"); |
Copilot
AI
Sep 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard-coded Windows-specific file path makes tests non-portable across operating systems. Consider using environment variables or a configuration mechanism to specify the library path.
| Core.TlsClient.Initialize("D:\\Tools\\TlsClient\\tls-client-windows-64-1.10.0.dll"); | |
| var dllPath = Environment.GetEnvironmentVariable("TLSCLIENT_DLL_PATH") | |
| ?? "D:\\Tools\\TlsClient\\tls-client-windows-64-1.10.0.dll"; | |
| Core.TlsClient.Initialize(dllPath); |
| public Dictionary<string, List<string>> DefaultHeaders { get; set; } | ||
| public Guid SessionID { get; set; } | ||
| public TlsClientIdentifier TlsClientIdentifier { get; set; } = TlsClientIdentifier.Chrome131; | ||
| public TlsClientIdentifier? TlsClientIdentifier { get; set; } = null; |
Copilot
AI
Sep 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant explicit = null assignment for nullable reference type. The property will be null by default.
| public TlsClientIdentifier? TlsClientIdentifier { get; set; } = null; | |
| public TlsClientIdentifier? TlsClientIdentifier { get; set; } |
| DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, // Null değerleri yoksay | ||
| WriteIndented = true, // Indent edilmiş JSON | ||
| PropertyNamingPolicy = JsonNamingPolicy.CamelCase // camelCase isimlendirme |
Copilot
AI
Sep 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments are in Turkish. Consider using English for consistency with the rest of the codebase.
| DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, // Null değerleri yoksay | |
| WriteIndented = true, // Indent edilmiş JSON | |
| PropertyNamingPolicy = JsonNamingPolicy.CamelCase // camelCase isimlendirme | |
| DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, // Ignore null values | |
| WriteIndented = true, // Indented JSON | |
| PropertyNamingPolicy = JsonNamingPolicy.CamelCase // camelCase naming |
Refactors
Fixes
Documentation
Chore