Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
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 = "Assembly.CodeBase and Assembly.EscapedCodeBase are only included for .NET Framework compatibility. Use Assembly.Location instead.";
internal const string CodeBaseDiagId = "SYSLIB0012";

internal const string WebRequestMessage = "Use HttpClient instead.";
internal const string WebRequestDiagId = "SYSLIB0013";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,9 @@ public ServicePoint ServicePoint
// This has some subtle impact on behavior, e.g. the returned ServicePoint's Address property will
// be usable, whereas in .NET Framework it throws an exception that "This property is not supported for
// protocols that do not use URI."
#pragma warning disable SYSLIB0013
return _servicePoint ??= ServicePointManager.FindServicePoint(new Uri("mailto:" + _host + ":" + _port));
#pragma warning restore SYSLIB0013
}
}

Expand Down
11 changes: 10 additions & 1 deletion src/libraries/System.Net.Requests/ref/System.Net.Requests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ public enum FtpStatusCode
}
public sealed partial class FtpWebRequest : System.Net.WebRequest
{
#pragma warning disable SYSLIB0013
internal FtpWebRequest() { }
#pragma warning restore SYSLIB0013
public System.Security.Cryptography.X509Certificates.X509CertificateCollection ClientCertificates { get { throw null; } set { } }
public override string? ConnectionGroupName { get { throw null; } set { } }
public override long ContentLength { get { throw null; } set { } }
Expand Down Expand Up @@ -171,7 +173,7 @@ public GlobalProxySelection() { }
public delegate void HttpContinueDelegate(int StatusCode, System.Net.WebHeaderCollection httpHeaders);
public partial class HttpWebRequest : System.Net.WebRequest, System.Runtime.Serialization.ISerializable
{
[System.ObsoleteAttribute("Serialization is obsoleted for this type. https://go.microsoft.com/fwlink/?linkid=14202")]
[System.ObsoleteAttribute("Use HttpClient instead.", DiagnosticId = "SYSLIB0013", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
protected HttpWebRequest(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { }
public string? Accept { get { throw null; } set { } }
public System.Uri Address { get { throw null; } }
Expand Down Expand Up @@ -333,7 +335,9 @@ public enum WebExceptionStatus
}
public abstract partial class WebRequest : System.MarshalByRefObject, System.Runtime.Serialization.ISerializable
{
[System.ObsoleteAttribute("Use HttpClient instead.", DiagnosticId = "SYSLIB0013", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
protected WebRequest() { }
[System.ObsoleteAttribute("Use HttpClient instead.", DiagnosticId = "SYSLIB0013", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
protected WebRequest(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { }
public System.Net.Security.AuthenticationLevel AuthenticationLevel { get { throw null; } set { } }
public virtual System.Net.Cache.RequestCachePolicy? CachePolicy { get { throw null; } set { } }
Expand All @@ -354,10 +358,15 @@ protected WebRequest(System.Runtime.Serialization.SerializationInfo serializatio
public virtual void Abort() { }
public virtual System.IAsyncResult BeginGetRequestStream(System.AsyncCallback? callback, object? state) { throw null; }
public virtual System.IAsyncResult BeginGetResponse(System.AsyncCallback? callback, object? state) { throw null; }
[System.ObsoleteAttribute("Use HttpClient instead.", DiagnosticId = "SYSLIB0013", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
public static System.Net.WebRequest Create(string requestUriString) { throw null; }
[System.ObsoleteAttribute("Use HttpClient instead.", DiagnosticId = "SYSLIB0013", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
public static System.Net.WebRequest Create(System.Uri requestUri) { throw null; }
[System.ObsoleteAttribute("Use HttpClient instead.", DiagnosticId = "SYSLIB0013", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
public static System.Net.WebRequest CreateDefault(System.Uri requestUri) { throw null; }
[System.ObsoleteAttribute("Use HttpClient instead.", DiagnosticId = "SYSLIB0013", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
public static System.Net.HttpWebRequest CreateHttp(string requestUriString) { throw null; }
[System.ObsoleteAttribute("Use HttpClient instead.", DiagnosticId = "SYSLIB0013", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
public static System.Net.HttpWebRequest CreateHttp(System.Uri requestUri) { throw null; }
public virtual System.IO.Stream EndGetRequestStream(System.IAsyncResult asyncResult) { throw null; }
public virtual System.Net.WebResponse EndGetResponse(System.IAsyncResult asyncResult) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class FileWebRequest : WebRequest, ISerializable
private bool _syncHint;
private int _aborted;

#pragma warning disable SYSLIB0013
internal FileWebRequest(Uri uri)
{
if (uri.Scheme != (object)Uri.UriSchemeFile)
Expand All @@ -40,6 +41,7 @@ protected FileWebRequest(SerializationInfo serializationInfo, StreamingContext s
{
throw new PlatformNotSupportedException();
}
#pragma warning restore SYSLIB0013

void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) =>
GetObjectData(serializationInfo, streamingContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,9 @@ public override string? ConnectionGroupName
}
}

#pragma warning disable SYSLIB0013
public ServicePoint ServicePoint => _servicePoint ??= ServicePointManager.FindServicePoint(_uri);
#pragma warning restore SYSLIB0013

internal bool Aborted
{
Expand All @@ -489,7 +491,9 @@ internal bool Aborted
}
}

#pragma warning disable SYSLIB0013
internal FtpWebRequest(Uri uri)
#pragma warning restore SYSLIB0013
{
if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, uri);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,12 @@ 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 All @@ -180,10 +181,12 @@ protected override void GetObjectData(SerializationInfo serializationInfo, Strea
throw new PlatformNotSupportedException();
}

#pragma warning disable SYSLIB0013
internal HttpWebRequest(Uri uri)
{
_requestUri = uri;
}
#pragma warning restore SYSLIB0013

private void SetSpecialHeaders(string HeaderName, string? value)
{
Expand Down Expand Up @@ -753,7 +756,9 @@ public HttpContinueDelegate? ContinueDelegate
}
}

#pragma warning disable SYSLIB0013
public ServicePoint ServicePoint => _servicePoint ??= ServicePointManager.FindServicePoint(Address, Proxy);
#pragma warning restore SYSLIB0013

public RemoteCertificateValidationCallback? ServerCertificateValidationCallback { get; set; }

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 @@ -4,7 +4,9 @@
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
<TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks>
<DefineConstants>$(DefineConstants);NETSTANDARD</DefineConstants>
<IgnoreForCI Condition="'$(TargetOS)' == 'Browser'">true</IgnoreForCI>
<IgnoreForCI Condition="'$(T
argetOS)' == 'Browser'">true</IgnoreForCI>

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.

Looks like there is an unnecessery weird line break:

'$(T
argetOS)'

<NoWarn>$(NoWarn);SYSLIB0013</NoWarn>
</PropertyGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@ internal ServicePointManager() { }
public static System.Net.SecurityProtocolType SecurityProtocol { get { throw null; } set { } }
public static System.Net.Security.RemoteCertificateValidationCallback? ServerCertificateValidationCallback { get { throw null; } set { } }
public static bool UseNagleAlgorithm { get { throw null; } set { } }
[System.ObsoleteAttribute("Use HttpClient instead.", DiagnosticId = "SYSLIB0013", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
public static System.Net.ServicePoint FindServicePoint(string uriString, System.Net.IWebProxy? proxy) { throw null; }
[System.ObsoleteAttribute("Use HttpClient instead.", DiagnosticId = "SYSLIB0013", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
public static System.Net.ServicePoint FindServicePoint(System.Uri address) { throw null; }
[System.ObsoleteAttribute("Use HttpClient instead.", DiagnosticId = "SYSLIB0013", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
public static System.Net.ServicePoint FindServicePoint(System.Uri address, System.Net.IWebProxy? proxy) { throw null; }
public static void SetTcpKeepAlive(bool enabled, int keepAliveTime, int keepAliveInterval) { }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<Compile Include="System\Net\SecurityProtocolType.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="$(CommonPath)System\Obsoletions.cs"
Link="Common\System\Obsoletions.cs" />
<Reference Include="System.Collections.Concurrent" />
<Reference Include="System.Net.Primitives" />
<Reference Include="System.Net.Security" />
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 @@ -2,9 +2,10 @@
<PropertyGroup>
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
<TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks>
<NoWarn>$(NoWarn);SYSLIB0013</NoWarn>
</PropertyGroup>
<ItemGroup>
<Compile Include="ServicePointManagerTest.cs" />
<Compile Include="TlsSystemDefault.cs" />
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public partial class UploadValuesCompletedEventArgs : System.ComponentModel.Asyn
public delegate void UploadValuesCompletedEventHandler(object sender, System.Net.UploadValuesCompletedEventArgs e);
public partial class WebClient : System.ComponentModel.Component
{
[System.ObsoleteAttribute("Use HttpClient instead.", DiagnosticId = "SYSLIB0013", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
public WebClient() { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.ObsoleteAttribute("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
Link="Common\System\HexConverter.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="$(CommonPath)System\Obsoletions.cs"
Link="Common\System\Obsoletions.cs" />
<Reference Include="System.Collections.Specialized" />
<Reference Include="System.ComponentModel.EventBasedAsync" />
<Reference Include="System.ComponentModel.Primitives" />
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 Expand Up @@ -216,7 +217,10 @@ public IWebProxy? Proxy

protected virtual WebRequest GetWebRequest(Uri address)
{
#pragma warning disable SYSLIB0013
WebRequest request = WebRequest.Create(address);
#pragma warning restore SYSLIB0013

CopyHeadersTo(request);

if (Credentials != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks>
<DefineConstants>$(DefineConstants);NETSTANDARD</DefineConstants>
<NoWarn>$(NoWarn);SYSLIB0013</NoWarn>
</PropertyGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,9 @@ private void LoadSync()
// setup the http stream
if (_uri != null && !_uri.IsFile && _stream == null)
{
#pragma warning disable SYSLIB0013
WebRequest webRequest = WebRequest.Create(_uri);
#pragma warning restore SYSLIB0013
webRequest.Timeout = LoadTimeout;

WebResponse webResponse;
Expand Down Expand Up @@ -479,7 +481,9 @@ private async Task CopyStreamAsync(CancellationToken cancellationToken)
// setup the http stream
if (_uri != null && !_uri.IsFile && _stream == null)
{
#pragma warning disable SYSLIB0013
WebRequest webRequest = WebRequest.Create(_uri);
#pragma warning restore SYSLIB0013
using (cancellationToken.Register(r => ((WebRequest)r).Abort(), webRequest))
{
WebResponse webResponse = await webRequest.GetResponseAsync().ConfigureAwait(false);
Expand Down