Fix additional warnings introduced after fixing inconsistencty (#42750)
authorBuyaa <bunamnan@microsoft.com>
Sat, 26 Sep 2020 00:42:24 +0000 (17:42 -0700)
committerGitHub <noreply@github.com>
Sat, 26 Sep 2020 00:42:24 +0000 (17:42 -0700)
src/libraries/System.Net.Sockets/src/System/Net/Sockets/IOControlKeepAlive.Windows.cs
src/libraries/System.Net.Sockets/src/System/Net/Sockets/TCPListener.cs
src/libraries/System.Security.Cryptography.Pkcs/src/Internal/Cryptography/Pal/Windows/HelpersWindows.cs
src/libraries/System.Security.Cryptography.Pkcs/src/Internal/Cryptography/Pal/Windows/PkcsPalWindows.cs

index 20b70f7..26ad1a2 100644 (file)
@@ -74,6 +74,7 @@ namespace System.Net.Sockets
             byte[] buffer = s_keepAliveValuesBuffer ?? (s_keepAliveValuesBuffer = new byte[3 * sizeof(uint)]);
             ioControlKeepAlive.Fill(buffer);
             int realOptionLength = 0;
+            Debug.Assert(OperatingSystem.IsWindows());
             return SocketPal.WindowsIoctl(handle, unchecked((int)IOControlCode.KeepAliveValues), buffer, null, out realOptionLength);
         }
 
index 34b0cbd..e622257 100644 (file)
@@ -3,6 +3,7 @@
 
 using System.Threading.Tasks;
 using System.Runtime.Versioning;
+using System.Diagnostics;
 
 namespace System.Net.Sockets
 {
@@ -262,6 +263,7 @@ namespace System.Net.Sockets
             return listener;
         }
 
+        [SupportedOSPlatform("windows")]
         private void SetIPProtectionLevel(bool allowed)
             => _serverSocket!.SetIPProtectionLevel(allowed ? IPProtectionLevel.Unrestricted : IPProtectionLevel.EdgeRestricted);
 
@@ -276,6 +278,7 @@ namespace System.Net.Sockets
 
             if (_allowNatTraversal != null)
             {
+                Debug.Assert(OperatingSystem.IsWindows());
                 SetIPProtectionLevel(_allowNatTraversal.GetValueOrDefault());
                 _allowNatTraversal = null; // Reset value to avoid affecting more sockets
             }
index 48c8ba9..ac5a28e 100644 (file)
@@ -412,6 +412,7 @@ namespace Internal.Cryptography.Pal.Windows
                 CryptoPool.Return(rented, maxClear);
             }
 
+            Debug.Assert(RuntimeInformation.IsOSPlatform(OSPlatform.Windows));
             return new CspParameters(provType)
             {
                 Flags = provFlags,
index 19a47ee..a5ec578 100644 (file)
@@ -166,6 +166,7 @@ namespace Internal.Cryptography.Pal.Windows
                 // 3) PNSE.
                 // 4) Defer to cert.Get{R|D}SAPrivateKey if not silent, throw otherwise.
                 CspParameters cspParams = handle.GetProvParameters();
+                Debug.Assert(RuntimeInformation.IsOSPlatform(OSPlatform.Windows));
                 Debug.Assert((cspParams.Flags & CspProviderFlags.UseExistingKey) != 0);
                 cspParams.KeyNumber = (int)keySpec;