Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/libraries/Common/src/System/Obsoletions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@ internal static class Obsoletions

internal const string CodeBaseMessage = "Use Location instead.";
internal const string CodeBaseDiagId = "SYSLIB0012";

internal const string WebRequestMessage = "Use HttpClient api instead.";
Comment thread
aik-jahoda marked this conversation as resolved.
Outdated
internal const string WebRequestDiagId = "SYSLIB0013";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ internal FileWebRequest(Uri uri)
}

[Obsolete("Serialization is obsoleted for this type. https://go.microsoft.com/fwlink/?linkid=14202")]
[Obsolete(Obsoletions.WebRequestMessage, DiagnosticId = Obsoletions.WebRequestDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HttpClient does not support file URIs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have an alternative api for fie URIs?

It will warn even I remove this line if the FileWebRequest is created by WebRequest.Create() / CreateDefault.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The closest API we have is for a user to call Uri.LocalPath and use File.Open. It should still be obsoleted, but a message of "use HttpClient" doesn't make sense.

protected FileWebRequest(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext)
{
throw new PlatformNotSupportedException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,13 @@ public bool AreParametersAcceptableForCaching()
private const string ContinueHeader = "100-continue";
private const string ChunkedHeader = "chunked";

[Obsolete(Obsoletions.WebRequestMessage, DiagnosticId = Obsoletions.WebRequestDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
public HttpWebRequest()
{
}

[Obsolete("Serialization is obsoleted for this type. https://go.microsoft.com/fwlink/?linkid=14202")]
[Obsolete(Obsoletions.WebRequestMessage, DiagnosticId = Obsoletions.WebRequestDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
protected HttpWebRequest(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext)
{
throw new PlatformNotSupportedException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ public WebRequestPrefixElement(string prefix, IWebRequestCreate creator)

internal const int DefaultTimeoutMilliseconds = 100 * 1000;

[Obsolete(Obsoletions.WebRequestMessage, DiagnosticId = Obsoletions.WebRequestDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
protected WebRequest() { }

[Obsolete(Obsoletions.WebRequestMessage, DiagnosticId = Obsoletions.WebRequestDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
protected WebRequest(SerializationInfo serializationInfo, StreamingContext streamingContext)
{
throw new PlatformNotSupportedException();
Expand Down Expand Up @@ -140,6 +142,7 @@ private static WebRequest Create(Uri requestUri, bool useUriBase)
//
// Returns:
// Newly created WebRequest.
[Obsolete(Obsoletions.WebRequestMessage, DiagnosticId = Obsoletions.WebRequestDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
public static WebRequest Create(string requestUriString)
{
if (requestUriString == null)
Expand All @@ -160,6 +163,7 @@ public static WebRequest Create(string requestUriString)
//
// Returns:
// Newly created WebRequest.
[Obsolete(Obsoletions.WebRequestMessage, DiagnosticId = Obsoletions.WebRequestDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
public static WebRequest Create(Uri requestUri)
{
if (requestUri == null)
Expand All @@ -181,6 +185,7 @@ public static WebRequest Create(Uri requestUri)
//
// Returns:
// Newly created WebRequest.
[Obsolete(Obsoletions.WebRequestMessage, DiagnosticId = Obsoletions.WebRequestDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
public static WebRequest CreateDefault(Uri requestUri)
{
if (requestUri == null)
Expand All @@ -191,6 +196,7 @@ public static WebRequest CreateDefault(Uri requestUri)
return Create(requestUri, true);
}

[Obsolete(Obsoletions.WebRequestMessage, DiagnosticId = Obsoletions.WebRequestDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
public static HttpWebRequest CreateHttp(string requestUriString)
{
if (requestUriString == null)
Expand All @@ -200,6 +206,7 @@ public static HttpWebRequest CreateHttp(string requestUriString)
return CreateHttp(new Uri(requestUriString));
}

[Obsolete(Obsoletions.WebRequestMessage, DiagnosticId = Obsoletions.WebRequestDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
public static HttpWebRequest CreateHttp(Uri requestUri)
{
if (requestUri == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,13 @@ public static int DnsRefreshTimeout

public static EncryptionPolicy EncryptionPolicy { get; } = EncryptionPolicy.RequireEncryption;

[Obsolete(Obsoletions.WebRequestMessage, DiagnosticId = Obsoletions.WebRequestDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
public static ServicePoint FindServicePoint(Uri address) => FindServicePoint(address, null);

[Obsolete(Obsoletions.WebRequestMessage, DiagnosticId = Obsoletions.WebRequestDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
public static ServicePoint FindServicePoint(string uriString, IWebProxy? proxy) => FindServicePoint(new Uri(uriString), proxy);

[Obsolete(Obsoletions.WebRequestMessage, DiagnosticId = Obsoletions.WebRequestDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
public static ServicePoint FindServicePoint(Uri address, IWebProxy? proxy)
{
if (address == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class WebClient : Component
private SendOrPostCallback? _reportDownloadProgressChanged;
private SendOrPostCallback? _reportUploadProgressChanged;

[Obsolete(Obsoletions.WebRequestMessage, DiagnosticId = Obsoletions.WebRequestDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
public WebClient()
{
// We don't know if derived types need finalizing, but WebClient doesn't.
Expand Down