Skip to content

Commit

Permalink
Annotate System.Net.ServicePoint for nullable reference types (dotnet…
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentoub authored Feb 10, 2020
1 parent bdcea81 commit 99d9765
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public partial class ServicePoint
{
internal ServicePoint() { }
public System.Uri Address { get { throw null; } }
public System.Net.BindIPEndPoint BindIPEndPointDelegate { get { throw null; } set { } }
public System.Security.Cryptography.X509Certificates.X509Certificate Certificate { get { throw null; } }
public System.Security.Cryptography.X509Certificates.X509Certificate ClientCertificate { get { throw null; } }
public System.Net.BindIPEndPoint? BindIPEndPointDelegate { get { throw null; } set { } }
public System.Security.Cryptography.X509Certificates.X509Certificate? Certificate { get { throw null; } }
public System.Security.Cryptography.X509Certificates.X509Certificate? ClientCertificate { get { throw null; } }
public int ConnectionLeaseTimeout { get { throw null; } set { } }
public int ConnectionLimit { get { throw null; } set { } }
public string ConnectionName { get { throw null; } }
Expand Down Expand Up @@ -55,11 +55,11 @@ internal ServicePointManager() { }
public static int MaxServicePoints { get { throw null; } set { } }
public static bool ReusePort { get { throw null; } set { } }
public static System.Net.SecurityProtocolType SecurityProtocol { get { throw null; } set { } }
public static System.Net.Security.RemoteCertificateValidationCallback ServerCertificateValidationCallback { get { throw null; } set { } }
public static System.Net.Security.RemoteCertificateValidationCallback? ServerCertificateValidationCallback { get { throw null; } set { } }
public static bool UseNagleAlgorithm { get { throw null; } set { } }
public static System.Net.ServicePoint FindServicePoint(string uriString, System.Net.IWebProxy proxy) { throw null; }
public static System.Net.ServicePoint FindServicePoint(string uriString, System.Net.IWebProxy? proxy) { throw null; }
public static System.Net.ServicePoint FindServicePoint(System.Uri address) { throw null; }
public static System.Net.ServicePoint FindServicePoint(System.Uri address, System.Net.IWebProxy proxy) { throw null; }
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) { }
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Include="System.Net.ServicePoint.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<NoWarn>$(NoWarn);CA5364</NoWarn>
<TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup Condition="'$(IsPartialFacadeAssembly)' != 'true'">
<Compile Include="System\Net\BindIPEndPoint.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal ServicePoint(Uri address)
ConnectionName = address.Scheme;
}

public BindIPEndPoint BindIPEndPointDelegate { get; set; }
public BindIPEndPoint? BindIPEndPointDelegate { get; set; }

public int ConnectionLeaseTimeout
{
Expand Down Expand Up @@ -92,9 +92,9 @@ public int ConnectionLimit

public int CurrentConnections => 0;

public X509Certificate Certificate { get; internal set; }
public X509Certificate? Certificate { get; internal set; }

public X509Certificate ClientCertificate { get; internal set; }
public X509Certificate? ClientCertificate { get; internal set; }

public bool SupportsPipelining { get; internal set; } = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static int DnsRefreshTimeout
set { s_dnsRefreshTimeout = Math.Max(-1, value); }
}

public static RemoteCertificateValidationCallback ServerCertificateValidationCallback { get; set; }
public static RemoteCertificateValidationCallback? ServerCertificateValidationCallback { get; set; }

public static bool ReusePort { get; set; }

Expand All @@ -104,9 +104,9 @@ public static int DnsRefreshTimeout

public static ServicePoint FindServicePoint(Uri address) => FindServicePoint(address, null);

public static ServicePoint FindServicePoint(string uriString, IWebProxy proxy) => FindServicePoint(new Uri(uriString), proxy);
public static ServicePoint FindServicePoint(string uriString, IWebProxy? proxy) => FindServicePoint(new Uri(uriString), proxy);

public static ServicePoint FindServicePoint(Uri address, IWebProxy proxy)
public static ServicePoint FindServicePoint(Uri address, IWebProxy? proxy)
{
if (address == null)
{
Expand All @@ -120,13 +120,13 @@ public static ServicePoint FindServicePoint(Uri address, IWebProxy proxy)
string tableKey = MakeQueryString(address, isProxyServicePoint);

// Get an existing service point or create a new one
ServicePoint sp; // outside of loop to keep references alive from one iteration to the next
ServicePoint? sp; // outside of loop to keep references alive from one iteration to the next
while (true)
{
// The table maps lookup key to a weak reference to a service point. If the table
// contains a weak ref for the key and that weak ref points to a valid ServicePoint,
// simply return it (after updating its last used time).
WeakReference<ServicePoint> wr;
WeakReference<ServicePoint>? wr;
if (s_servicePointTable.TryGetValue(tableKey, out wr) && wr.TryGetTarget(out sp))
{
sp.IdleSince = DateTime.Now;
Expand Down Expand Up @@ -170,7 +170,7 @@ public static ServicePoint FindServicePoint(Uri address, IWebProxy proxy)
}
}

private static bool ProxyAddressIfNecessary(ref Uri address, IWebProxy proxy)
private static bool ProxyAddressIfNecessary(ref Uri address, IWebProxy? proxy)
{
if (proxy != null && !address.IsLoopback)
{
Expand Down

0 comments on commit 99d9765

Please sign in to comment.