Skip to content

Replace string ProxyAddress with IWebProxy for flexible proxy configuration#925

Merged
abuzuhri merged 11 commits into
abuzuhri:mainfrom
ProNotion:feature/WebProxy
Apr 25, 2026
Merged

Replace string ProxyAddress with IWebProxy for flexible proxy configuration#925
abuzuhri merged 11 commits into
abuzuhri:mainfrom
ProNotion:feature/WebProxy

Conversation

@ProNotion

@ProNotion ProNotion commented Apr 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Replaces the string ProxyAddress property on AmazonCredential with IWebProxy Proxy, allowing callers to pass any proxy implementation (e.g. authenticated proxies via WebProxy credentials, or custom IWebProxy implementations). ProxyAddress is retained as an [Obsolete] property that wraps Proxy, so existing object-initialiser callers continue to compile with a migration warning
  • The existing string-based constructor overload is preserved (parameter name unchanged) for backwards compatibility; a separate IWebProxy constructor was considered but removed to avoid null-argument ambiguity -- callers supplying an IWebProxy directly should use the Proxy property via object initialiser (new AmazonCredential { Proxy = ... })
  • Removes redundant null-check branching in RequestService and LWAClient -- RestSharp handles a null Proxy value cleanly, so a single code path suffices
  • LWAClient updated to accept IWebProxy directly rather than extracting a string address from it
  • README updated with corrected proxy configuration examples referencing the IWebProxy interface

Test plan

  • Verify requests succeed without any proxy configured (null proxy path)
  • Verify requests are routed correctly when a plain WebProxy address is provided
  • Verify requests are routed correctly when an authenticated WebProxy with credentials is provided
  • Confirm the string-based constructor overload still works for existing callers
  • Confirm existing callers using ProxyAddress via object initialiser receive a deprecation warning but still compile

ProNotion and others added 10 commits December 4, 2024 07:04
# Fixed conflicts:
#	README.md
#	Source/FikaAmazonAPI/AmazonCredential.cs
# Conflicts:
#	Source/FikaAmazonAPI/AmazonCredential.cs
Upgrades the proxy configuration from a plain string to IWebProxy,
allowing callers to pass any proxy implementation including authenticated
proxies via WebProxy credentials. A backwards-compatible string-based
constructor overload is retained. RequestService simplified to a single
code path; TokenGeneration extracts the address string for LWAClient
which still requires one. README updated to reflect the new API.
Resolves conflicts in README.md, RequestService.cs, and TokenGeneration.cs
from merging main into feature/WebProxy. LWAClient simplified to remove
redundant null-proxy branch, consistent with RequestService. README
wording updated to make clear the Proxy property accepts any IWebProxy
implementation, with WebProxy shown as a concrete example only.

Copilot AI left a comment

Copy link
Copy Markdown

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 updates proxy handling across the library by replacing the AmazonCredential.ProxyAddress string with an IWebProxy-based configuration, allowing richer proxy scenarios (e.g., credentials/authenticated proxies) and simplifying client creation code paths.

Changes:

  • Replace AmazonCredential.ProxyAddress with AmazonCredential.Proxy (IWebProxy) and propagate the new type through token generation and LWA client construction.
  • Simplify RequestService and LWAClient Rest client setup to a single options path (proxy can be null).
  • Update README proxy configuration examples to use IWebProxy / WebProxy.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
Source/FikaAmazonAPI/Services/TokenGeneration.cs Pass IWebProxy through to LWAClient during token refresh.
Source/FikaAmazonAPI/Services/RequestService.cs Use RestClientOptions.Proxy directly from credentials.
Source/FikaAmazonAPI/AmazonSpApiSDK/Runtime/LWAClient.cs Change proxy parameter to IWebProxy and simplify Rest client initialization.
Source/FikaAmazonAPI/AmazonCredential.cs Replace proxy string property with IWebProxy and add a string-based constructor overload.
README.md Document the new IWebProxy-based proxy configuration (including authenticated proxy example).

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

Comment thread Source/FikaAmazonAPI/AmazonSpApiSDK/Runtime/LWAClient.cs Outdated
Comment thread Source/FikaAmazonAPI/Services/TokenGeneration.cs Outdated
Comment thread Source/FikaAmazonAPI/AmazonCredential.cs
Comment thread Source/FikaAmazonAPI/AmazonCredential.cs Outdated
Comment thread Source/FikaAmazonAPI/AmazonCredential.cs Outdated
Comment thread Source/FikaAmazonAPI/AmazonCredential.cs Outdated
- Remove duplicate using directive in LWAClient.cs
- Rename var Client to var client in TokenGeneration.cs (camelCase)
- Add [Obsolete] ProxyAddress property to preserve object-initialiser
  compatibility for existing callers
- Remove the IWebProxy constructor overload to eliminate null ambiguity;
  callers should set the Proxy property directly
- Rename constructor parameter to ProxyAddress to preserve named-argument
  compatibility
- Use IsNullOrWhiteSpace instead of IsNullOrEmpty in proxy string handling
@ProNotion

Copy link
Copy Markdown
Collaborator Author

All six Copilot review comments addressed in commit 045e70c:

  • Duplicate using (LWAClient.cs): removed.
  • var Client casing (TokenGeneration.cs): renamed to client.
  • ProxyAddress property removal (AmazonCredential.cs): added an [Obsolete] ProxyAddress property that wraps Proxy (get/set), so existing object-initialiser callers continue to compile and receive a build warning guiding them toward the new API.
  • Ambiguous null overload (AmazonCredential.cs): removed the IWebProxy constructor to eliminate the ambiguity. Callers supplying a concrete IWebProxy should use the Proxy property via object initialiser (new AmazonCredential { Proxy = ... }).
  • Parameter name (AmazonCredential.cs): constructor parameter renamed to ProxyAddress to match the previous public API and preserve named-argument compatibility.
  • IsNullOrWhiteSpace (AmazonCredential.cs): changed from IsNullOrEmpty to IsNullOrWhiteSpace to handle whitespace-only values consistently.

@sonarqubecloud

Copy link
Copy Markdown

@abuzuhri abuzuhri merged commit ec1e888 into abuzuhri:main Apr 25, 2026
3 checks passed
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