Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 5.6k
Backport XML documentation for WebProxy and IWebProxyScript#124396
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
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9981396
Initial plan
Copilot faeadd1
Add XML documentation to WebProxy and IWebProxyScript
Copilot f1025e9
Fix typo and resolve XML documentation reference errors
Copilot 0287cd0
Address PR review feedback: Update csproj, fix crefs, simplify param …
Copilot 5b2e4c9
Address bot review feedback: Remove incorrect exceptions, update obso…
Copilot cb92aec
Apply suggestions from code review
gewarren 3be15ea
Remove duplicate exception tag from GetObjectData
Copilot 0b61055
Remove repetitive constructor remarks and .NET Framework-specific par…
Copilot 7e0bea6
Simplify type-level remarks and remove IWebProxyScript.Run remarks
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1 src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23 src/libraries/System.Net.WebProxy/src/System/Net/IWebProxyScript.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
149 changes: 149 additions & 0 deletions
149 src/libraries/System.Net.WebProxy/src/System/Net/WebProxy.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -13,19 +13,59 @@ | ||
| namespace System.Net | ||
| { | ||
| /// <summary> | ||
| /// Contains HTTP proxy settings for the <see cref="T:System.Net.Http.HttpClient" /> class. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// The <see cref="WebProxy"/> class contains the proxy settings that <see cref="T:System.Net.Http.HttpClient"/> instances use to determine whether a Web proxy is used to send requests. | ||
| /// The <see cref="WebProxy"/> class is the base implementation of the <see cref="IWebProxy"/> interface. | ||
| /// </remarks> | ||
| public partial class WebProxy : IWebProxy, ISerializable | ||
| { | ||
| private ChangeTrackingArrayList? _bypassList; | ||
| private Regex[]? _regexBypassList; | ||
| /// <summary> | ||
| /// Initializes an empty instance of the <see cref="WebProxy" /> class. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// <para> | ||
| /// The parameterless constructor initializes an empty instance of the <see cref="WebProxy"/> class with the <see cref="Address"/> property set to <see langword="null"/>. | ||
| /// </para> | ||
| /// <para> | ||
| /// When the <see cref="Address"/> property is <see langword="null"/>, the <see cref="IsBypassed"/> method returns <see langword="true"/> and the <see cref="GetProxy"/> method returns the destination address. | ||
| /// </para> | ||
| /// </remarks> | ||
| public WebProxy() : this((Uri?)null, false, null, null) { } | ||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="WebProxy" /> class from the specified <see cref="Uri" /> instance. | ||
| /// </summary> | ||
| /// <param name="Address">The address of the proxy server.</param> | ||
| public WebProxy(Uri? Address) : this(Address, false, null, null) { } | ||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="WebProxy" /> class with the <see cref="Uri" /> instance and bypass setting. | ||
| /// </summary> | ||
| /// <param name="Address">A <see cref="Uri" /> instance that contains the address of the proxy server.</param> | ||
| /// <param name="BypassOnLocal"><see langword="true" /> to bypass the proxy for local addresses; otherwise, <see langword="false" />.</param> | ||
| public WebProxy(Uri? Address, bool BypassOnLocal) : this(Address, BypassOnLocal, null, null) { } | ||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="WebProxy" /> class with the specified <see cref="Uri" /> instance, bypass setting, and list of URIs to bypass. | ||
| /// </summary> | ||
| /// <param name="Address">A <see cref="Uri" /> instance that contains the address of the proxy server.</param> | ||
| /// <param name="BypassOnLocal"><see langword="true" /> to bypass the proxy for local addresses; otherwise, <see langword="false" />.</param> | ||
| /// <param name="BypassList">An array of regular expression strings that contains the URIs of the servers to bypass.</param> | ||
| public WebProxy(Uri? Address, bool BypassOnLocal, [StringSyntax(StringSyntaxAttribute.Regex, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)] string[]? BypassList) : this(Address, BypassOnLocal, BypassList, null) { } | ||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="WebProxy" /> class with the specified <see cref="Uri" /> instance, bypass setting, list of URIs to bypass, and credentials. | ||
| /// </summary> | ||
| /// <param name="Address">A <see cref="Uri" /> instance that contains the address of the proxy server.</param> | ||
| /// <param name="BypassOnLocal"><see langword="true" /> to bypass the proxy for local addresses; otherwise, <see langword="false" />.</param> | ||
| /// <param name="BypassList">An array of regular expression strings that contains the URIs of the servers to bypass.</param> | ||
| /// <param name="Credentials">An <see cref="ICredentials" /> instance to submit to the proxy server for authentication.</param> | ||
| public WebProxy(Uri? Address, bool BypassOnLocal, [StringSyntax(StringSyntaxAttribute.Regex, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)] string[]? BypassList, ICredentials? Credentials) | ||
| { | ||
| this.Address = Address; | ||
| @@ -38,35 +78,88 @@ public WebProxy(Uri? Address, bool BypassOnLocal, [StringSyntax(StringSyntaxAttr | ||
| } | ||
| } | ||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="WebProxy" /> class with the specified host and port number. | ||
| /// </summary> | ||
| /// <param name="Host">The name of the proxy host.</param> | ||
| /// <param name="Port">The port number on <paramref name="Host" /> to use.</param> | ||
| /// <exception cref="UriFormatException">The URI formed by combining <paramref name="Host" /> and <paramref name="Port" /> is not a valid URI.</exception> | ||
| /// <remarks> | ||
| /// The <see cref="WebProxy"/> instance is initialized with the <see cref="Address"/> property set to a <see cref="Uri"/> instance of the form <c>http://</c><paramref name="Host"/><c>:</c><paramref name="Port"/>. | ||
| /// </remarks> | ||
| public WebProxy(string Host, int Port) | ||
| : this(CreateProxyUri(Host, Port), false, null, null) | ||
| { | ||
| } | ||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="WebProxy" /> class with the specified URI. | ||
| /// </summary> | ||
| /// <param name="Address">The URI of the proxy server.</param> | ||
| /// <exception cref="UriFormatException"><paramref name="Address" /> is an invalid URI.</exception> | ||
| public WebProxy(string? Address) | ||
| : this(CreateProxyUri(Address), false, null, null) | ||
| { | ||
| } | ||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="WebProxy" /> class with the specified URI and bypass setting. | ||
| /// </summary> | ||
| /// <param name="Address">The URI of the proxy server.</param> | ||
| /// <param name="BypassOnLocal"><see langword="true" /> to bypass the proxy for local addresses; otherwise, <see langword="false" />.</param> | ||
| /// <exception cref="UriFormatException"><paramref name="Address" /> is an invalid URI.</exception> | ||
| public WebProxy(string? Address, bool BypassOnLocal) | ||
| : this(CreateProxyUri(Address), BypassOnLocal, null, null) | ||
| { | ||
| } | ||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="WebProxy" /> class with the specified URI, bypass setting, and list of URIs to bypass. | ||
| /// </summary> | ||
| /// <param name="Address">The URI of the proxy server.</param> | ||
| /// <param name="BypassOnLocal"><see langword="true" /> to bypass the proxy for local addresses; otherwise, <see langword="false" />.</param> | ||
| /// <param name="BypassList">An array of regular expression strings that contain the URIs of the servers to bypass.</param> | ||
| /// <exception cref="UriFormatException"><paramref name="Address" /> is an invalid URI.</exception> | ||
| public WebProxy(string? Address, bool BypassOnLocal, [StringSyntax(StringSyntaxAttribute.Regex, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)] string[]? BypassList) | ||
| : this(CreateProxyUri(Address), BypassOnLocal, BypassList, null) | ||
| { | ||
| } | ||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="WebProxy" /> class with the specified URI, bypass setting, list of URIs to bypass, and credentials. | ||
| /// </summary> | ||
| /// <param name="Address">The URI of the proxy server.</param> | ||
| /// <param name="BypassOnLocal"><see langword="true" /> to bypass the proxy for local addresses; otherwise, <see langword="false" />.</param> | ||
| /// <param name="BypassList">An array of regular expression strings that contains the URIs of the servers to bypass.</param> | ||
| /// <param name="Credentials">An <see cref="ICredentials" /> instance to submit to the proxy server for authentication.</param> | ||
| /// <exception cref="UriFormatException"><paramref name="Address" /> is an invalid URI.</exception> | ||
| public WebProxy(string? Address, bool BypassOnLocal, [StringSyntax(StringSyntaxAttribute.Regex, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)] string[]? BypassList, ICredentials? Credentials) | ||
| : this(CreateProxyUri(Address), BypassOnLocal, BypassList, Credentials) | ||
| { | ||
| } | ||
| /// <summary> | ||
| /// Gets or sets the address of the proxy server. | ||
| /// </summary> | ||
| /// <value> | ||
| /// A <see cref="Uri"/> instance that contains the address of the proxy server. | ||
| /// </value> | ||
| public Uri? Address { get; set; } | ||
| /// <summary> | ||
| /// Gets or sets a value that indicates whether to bypass the proxy server for local addresses. | ||
| /// </summary> | ||
| /// <value> | ||
| /// <see langword="true"/> to bypass the proxy server for local addresses; otherwise, <see langword="false"/>. The default value is <see langword="false"/>. | ||
| /// </value> | ||
| public bool BypassProxyOnLocal { get; set; } | ||
| /// <summary> | ||
| /// Gets or sets an array of addresses that do not use the proxy server. | ||
| /// </summary> | ||
| /// <value> | ||
| /// An array of regular expression strings that contains the URIs of servers that should not use the proxy server when accessed. | ||
| /// </value> | ||
| [AllowNull] | ||
| public string[] BypassList | ||
| { | ||
| @@ -88,16 +181,42 @@ public string[] BypassList | ||
| } | ||
| } | ||
| /// <summary> | ||
| /// Gets or sets an <see cref="ArrayList"/> of addresses that do not use the proxy server. | ||
| /// </summary> | ||
| /// <value> | ||
| /// An <see cref="ArrayList"/> that contains a list of regular expressions that represents URIs that do not use the proxy server when accessed. | ||
| /// </value> | ||
| public ArrayList BypassArrayList => _bypassList ??= new ChangeTrackingArrayList(); | ||
| /// <summary> | ||
| /// Gets or sets the credentials to submit to the proxy server for authentication. | ||
| /// </summary> | ||
| /// <value> | ||
| /// An <see cref="ICredentials"/> instance that contains the credentials to submit to the proxy server for authentication. | ||
| /// </value> | ||
| public ICredentials? Credentials { get; set; } | ||
| /// <summary> | ||
| /// Gets or sets a value that controls whether the <see cref="CredentialCache.DefaultCredentials"/> are sent with requests. | ||
| /// </summary> | ||
| /// <value> | ||
| /// <see langword="true"/> if the default credentials are used; otherwise, <see langword="false"/>. The default value is <see langword="false"/>. | ||
| /// </value> | ||
| public bool UseDefaultCredentials | ||
| { | ||
| get => Credentials == CredentialCache.DefaultCredentials; | ||
| set => Credentials = value ? CredentialCache.DefaultCredentials : null; | ||
| } | ||
| /// <summary> | ||
| /// Returns the URI of a proxy. | ||
| /// </summary> | ||
| /// <param name="destination">The <see cref="Uri"/> instance of the requested Internet resource.</param> | ||
| /// <returns> | ||
| /// The <see cref="Uri"/> instance of the Internet resource, if the resource is on the bypass list; otherwise, the <see cref="Uri"/> instance of the proxy. | ||
| /// </returns> | ||
| /// <exception cref="ArgumentNullException">The <paramref name="destination"/> parameter is <see langword="null"/>.</exception> | ||
| public Uri? GetProxy(Uri destination) | ||
| { | ||
| ArgumentNullException.ThrowIfNull(destination); | ||
| @@ -192,6 +311,14 @@ private bool IsMatchInBypassList(Uri input) | ||
| return false; | ||
| } | ||
| /// <summary> | ||
| /// Indicates whether to use the proxy server for the specified host. | ||
| /// </summary> | ||
| /// <param name="host">The <see cref="Uri"/> instance of the host to check for proxy use.</param> | ||
| /// <returns> | ||
| /// <see langword="true"/> if the proxy server should not be used for <paramref name="host"/>; otherwise, <see langword="false"/>. | ||
| /// </returns> | ||
| /// <exception cref="ArgumentNullException">The <paramref name="host"/> parameter is <see langword="null"/>.</exception> | ||
| public bool IsBypassed(Uri host) | ||
| { | ||
| ArgumentNullException.ThrowIfNull(host); | ||
| @@ -202,6 +329,15 @@ public bool IsBypassed(Uri host) | ||
| IsMatchInBypassList(host); | ||
| } | ||
| /// <summary> | ||
| /// Initializes an instance of the <see cref="WebProxy" /> class using previously serialized content. | ||
| /// </summary> | ||
| /// <param name="serializationInfo">The serialization data.</param> | ||
| /// <param name="streamingContext">The context for the serialized data.</param> | ||
| /// <exception cref="PlatformNotSupportedException">This method is not supported and will always throw <see cref="PlatformNotSupportedException"/>.</exception> | ||
| /// <remarks> | ||
| /// This method is called by the system to deserialize a <see cref="WebProxy"/> instance; applications do not call it. | ||
| /// </remarks> | ||
gewarren marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] | ||
| [EditorBrowsable(EditorBrowsableState.Never)] | ||
| protected WebProxy(SerializationInfo serializationInfo, StreamingContext streamingContext) => | ||
| @@ -210,9 +346,22 @@ protected WebProxy(SerializationInfo serializationInfo, StreamingContext streami | ||
| void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) => | ||
| throw new PlatformNotSupportedException(); | ||
| /// <summary> | ||
| /// Populates a <see cref="SerializationInfo"/> with the data that is needed to serialize the target object. | ||
| /// </summary> | ||
| /// <param name="serializationInfo">The <see cref="SerializationInfo"/> to populate with data.</param> | ||
| /// <param name="streamingContext">A <see cref="StreamingContext"/> that specifies the destination for this serialization.</param> | ||
gewarren marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| /// <exception cref="PlatformNotSupportedException">This method is not supported and will always throw <see cref="PlatformNotSupportedException"/>.</exception> | ||
| protected virtual void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) => | ||
| throw new PlatformNotSupportedException(); | ||
| /// <summary> | ||
| /// Returns the proxy information configured by the system. | ||
| /// </summary> | ||
| /// <returns> | ||
| /// A <see cref="WebProxy"/> instance that contains the nondynamic proxy settings from Internet options. | ||
| /// </returns> | ||
| /// <exception cref="PlatformNotSupportedException">This method is not supported on .NET Core and will always throw <see cref="PlatformNotSupportedException"/>.</exception> | ||
| [Obsolete("WebProxy.GetDefaultProxy has been deprecated. Use the proxy selected for you by default.")] | ||
| public static WebProxy GetDefaultProxy() => | ||
| // The .NET Framework here returns a proxy that fetches IE settings and | ||
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.