Annotate System.Net.ServicePoint for nullable reference types (#32012)
authorStephen Toub <stoub@microsoft.com>
Mon, 10 Feb 2020 16:04:38 +0000 (08:04 -0800)
committerGitHub <noreply@github.com>
Mon, 10 Feb 2020 16:04:38 +0000 (08:04 -0800)
src/libraries/System.Net.ServicePoint/ref/System.Net.ServicePoint.cs
src/libraries/System.Net.ServicePoint/ref/System.Net.ServicePoint.csproj
src/libraries/System.Net.ServicePoint/src/System.Net.ServicePoint.csproj
src/libraries/System.Net.ServicePoint/src/System/Net/ServicePoint.cs
src/libraries/System.Net.ServicePoint/src/System/Net/ServicePointManager.cs

index 7a81150..8cbf60f 100644 (file)
@@ -23,9 +23,9 @@ namespace System.Net
     {
         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; } }
@@ -55,11 +55,11 @@ namespace System.Net
         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) { }
     }
 }
index cc1b212..8041ebe 100644 (file)
@@ -1,6 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
     <TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks>
+    <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
     <Compile Include="System.Net.ServicePoint.cs" />
index df6365c..1e00240 100644 (file)
@@ -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" />
index b53d0b7..1ff1daf 100644 (file)
@@ -22,7 +22,7 @@ namespace System.Net
             ConnectionName = address.Scheme;
         }
 
-        public BindIPEndPoint BindIPEndPointDelegate { get; set; }
+        public BindIPEndPoint? BindIPEndPointDelegate { get; set; }
 
         public int ConnectionLeaseTimeout
         {
@@ -92,9 +92,9 @@ namespace System.Net
 
         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;
 
index 95ff221..ae7f2ac 100644 (file)
@@ -94,7 +94,7 @@ namespace System.Net
             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; }
 
@@ -104,9 +104,9 @@ namespace System.Net
 
         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)
             {
@@ -120,13 +120,13 @@ namespace System.Net
             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;
@@ -170,7 +170,7 @@ namespace System.Net
             }
         }
 
-        private static bool ProxyAddressIfNecessary(ref Uri address, IWebProxy proxy)
+        private static bool ProxyAddressIfNecessary(ref Uri address, IWebProxy? proxy)
         {
             if (proxy != null && !address.IsLoopback)
             {