mark Windows-specific APIs as such (#39265)
authorAdam Sitnik <adam.sitnik@gmail.com>
Fri, 17 Jul 2020 13:11:50 +0000 (15:11 +0200)
committerGitHub <noreply@github.com>
Fri, 17 Jul 2020 13:11:50 +0000 (15:11 +0200)
* move all OSPlatformAttributes to a single file so they can be easily referenced in < .NET 5 libraries

* Adds System.Runtime.Versioning*Platform* annotation attributes to < .NET 5 builds

* introduce MinimiumSupportedWindowsPlatform

* introduce IsWindowsSpecific setting that adds MinimumOSPlatform attribute for Windows Specific libraries

* mark all Windows-specific libraries as such

* annotate Windows-specific System.Console methods and properites

* annotate Windows-specific DpapiProtectedConfigurationProvider type

* annotate throwing Windows-specific APIs from System.Diagnostics.Process namespace

* annotate throwing Windows-specific APIs from System.IO.MemoryMappedFiles namespace

* annotate Windows-specific APIs from System.IO.Pipes namespace

* the new attributes should support enums

* annotate Windows-specific APIs from HttpListenerTimeoutManager class

* annotate Windows-specific APIs from System.Net.Sockets namespace

* annotate Windows-specific APIs from System.Runtime.InteropServices namespace

* annotate Windows-specific APIs from System.Security.Cryptography.Csp namespace

* annotate Windows-specific APIs from System.Security.Cryptography.X509Certificates namespace

* annotate Windows-specific APIs from System.Threading namespace

* address code review feedback: dont introduce new constants, reuse existing SYSTEM_PRIVATE_CORELIB

* code review: import the namespace, simplify the attribute name

* add missing Socket.DuplicateAndClose and Socket(SocketInformation)

* fix the test name (it does not throw)

* add missing DriveInfo.set_VolumeLabel

* add System.IO.FileSystem File Encrypt and Descrypt methods

* simplify the < .NET 5 check

* enable nullable in explicit way as it's not enabled in all the projects where this file is included

* include platform attributes in projects that ask for it in explicit way

* set IncludePlatformAttributes to true for projects that include files from other projects

* use suggestions from Viktor and Santi

Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com>
101 files changed:
eng/Configurations.props
eng/versioning.targets
src/libraries/Directory.Build.targets
src/libraries/Microsoft.IO.Redist/src/Microsoft.IO.Redist.csproj
src/libraries/Microsoft.Win32.Registry.AccessControl/Directory.Build.props
src/libraries/Microsoft.Win32.Registry/Directory.Build.props
src/libraries/Microsoft.Win32.SystemEvents/Directory.Build.props
src/libraries/System.Configuration.ConfigurationManager/Directory.Build.props
src/libraries/System.Configuration.ConfigurationManager/ref/System.Configuration.ConfigurationManager.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/DpapiProtectedConfigurationProvider.cs
src/libraries/System.Console/Directory.Build.props
src/libraries/System.Console/ref/System.Console.cs
src/libraries/System.Console/src/System/Console.cs
src/libraries/System.Diagnostics.EventLog/Directory.Build.props
src/libraries/System.Diagnostics.PerformanceCounter/Directory.Build.props
src/libraries/System.Diagnostics.Process/Directory.Build.props
src/libraries/System.Diagnostics.Process/ref/System.Diagnostics.Process.cs
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.cs
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessStartInfo.Unix.cs
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessStartInfo.Windows.cs
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessThread.Unix.cs
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessThread.Windows.cs
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessThread.cs
src/libraries/System.Diagnostics.Process/tests/ProcessTests.Unix.cs
src/libraries/System.DirectoryServices.AccountManagement/Directory.Build.props
src/libraries/System.DirectoryServices/Directory.Build.props
src/libraries/System.IO.FileSystem.AccessControl/Directory.Build.props
src/libraries/System.IO.FileSystem.DriveInfo/Directory.Build.props
src/libraries/System.IO.FileSystem.DriveInfo/ref/System.IO.FileSystem.DriveInfo.cs
src/libraries/System.IO.FileSystem.DriveInfo/src/System/IO/DriveInfo.UnixOrBrowser.cs
src/libraries/System.IO.FileSystem.DriveInfo/src/System/IO/DriveInfo.Windows.cs
src/libraries/System.IO.FileSystem/Directory.Build.props
src/libraries/System.IO.FileSystem/ref/System.IO.FileSystem.cs
src/libraries/System.IO.FileSystem/src/System/IO/File.cs
src/libraries/System.IO.MemoryMappedFiles/Directory.Build.props
src/libraries/System.IO.MemoryMappedFiles/ref/System.IO.MemoryMappedFiles.cs
src/libraries/System.IO.MemoryMappedFiles/src/System/IO/MemoryMappedFiles/MemoryMappedFile.cs
src/libraries/System.IO.Pipes.AccessControl/Directory.Build.props
src/libraries/System.IO.Pipes/Directory.Build.props
src/libraries/System.IO.Pipes/ref/System.IO.Pipes.cs
src/libraries/System.IO.Pipes/src/System/IO/Pipes/NamedPipeClientStream.Unix.cs
src/libraries/System.IO.Pipes/src/System/IO/Pipes/NamedPipeClientStream.Windows.cs
src/libraries/System.IO.Pipes/src/System/IO/Pipes/PipeStream.Unix.cs
src/libraries/System.IO.Pipes/src/System/IO/Pipes/PipeStream.Windows.cs
src/libraries/System.IO.Pipes/src/System/IO/Pipes/PipeTransmissionMode.cs
src/libraries/System.Management/Directory.Build.props
src/libraries/System.Net.Http.WinHttpHandler/Directory.Build.props
src/libraries/System.Net.HttpListener/Directory.Build.props
src/libraries/System.Net.HttpListener/ref/System.Net.HttpListener.cs
src/libraries/System.Net.HttpListener/src/System/Net/Managed/HttpListenerTimeoutManager.Managed.cs
src/libraries/System.Net.HttpListener/src/System/Net/Windows/HttpListenerTimeoutManager.Windows.cs
src/libraries/System.Net.Sockets/Directory.Build.props
src/libraries/System.Net.Sockets/ref/System.Net.Sockets.cs
src/libraries/System.Net.Sockets/src/System/Net/Sockets/IOControlCode.cs
src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.Unix.cs
src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.Windows.cs
src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs
src/libraries/System.Net.Sockets/src/System/Net/Sockets/TCPListener.cs
src/libraries/System.Net.Sockets/src/System/Net/Sockets/TransmitFileOptions.cs
src/libraries/System.Net.Sockets/src/System/Net/Sockets/UDPClient.cs
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/NullableAttributes.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/DispatchWrapper.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.NoCom.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/MinimumOSPlatformAttribute.cs [deleted file]
src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/OSPlatformAttribute.cs [deleted file]
src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/ObsoletedInOSPlatformAttribute.cs [deleted file]
src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/PlatformAttributes.cs [new file with mode: 0644]
src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/RemovedInOSPlatformAttribute.cs [deleted file]
src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/TargetPlatformAttribute.cs [deleted file]
src/libraries/System.Private.CoreLib/src/System/Threading/EventWaitHandle.cs
src/libraries/System.Private.CoreLib/src/System/Threading/Semaphore.cs
src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs
src/libraries/System.Runtime.InteropServices/Directory.Build.props
src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs
src/libraries/System.Security.AccessControl/Directory.Build.props
src/libraries/System.Security.Cryptography.Cng/Directory.Build.props
src/libraries/System.Security.Cryptography.Csp/Directory.Build.props
src/libraries/System.Security.Cryptography.Csp/ref/System.Security.Cryptography.Csp.cs
src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/CspKeyContainerInfo.Unix.cs
src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/CspKeyContainerInfo.Windows.cs
src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/DSACryptoServiceProvider.Unix.cs
src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/DSACryptoServiceProvider.Windows.cs
src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/PasswordDeriveBytes.Unix.cs
src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/PasswordDeriveBytes.Windows.cs
src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/RC2CryptoServiceProvider.Unix.cs
src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/RC2CryptoServiceProvider.Windows.cs
src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/RSACryptoServiceProvider.Unix.cs
src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/RSACryptoServiceProvider.Windows.cs
src/libraries/System.Security.Cryptography.ProtectedData/Directory.Build.props
src/libraries/System.Security.Cryptography.X509Certificates/Directory.Build.props
src/libraries/System.Security.Cryptography.X509Certificates/ref/System.Security.Cryptography.X509Certificates.cs
src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Chain.cs
src/libraries/System.Security.Principal.Windows/Directory.Build.props
src/libraries/System.ServiceProcess.ServiceController/Directory.Build.props
src/libraries/System.Threading.AccessControl/Directory.Build.props
src/libraries/System.Threading.Overlapped/Directory.Build.props
src/libraries/System.Threading.Thread/ref/System.Threading.Thread.cs
src/libraries/System.Threading/ref/System.Threading.cs

index 1d6ad36..aa8e9ad 100644 (file)
@@ -31,6 +31,7 @@
     <NetCoreAppCurrentBrandName>.NET $(NetCoreAppCurrentVersion)</NetCoreAppCurrentBrandName>
 
     <NetFrameworkCurrent>net472</NetFrameworkCurrent>
+    <MinimiumSupportedWindowsPlatform>WINDOWS7.0</MinimiumSupportedWindowsPlatform>
   </PropertyGroup>
 
   <!-- Honor the generic RuntimeConfiguration property. -->
index c907b58..1eba158 100644 (file)
     </AssemblyMetadata>
   </ItemGroup>
 
+  <!-- Adds MinimumOSPlatform attribute for Windows Specific libraries -->
+  <ItemGroup Condition="'$(IsWindowsSpecific)' == 'true' and '$(IsTestProject)' != 'true'">
+    <AssemblyAttribute Include="System.Runtime.Versioning.MinimumOSPlatform">
+        <_Parameter1>$(MinimiumSupportedWindowsPlatform)</_Parameter1>
+    </AssemblyAttribute>
+  </ItemGroup>
+
   <Target Name="DecideIfWeNeedToIncludeDllSafeSearchPathAttribute"
           Condition="'$(IsDotNetFrameworkProductAssembly)' == 'true' and '$(IsTestProject)' != 'true' and '$(IsTestSupportProject)' != 'true'">
 
index 48dc86d..bf87a4e 100644 (file)
   <!-- Adds Nullable annotation attributes to netstandard <= 2.0 builds -->
   <Choose>
     <When Condition="'$(Nullable)' != '' and ($(TargetFramework.StartsWith('netstandard1')) or '$(TargetFramework)' == 'netstandard2.0' or $(TargetFramework.StartsWith('netcoreapp2')) or '$(TargetFrameworkIdentifier)' == '.NETFramework')">
-      <PropertyGroup>
-        <DefineConstants>$(DefineConstants),INTERNAL_NULLABLE_ATTRIBUTES</DefineConstants>
-      </PropertyGroup>
       <ItemGroup>
         <Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\NullableAttributes.cs" Link="System\Diagnostics\CodeAnalysis\NullableAttributes.cs" />
       </ItemGroup>
     <ExcludeFromPackage Condition="'$(TargetFramework)' == '$(NetFrameworkCurrent)' and '$(ExcludeCurrentFullFrameworkFromPackage)' == 'true'">true</ExcludeFromPackage>
   </PropertyGroup>
 
+  <!-- Adds System.Runtime.Versioning*Platform* annotation attributes to < .NET 5 builds -->
+  <Choose>
+    <When Condition="('$(IncludePlatformAttributes)' == 'true' or '$(IsWindowsSpecific)' == 'true') and ('$(TargetFrameworkIdentifier)' != '.NETCoreApp' or $([MSBuild]::VersionLessThan($(TargetFrameworkVersion), '5.0')))">
+      <ItemGroup>
+        <Compile Include="$(CoreLibSharedDir)System\Runtime\Versioning\PlatformAttributes.cs" Link="System\Runtime\Versioning\PlatformAttributes.cs" />
+      </ItemGroup>
+    </When>
+  </Choose>
+
   <!-- The Default behavior in VS is to show files for the first target framework in TargetFrameworks property.
         This is required to show all the files corresponding to all target frameworks in VS. -->
   <ItemGroup>
index 2614f3c..41b1e51 100644 (file)
@@ -6,6 +6,7 @@
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <ClsCompliant>false</ClsCompliant>
     <Nullable>annotations</Nullable>
+    <IncludePlatformAttributes>true</IncludePlatformAttributes>
   </PropertyGroup>
   <ItemGroup>
     <Compile Include="..\..\System.IO.FileSystem\src\System\IO\Directory.cs"
index 63f02a0..33e65b7 100644 (file)
@@ -2,5 +2,6 @@
   <Import Project="..\Directory.Build.props" />
   <PropertyGroup>
     <StrongNameKeyId>Microsoft</StrongNameKeyId>
+    <IsWindowsSpecific>true</IsWindowsSpecific>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index 8c72c62..27a4a55 100644 (file)
@@ -4,5 +4,6 @@
     <StrongNameKeyId>Microsoft</StrongNameKeyId>
     <IsNETCoreApp>true</IsNETCoreApp>
     <IsNETCoreAppRef>false</IsNETCoreAppRef>
+    <IsWindowsSpecific>true</IsWindowsSpecific>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index bdcfca3..2f8a894 100644 (file)
@@ -2,5 +2,6 @@
   <Import Project="..\Directory.Build.props" />
   <PropertyGroup>
     <StrongNameKeyId>Open</StrongNameKeyId>
+    <IsWindowsSpecific>true</IsWindowsSpecific>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index bdcfca3..1db5968 100644 (file)
@@ -2,5 +2,6 @@
   <Import Project="..\Directory.Build.props" />
   <PropertyGroup>
     <StrongNameKeyId>Open</StrongNameKeyId>
+    <IncludePlatformAttributes>true</IncludePlatformAttributes>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index 95a27a2..df967ac 100644 (file)
@@ -607,6 +607,7 @@ namespace System.Configuration
         protected virtual string ValueAttributeName { get { throw null; } }
         public virtual object Create(object parent, object context, System.Xml.XmlNode section) { throw null; }
     }
+    [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
     public sealed partial class DpapiProtectedConfigurationProvider : System.Configuration.ProtectedConfigurationProvider
     {
         public DpapiProtectedConfigurationProvider() { }
index 7673dab..b6ada8a 100644 (file)
@@ -5,9 +5,11 @@ using System.Collections.Specialized;
 using System.Security.Cryptography;
 using System.Text;
 using System.Xml;
+using System.Runtime.Versioning;
 
 namespace System.Configuration
 {
+    [MinimumOSPlatform("windows7.0")]
     public sealed class DpapiProtectedConfigurationProvider : ProtectedConfigurationProvider
     {
         private bool _useMachineProtection = true;
index 465e111..42c6eaf 100644 (file)
@@ -3,5 +3,6 @@
   <PropertyGroup>
     <StrongNameKeyId>Microsoft</StrongNameKeyId>
     <IsNETCoreApp>true</IsNETCoreApp>
+    <IncludePlatformAttributes>true</IncludePlatformAttributes>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index 98f8027..20b7d33 100644 (file)
@@ -9,16 +9,16 @@ namespace System
     public static partial class Console
     {
         public static System.ConsoleColor BackgroundColor { get { throw null; } set { } }
-        public static int BufferHeight { get { throw null; } set { } }
-        public static int BufferWidth { get { throw null; } set { } }
+        public static int BufferHeight { get { throw null; } [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")] set { } }
+        public static int BufferWidth { get { throw null; } [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")] set { } }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static bool CapsLock { get { throw null; } }
         public static int CursorLeft { get { throw null; } set { } }
-        public static int CursorSize { get { throw null; } set { } }
+        public static int CursorSize { get { throw null; } [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")] set { } }
         public static int CursorTop { get { throw null; } set { } }
-        public static bool CursorVisible { get { throw null; } set { } }
+        public static bool CursorVisible { [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")] get { throw null; } set { } }
         public static System.IO.TextWriter Error { get { throw null; } }
         public static System.ConsoleColor ForegroundColor { get { throw null; } set { } }
-        public static (int Left, int Top) GetCursorPosition() { throw null; }
         public static System.IO.TextReader In { get { throw null; } }
         public static System.Text.Encoding InputEncoding { get { throw null; } set { } }
         public static bool IsErrorRedirected { get { throw null; } }
@@ -27,20 +27,25 @@ namespace System
         public static bool KeyAvailable { get { throw null; } }
         public static int LargestWindowHeight { get { throw null; } }
         public static int LargestWindowWidth { get { throw null; } }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static bool NumberLock { get { throw null; } }
         public static System.IO.TextWriter Out { get { throw null; } }
         public static System.Text.Encoding OutputEncoding { get { throw null; } set { } }
-        public static string Title { get { throw null; } set { } }
+        public static string Title { [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")] get { throw null; } set { } }
         public static bool TreatControlCAsInput { get { throw null; } set { } }
-        public static int WindowHeight { get { throw null; } set { } }
-        public static int WindowLeft { get { throw null; } set { } }
-        public static int WindowTop { get { throw null; } set { } }
-        public static int WindowWidth { get { throw null; } set { } }
+        public static int WindowHeight { get { throw null; } [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")] set { } }
+        public static int WindowLeft { get { throw null; } [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")] set { } }
+        public static int WindowTop { get { throw null; } [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")] set { } }
+        public static int WindowWidth { get { throw null; } [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")] set { } }
         public static event System.ConsoleCancelEventHandler? CancelKeyPress { add { } remove { } }
         public static void Beep() { }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static void Beep(int frequency, int duration) { }
         public static void Clear() { }
+        public static (int Left, int Top) GetCursorPosition() { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static void MoveBufferArea(int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight, int targetLeft, int targetTop) { }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static void MoveBufferArea(int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight, int targetLeft, int targetTop, char sourceChar, System.ConsoleColor sourceForeColor, System.ConsoleColor sourceBackColor) { }
         public static System.IO.Stream OpenStandardError() { throw null; }
         public static System.IO.Stream OpenStandardError(int bufferSize) { throw null; }
@@ -53,12 +58,15 @@ namespace System
         public static System.ConsoleKeyInfo ReadKey(bool intercept) { throw null; }
         public static string? ReadLine() { throw null; }
         public static void ResetColor() { }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static void SetBufferSize(int width, int height) { }
         public static void SetCursorPosition(int left, int top) { }
         public static void SetError(System.IO.TextWriter newError) { }
         public static void SetIn(System.IO.TextReader newIn) { }
         public static void SetOut(System.IO.TextWriter newOut) { }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static void SetWindowPosition(int left, int top) { }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static void SetWindowSize(int width, int height) { }
         public static void Write(bool value) { }
         public static void Write(char value) { }
index 1cf8bdc..ed25ffe 100644 (file)
@@ -2,9 +2,9 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 
 using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
 using System.IO;
 using System.Runtime.CompilerServices;
+using System.Runtime.Versioning;
 using System.Text;
 using System.Threading;
 
@@ -277,14 +277,17 @@ namespace System
         public static int CursorSize
         {
             get { return ConsolePal.CursorSize; }
+            [MinimumOSPlatform("windows7.0")]
             set { ConsolePal.CursorSize = value; }
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static bool NumberLock
         {
             get { return ConsolePal.NumberLock; }
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static bool CapsLock
         {
             get { return ConsolePal.CapsLock; }
@@ -312,15 +315,18 @@ namespace System
         public static int BufferWidth
         {
             get { return ConsolePal.BufferWidth; }
+            [MinimumOSPlatform("windows7.0")]
             set { ConsolePal.BufferWidth = value; }
         }
 
         public static int BufferHeight
         {
             get { return ConsolePal.BufferHeight; }
+            [MinimumOSPlatform("windows7.0")]
             set { ConsolePal.BufferHeight = value; }
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static void SetBufferSize(int width, int height)
         {
             ConsolePal.SetBufferSize(width, height);
@@ -329,32 +335,38 @@ namespace System
         public static int WindowLeft
         {
             get { return ConsolePal.WindowLeft; }
+            [MinimumOSPlatform("windows7.0")]
             set { ConsolePal.WindowLeft = value; }
         }
 
         public static int WindowTop
         {
             get { return ConsolePal.WindowTop; }
+            [MinimumOSPlatform("windows7.0")]
             set { ConsolePal.WindowTop = value; }
         }
 
         public static int WindowWidth
         {
             get { return ConsolePal.WindowWidth; }
+            [MinimumOSPlatform("windows7.0")]
             set { ConsolePal.WindowWidth = value; }
         }
 
         public static int WindowHeight
         {
             get { return ConsolePal.WindowHeight; }
+            [MinimumOSPlatform("windows7.0")]
             set { ConsolePal.WindowHeight = value; }
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static void SetWindowPosition(int left, int top)
         {
             ConsolePal.SetWindowPosition(left, top);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static void SetWindowSize(int width, int height)
         {
             ConsolePal.SetWindowSize(width, height);
@@ -372,6 +384,7 @@ namespace System
 
         public static bool CursorVisible
         {
+            [MinimumOSPlatform("windows7.0")]
             get { return ConsolePal.CursorVisible; }
             set { ConsolePal.CursorVisible = value; }
         }
@@ -400,6 +413,7 @@ namespace System
 
         public static string Title
         {
+            [MinimumOSPlatform("windows7.0")]
             get { return ConsolePal.Title; }
             set
             {
@@ -412,16 +426,19 @@ namespace System
             ConsolePal.Beep();
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static void Beep(int frequency, int duration)
         {
             ConsolePal.Beep(frequency, duration);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static void MoveBufferArea(int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight, int targetLeft, int targetTop)
         {
             ConsolePal.MoveBufferArea(sourceLeft, sourceTop, sourceWidth, sourceHeight, targetLeft, targetTop, ' ', ConsoleColor.Black, BackgroundColor);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static void MoveBufferArea(int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight, int targetLeft, int targetTop, char sourceChar, ConsoleColor sourceForeColor, ConsoleColor sourceBackColor)
         {
             ConsolePal.MoveBufferArea(sourceLeft, sourceTop, sourceWidth, sourceHeight, targetLeft, targetTop, sourceChar, sourceForeColor, sourceBackColor);
index bdcfca3..2f8a894 100644 (file)
@@ -2,5 +2,6 @@
   <Import Project="..\Directory.Build.props" />
   <PropertyGroup>
     <StrongNameKeyId>Open</StrongNameKeyId>
+    <IsWindowsSpecific>true</IsWindowsSpecific>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index bdcfca3..2f8a894 100644 (file)
@@ -2,5 +2,6 @@
   <Import Project="..\Directory.Build.props" />
   <PropertyGroup>
     <StrongNameKeyId>Open</StrongNameKeyId>
+    <IsWindowsSpecific>true</IsWindowsSpecific>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index 465e111..42c6eaf 100644 (file)
@@ -3,5 +3,6 @@
   <PropertyGroup>
     <StrongNameKeyId>Microsoft</StrongNameKeyId>
     <IsNETCoreApp>true</IsNETCoreApp>
+    <IncludePlatformAttributes>true</IncludePlatformAttributes>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index 2f414aa..60808ee 100644 (file)
@@ -41,8 +41,8 @@ namespace System.Diagnostics
         public System.Diagnostics.ProcessModule? MainModule { get { throw null; } }
         public System.IntPtr MainWindowHandle { get { throw null; } }
         public string MainWindowTitle { get { throw null; } }
-        public System.IntPtr MaxWorkingSet { get { throw null; } set { } }
-        public System.IntPtr MinWorkingSet { get { throw null; } set { } }
+        public System.IntPtr MaxWorkingSet { get { throw null; } [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")] set { } }
+        public System.IntPtr MinWorkingSet { get { throw null; } [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")] set { } }
         public System.Diagnostics.ProcessModuleCollection Modules { get { throw null; } }
         [System.ObsoleteAttribute("This property has been deprecated.  Please use System.Diagnostics.Process.NonpagedSystemMemorySize64 instead.  https://go.microsoft.com/fwlink/?linkid=14202")]
         public int NonpagedSystemMemorySize { get { throw null; } }
@@ -116,8 +116,10 @@ namespace System.Diagnostics
         public static System.Diagnostics.Process Start(string fileName) { throw null; }
         public static System.Diagnostics.Process Start(string fileName, string arguments) { throw null; }
         [System.CLSCompliantAttribute(false)]
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static System.Diagnostics.Process Start(string fileName, string userName, System.Security.SecureString password, string domain) { throw null; }
         [System.CLSCompliantAttribute(false)]
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static System.Diagnostics.Process Start(string fileName, string arguments, string userName, System.Security.SecureString password, string domain) { throw null; }
         public override string ToString() { throw null; }
         public void WaitForExit() { }
@@ -163,15 +165,19 @@ namespace System.Diagnostics
         public System.Collections.ObjectModel.Collection<string> ArgumentList { get { throw null; } }
         public string Arguments { get { throw null; } set { } }
         public bool CreateNoWindow { get { throw null; } set { } }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public string Domain { get { throw null; } set { } }
         public System.Collections.Generic.IDictionary<string, string?> Environment { get { throw null; } }
         public System.Collections.Specialized.StringDictionary EnvironmentVariables { get { throw null; } }
         public bool ErrorDialog { get { throw null; } set { } }
         public System.IntPtr ErrorDialogParentHandle { get { throw null; } set { } }
         public string FileName { get { throw null; } set { } }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public bool LoadUserProfile { get { throw null; } set { } }
         [System.CLSCompliantAttribute(false)]
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public System.Security.SecureString? Password { get { throw null; } set { } }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public string? PasswordInClearText { get { throw null; } set { } }
         public bool RedirectStandardError { get { throw null; } set { } }
         public bool RedirectStandardInput { get { throw null; } set { } }
@@ -196,8 +202,9 @@ namespace System.Diagnostics
         public int Id { get { throw null; } }
         public int IdealProcessor { set { } }
         public bool PriorityBoostEnabled { get { throw null; } set { } }
-        public System.Diagnostics.ThreadPriorityLevel PriorityLevel { get { throw null; } set { } }
+        public System.Diagnostics.ThreadPriorityLevel PriorityLevel { get { throw null; } [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")] set { } }
         public System.TimeSpan PrivilegedProcessorTime { get { throw null; } }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public System.IntPtr ProcessorAffinity { set { } }
         public System.IntPtr StartAddress { get { throw null; } }
         public System.DateTime StartTime { get { throw null; } }
index 131912f..845c054 100644 (file)
@@ -9,6 +9,7 @@ using System.Net.Sockets;
 using System.Security;
 using System.Text;
 using System.Threading;
+using System.Runtime.Versioning;
 
 namespace System.Diagnostics
 {
@@ -41,12 +42,14 @@ namespace System.Diagnostics
         }
 
         [CLSCompliant(false)]
+        [MinimumOSPlatform("windows7.0")]
         public static Process Start(string fileName, string userName, SecureString password, string domain)
         {
             throw new PlatformNotSupportedException(SR.ProcessStartWithPasswordAndDomainNotSupported);
         }
 
         [CLSCompliant(false)]
+        [MinimumOSPlatform("windows7.0")]
         public static Process Start(string fileName, string arguments, string userName, SecureString password, string domain)
         {
             throw new PlatformNotSupportedException(SR.ProcessStartWithPasswordAndDomainNotSupported);
index 34e1762..f565713 100644 (file)
@@ -6,6 +6,7 @@ using System.Collections.Generic;
 using System.ComponentModel;
 using System.IO;
 using System.Runtime.InteropServices;
+using System.Runtime.Versioning;
 using System.Security;
 using System.Text;
 using System.Threading;
@@ -46,6 +47,7 @@ namespace System.Diagnostics
         }
 
         [CLSCompliant(false)]
+        [MinimumOSPlatform("windows7.0")]
         public static Process? Start(string fileName, string userName, SecureString password, string domain)
         {
             ProcessStartInfo startInfo = new ProcessStartInfo(fileName);
@@ -57,6 +59,7 @@ namespace System.Diagnostics
         }
 
         [CLSCompliant(false)]
+        [MinimumOSPlatform("windows7.0")]
         public static Process? Start(string fileName, string arguments, string userName, SecureString password, string domain)
         {
             ProcessStartInfo startInfo = new ProcessStartInfo(fileName, arguments);
index e47cac9..17b665e 100644 (file)
@@ -10,6 +10,7 @@ using System.Runtime.Serialization;
 using System.Text;
 using System.Threading;
 using System.Threading.Tasks;
+using System.Runtime.Versioning;
 
 namespace System.Diagnostics
 {
@@ -264,6 +265,7 @@ namespace System.Diagnostics
                 EnsureWorkingSetLimits();
                 return _maxWorkingSet;
             }
+            [MinimumOSPlatform("windows7.0")]
             set
             {
                 SetWorkingSetLimits(null, value);
@@ -283,6 +285,7 @@ namespace System.Diagnostics
                 EnsureWorkingSetLimits();
                 return _minWorkingSet;
             }
+            [MinimumOSPlatform("windows7.0")]
             set
             {
                 SetWorkingSetLimits(value, null);
index 339e872..1af5bb9 100644 (file)
@@ -3,6 +3,7 @@
 
 using System;
 using System.Security;
+using System.Runtime.Versioning;
 
 namespace System.Diagnostics
 {
@@ -13,18 +14,21 @@ namespace System.Diagnostics
     {
         private const bool CaseSensitiveEnvironmentVariables = true;
 
+        [MinimumOSPlatform("windows7.0")]
         public string PasswordInClearText
         {
             get { throw new PlatformNotSupportedException(SR.Format(SR.ProcessStartSingleFeatureNotSupported, nameof(PasswordInClearText))); }
             set { throw new PlatformNotSupportedException(SR.Format(SR.ProcessStartSingleFeatureNotSupported, nameof(PasswordInClearText))); }
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public string Domain
         {
             get { throw new PlatformNotSupportedException(SR.Format(SR.ProcessStartSingleFeatureNotSupported, nameof(Domain))); }
             set { throw new PlatformNotSupportedException(SR.Format(SR.ProcessStartSingleFeatureNotSupported, nameof(Domain))); }
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public bool LoadUserProfile
         {
             get { throw new PlatformNotSupportedException(SR.Format(SR.ProcessStartSingleFeatureNotSupported, nameof(LoadUserProfile))); }
@@ -36,6 +40,7 @@ namespace System.Diagnostics
         public string[] Verbs => Array.Empty<string>();
 
         [CLSCompliant(false)]
+        [MinimumOSPlatform("windows7.0")]
         public SecureString Password
         {
             get { throw new PlatformNotSupportedException(SR.Format(SR.ProcessStartSingleFeatureNotSupported, nameof(Password))); }
index 465cd0b..5545b05 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 
 using System.Security;
+using System.Runtime.Versioning;
 
 namespace System.Diagnostics
 {
@@ -11,17 +12,21 @@ namespace System.Diagnostics
 
         private const bool CaseSensitiveEnvironmentVariables = false;
 
+        [MinimumOSPlatform("windows7.0")]
         public string? PasswordInClearText { get; set; }
 
+        [MinimumOSPlatform("windows7.0")]
         public string Domain
         {
             get => _domain ?? string.Empty;
             set => _domain = value;
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public bool LoadUserProfile { get; set; }
 
         [CLSCompliant(false)]
+        [MinimumOSPlatform("windows7.0")]
         public SecureString? Password { get; set; }
     }
 }
index cca6089..ac65c2d 100644 (file)
@@ -1,6 +1,8 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
+using System.Runtime.Versioning;
+
 namespace System.Diagnostics
 {
     public partial class ProcessThread
@@ -39,6 +41,7 @@ namespace System.Diagnostics
         /// two, etc.  For example, the value 1 means run on processor one, 2 means run on
         /// processor two, 3 means run on processor one or two.
         /// </summary>
+        [MinimumOSPlatform("windows7.0")]
         public IntPtr ProcessorAffinity
         {
             set { throw new PlatformNotSupportedException(); } // No ability to change the affinity of a thread in an arbitrary process
index 99fd741..450a1d7 100644 (file)
@@ -3,6 +3,7 @@
 
 using Microsoft.Win32.SafeHandles;
 using System.ComponentModel;
+using System.Runtime.Versioning;
 
 namespace System.Diagnostics
 {
@@ -99,6 +100,7 @@ namespace System.Diagnostics
         /// two, etc.  For example, the value 1 means run on processor one, 2 means run on
         /// processor two, 3 means run on processor one or two.
         /// </summary>
+        [MinimumOSPlatform("windows7.0")]
         public IntPtr ProcessorAffinity
         {
             set
index 4d68dd2..b4ad10f 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 
 using System.ComponentModel;
+using System.Runtime.Versioning;
 
 namespace System.Diagnostics
 {
@@ -94,6 +95,7 @@ namespace System.Diagnostics
                 }
                 return _priorityLevel.Value;
             }
+            [MinimumOSPlatform("windows7.0")]
             set
             {
                 PriorityLevelCore = value;
index 3e86054..6aca35f 100644 (file)
@@ -33,7 +33,7 @@ namespace System.Diagnostics.Tests
         }
 
         [ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))]
-        public void MainWindowHandle_GetUnix_ThrowsPlatformNotSupportedException()
+        public void MainWindowHandle_GetUnix_ReturnsDefaultValue()
         {
             CreateDefaultProcess();
 
index 2a7de35..e6b3574 100644 (file)
@@ -6,5 +6,6 @@
          to a different assembly. -->
     <AssemblyVersion>4.0.0.0</AssemblyVersion>
     <StrongNameKeyId>ECMA</StrongNameKeyId>
+    <IsWindowsSpecific>true</IsWindowsSpecific>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index 131fb67..d5f3585 100644 (file)
@@ -6,5 +6,6 @@
          to a different assembly. -->
     <AssemblyVersion>4.0.0.0</AssemblyVersion>
     <StrongNameKeyId>Microsoft</StrongNameKeyId>
+    <IsWindowsSpecific>true</IsWindowsSpecific>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index 8c72c62..27a4a55 100644 (file)
@@ -4,5 +4,6 @@
     <StrongNameKeyId>Microsoft</StrongNameKeyId>
     <IsNETCoreApp>true</IsNETCoreApp>
     <IsNETCoreAppRef>false</IsNETCoreAppRef>
+    <IsWindowsSpecific>true</IsWindowsSpecific>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index 465e111..42c6eaf 100644 (file)
@@ -3,5 +3,6 @@
   <PropertyGroup>
     <StrongNameKeyId>Microsoft</StrongNameKeyId>
     <IsNETCoreApp>true</IsNETCoreApp>
+    <IncludePlatformAttributes>true</IncludePlatformAttributes>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index fbd22e4..cc5e3b7 100644 (file)
@@ -18,7 +18,7 @@ namespace System.IO
         public long TotalFreeSpace { get { throw null; } }
         public long TotalSize { get { throw null; } }
         [System.Diagnostics.CodeAnalysis.AllowNullAttribute]
-        public string VolumeLabel { get { throw null; } set { } }
+        public string VolumeLabel { get { throw null; } [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")] set { } }
         public static System.IO.DriveInfo[] GetDrives() { throw null; }
         void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
         public override string ToString() { throw null; }
index ee2e569..89ac3ae 100644 (file)
@@ -4,6 +4,7 @@
 using System.Collections.Generic;
 using System.Diagnostics.CodeAnalysis;
 using System.Security;
+using System.Runtime.Versioning;
 
 namespace System.IO
 {
@@ -41,6 +42,7 @@ namespace System.IO
             {
                 return Name;
             }
+            [MinimumOSPlatform("windows7.0")]
             set
             {
                 throw new PlatformNotSupportedException();
index 8d93728..df7eadd 100644 (file)
@@ -6,6 +6,7 @@ using System.Diagnostics;
 using System.Diagnostics.CodeAnalysis;
 using System.Runtime.InteropServices;
 using System.Text;
+using System.Runtime.Versioning;
 
 namespace System.IO
 {
@@ -138,6 +139,7 @@ namespace System.IO
 
                 return new string(volumeName);
             }
+            [MinimumOSPlatform("windows7.0")]
             set
             {
                 uint oldMode;
index 465e111..42c6eaf 100644 (file)
@@ -3,5 +3,6 @@
   <PropertyGroup>
     <StrongNameKeyId>Microsoft</StrongNameKeyId>
     <IsNETCoreApp>true</IsNETCoreApp>
+    <IncludePlatformAttributes>true</IncludePlatformAttributes>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index 3b1cd74..953c048 100644 (file)
@@ -121,8 +121,10 @@ namespace System.IO
         public static System.IO.FileStream Create(string path, int bufferSize) { throw null; }
         public static System.IO.FileStream Create(string path, int bufferSize, System.IO.FileOptions options) { throw null; }
         public static System.IO.StreamWriter CreateText(string path) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static void Decrypt(string path) { }
         public static void Delete(string path) { }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static void Encrypt(string path) { }
         public static bool Exists(string? path) { throw null; }
         public static System.IO.FileAttributes GetAttributes(string path) { throw null; }
index 1b6b219..2e5909c 100644 (file)
@@ -7,6 +7,7 @@ using System.Collections.Generic;
 using System.Diagnostics;
 using System.IO;
 using System.Runtime.ExceptionServices;
+using System.Runtime.Versioning;
 using System.Text;
 using System.Threading;
 using System.Threading.Tasks;
@@ -645,11 +646,13 @@ namespace System.IO
             FileSystem.MoveFile(fullSourceFileName, fullDestFileName, overwrite);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static void Encrypt(string path)
         {
             FileSystem.Encrypt(path ?? throw new ArgumentNullException(nameof(path)));
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static void Decrypt(string path)
         {
             FileSystem.Decrypt(path ?? throw new ArgumentNullException(nameof(path)));
index 465e111..42c6eaf 100644 (file)
@@ -3,5 +3,6 @@
   <PropertyGroup>
     <StrongNameKeyId>Microsoft</StrongNameKeyId>
     <IsNETCoreApp>true</IsNETCoreApp>
+    <IncludePlatformAttributes>true</IncludePlatformAttributes>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index 4808e3f..4748d3a 100644 (file)
@@ -33,8 +33,11 @@ namespace System.IO.MemoryMappedFiles
         public static System.IO.MemoryMappedFiles.MemoryMappedFile CreateNew(string? mapName, long capacity) { throw null; }
         public static System.IO.MemoryMappedFiles.MemoryMappedFile CreateNew(string? mapName, long capacity, System.IO.MemoryMappedFiles.MemoryMappedFileAccess access) { throw null; }
         public static System.IO.MemoryMappedFiles.MemoryMappedFile CreateNew(string? mapName, long capacity, System.IO.MemoryMappedFiles.MemoryMappedFileAccess access, System.IO.MemoryMappedFiles.MemoryMappedFileOptions options, System.IO.HandleInheritability inheritability) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static System.IO.MemoryMappedFiles.MemoryMappedFile CreateOrOpen(string mapName, long capacity) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static System.IO.MemoryMappedFiles.MemoryMappedFile CreateOrOpen(string mapName, long capacity, System.IO.MemoryMappedFiles.MemoryMappedFileAccess access) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static System.IO.MemoryMappedFiles.MemoryMappedFile CreateOrOpen(string mapName, long capacity, System.IO.MemoryMappedFiles.MemoryMappedFileAccess access, System.IO.MemoryMappedFiles.MemoryMappedFileOptions options, System.IO.HandleInheritability inheritability) { throw null; }
         public System.IO.MemoryMappedFiles.MemoryMappedViewAccessor CreateViewAccessor() { throw null; }
         public System.IO.MemoryMappedFiles.MemoryMappedViewAccessor CreateViewAccessor(long offset, long size) { throw null; }
@@ -44,8 +47,11 @@ namespace System.IO.MemoryMappedFiles
         public System.IO.MemoryMappedFiles.MemoryMappedViewStream CreateViewStream(long offset, long size, System.IO.MemoryMappedFiles.MemoryMappedFileAccess access) { throw null; }
         public void Dispose() { }
         protected virtual void Dispose(bool disposing) { }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static System.IO.MemoryMappedFiles.MemoryMappedFile OpenExisting(string mapName) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static System.IO.MemoryMappedFiles.MemoryMappedFile OpenExisting(string mapName, System.IO.MemoryMappedFiles.MemoryMappedFileRights desiredAccessRights) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static System.IO.MemoryMappedFiles.MemoryMappedFile OpenExisting(string mapName, System.IO.MemoryMappedFiles.MemoryMappedFileRights desiredAccessRights, System.IO.HandleInheritability inheritability) { throw null; }
     }
     public enum MemoryMappedFileAccess
index 3d26335..aed5492 100644 (file)
@@ -3,6 +3,7 @@
 
 using Microsoft.Win32.SafeHandles;
 using System.Diagnostics;
+using System.Runtime.Versioning;
 
 namespace System.IO.MemoryMappedFiles
 {
@@ -43,16 +44,19 @@ namespace System.IO.MemoryMappedFiles
         // the first override of this method.  Note: having ReadWrite access to the object does not mean that we
         // have ReadWrite access to the pages mapping the file.  The OS will check against the access on the pages
         // when a view is created.
+        [MinimumOSPlatform("windows7.0")]
         public static MemoryMappedFile OpenExisting(string mapName)
         {
             return OpenExisting(mapName, MemoryMappedFileRights.ReadWrite, HandleInheritability.None);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static MemoryMappedFile OpenExisting(string mapName, MemoryMappedFileRights desiredAccessRights)
         {
             return OpenExisting(mapName, desiredAccessRights, HandleInheritability.None);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static MemoryMappedFile OpenExisting(string mapName, MemoryMappedFileRights desiredAccessRights,
                                                                     HandleInheritability inheritability)
         {
@@ -291,18 +295,21 @@ namespace System.IO.MemoryMappedFiles
         // memory mapped file if one exists with the same name.  The capacity, options, and
         // memoryMappedFileSecurity arguments will be ignored in the case of the later.
         // This is ideal for P2P style IPC.
+        [MinimumOSPlatform("windows7.0")]
         public static MemoryMappedFile CreateOrOpen(string mapName, long capacity)
         {
             return CreateOrOpen(mapName, capacity, MemoryMappedFileAccess.ReadWrite,
                 MemoryMappedFileOptions.None, HandleInheritability.None);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static MemoryMappedFile CreateOrOpen(string mapName, long capacity,
                                                     MemoryMappedFileAccess access)
         {
             return CreateOrOpen(mapName, capacity, access, MemoryMappedFileOptions.None, HandleInheritability.None);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static MemoryMappedFile CreateOrOpen(string mapName, long capacity,
                                                     MemoryMappedFileAccess access, MemoryMappedFileOptions options,
                                                     HandleInheritability inheritability)
index 8c72c62..27a4a55 100644 (file)
@@ -4,5 +4,6 @@
     <StrongNameKeyId>Microsoft</StrongNameKeyId>
     <IsNETCoreApp>true</IsNETCoreApp>
     <IsNETCoreAppRef>false</IsNETCoreAppRef>
+    <IsWindowsSpecific>true</IsWindowsSpecific>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index 465e111..42c6eaf 100644 (file)
@@ -3,5 +3,6 @@
   <PropertyGroup>
     <StrongNameKeyId>Microsoft</StrongNameKeyId>
     <IsNETCoreApp>true</IsNETCoreApp>
+    <IncludePlatformAttributes>true</IncludePlatformAttributes>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index 52a6ea1..8ef9f9f 100644 (file)
@@ -48,6 +48,7 @@ namespace System.IO.Pipes
         public NamedPipeClientStream(string serverName, string pipeName, System.IO.Pipes.PipeDirection direction, System.IO.Pipes.PipeOptions options) : base (default(System.IO.Pipes.PipeDirection), default(int)) { }
         public NamedPipeClientStream(string serverName, string pipeName, System.IO.Pipes.PipeDirection direction, System.IO.Pipes.PipeOptions options, System.Security.Principal.TokenImpersonationLevel impersonationLevel) : base (default(System.IO.Pipes.PipeDirection), default(int)) { }
         public NamedPipeClientStream(string serverName, string pipeName, System.IO.Pipes.PipeDirection direction, System.IO.Pipes.PipeOptions options, System.Security.Principal.TokenImpersonationLevel impersonationLevel, System.IO.HandleInheritability inheritability) : base (default(System.IO.Pipes.PipeDirection), default(int)) { }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public int NumberOfServerInstances { get { throw null; } }
         protected internal override void CheckPipePropertyOperations() { }
         public void Connect() { }
@@ -128,6 +129,7 @@ namespace System.IO.Pipes
         public override int ReadByte() { throw null; }
         public override long Seek(long offset, System.IO.SeekOrigin origin) { throw null; }
         public override void SetLength(long value) { }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public void WaitForPipeDrain() { }
         public override void Write(byte[] buffer, int offset, int count) { }
         public override void Write(System.ReadOnlySpan<byte> buffer) { }
@@ -139,6 +141,7 @@ namespace System.IO.Pipes
     public enum PipeTransmissionMode
     {
         Byte = 0,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         Message = 1,
     }
 }
index f8f55aa..dfb09b4 100644 (file)
@@ -8,6 +8,7 @@ using System.Runtime.InteropServices;
 using System.Net.Sockets;
 using System.Security;
 using System.Threading;
+using System.Runtime.Versioning;
 
 namespace System.IO.Pipes
 {
@@ -66,6 +67,7 @@ namespace System.IO.Pipes
             return true;
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public int NumberOfServerInstances
         {
             get
index bf2c8cf..730f1ea 100644 (file)
@@ -6,6 +6,7 @@ using System.Runtime.InteropServices;
 using System.Security.Principal;
 using System.Threading;
 using Microsoft.Win32.SafeHandles;
+using System.Runtime.Versioning;
 
 namespace System.IO.Pipes
 {
@@ -107,6 +108,7 @@ namespace System.IO.Pipes
             return true;
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public unsafe int NumberOfServerInstances
         {
             get
index ce57953..502829f 100644 (file)
@@ -10,6 +10,7 @@ using System.Security;
 using System.IO;
 using System.Threading;
 using System.Threading.Tasks;
+using System.Runtime.Versioning;
 
 namespace System.IO.Pipes
 {
@@ -219,6 +220,7 @@ namespace System.IO.Pipes
         }
 
         // Blocks until the other end of the pipe has read in all written buffer.
+        [MinimumOSPlatform("windows7.0")]
         public void WaitForPipeDrain()
         {
             CheckWriteOperations();
index a06c0cd..030f769 100644 (file)
@@ -7,6 +7,7 @@ using System.Runtime.InteropServices;
 using System.Threading;
 using System.Threading.Tasks;
 using Microsoft.Win32.SafeHandles;
+using System.Runtime.Versioning;
 
 namespace System.IO.Pipes
 {
@@ -178,6 +179,7 @@ namespace System.IO.Pipes
         }
 
         // Blocks until the other end of the pipe has read in all written buffer.
+        [MinimumOSPlatform("windows7.0")]
         public void WaitForPipeDrain()
         {
             CheckWriteOperations();
index f7ba7a3..fbfd0cc 100644 (file)
@@ -1,11 +1,14 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
+using System.Runtime.Versioning;
+
 namespace System.IO.Pipes
 {
     public enum PipeTransmissionMode
     {
         Byte = 0,
+        [MinimumOSPlatform("windows7.0")]
         Message = 1,
     }
 }
index 131fb67..d5f3585 100644 (file)
@@ -6,5 +6,6 @@
          to a different assembly. -->
     <AssemblyVersion>4.0.0.0</AssemblyVersion>
     <StrongNameKeyId>Microsoft</StrongNameKeyId>
+    <IsWindowsSpecific>true</IsWindowsSpecific>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index 63f02a0..33e65b7 100644 (file)
@@ -2,5 +2,6 @@
   <Import Project="..\Directory.Build.props" />
   <PropertyGroup>
     <StrongNameKeyId>Microsoft</StrongNameKeyId>
+    <IsWindowsSpecific>true</IsWindowsSpecific>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index 2b9e284..e912bb8 100644 (file)
@@ -3,5 +3,6 @@
   <PropertyGroup>
     <StrongNameKeyId>Open</StrongNameKeyId>
     <IsNETCoreApp>true</IsNETCoreApp>
+    <IncludePlatformAttributes>true</IncludePlatformAttributes>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index afb9e0d..3e867fd 100644 (file)
@@ -139,11 +139,11 @@ namespace System.Net
     {
         internal HttpListenerTimeoutManager() { }
         public System.TimeSpan DrainEntityBody { get { throw null; } set { } }
-        public System.TimeSpan EntityBody { get { throw null; } set { } }
-        public System.TimeSpan HeaderWait { get { throw null; } set { } }
+        public System.TimeSpan EntityBody { get { throw null; } [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")] set { } }
+        public System.TimeSpan HeaderWait { get { throw null; } [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")] set { } }
         public System.TimeSpan IdleConnection { get { throw null; } set { } }
-        public long MinSendBytesPerSecond { get { throw null; } set { } }
-        public System.TimeSpan RequestQueue { get { throw null; } set { } }
+        public long MinSendBytesPerSecond { get { throw null; } [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")] set { } }
+        public System.TimeSpan RequestQueue { get { throw null; } [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")] set { } }
     }
 }
 namespace System.Net.WebSockets
index b082aaa..fbb9d17 100644 (file)
@@ -1,6 +1,8 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
+using System.Runtime.Versioning;
+
 namespace System.Net
 {
     public class HttpListenerTimeoutManager
@@ -37,6 +39,7 @@ namespace System.Net
         public TimeSpan EntityBody
         {
             get => TimeSpan.Zero;
+            [MinimumOSPlatform("windows7.0")]
             set
             {
                 ValidateTimeout(value);
@@ -47,6 +50,7 @@ namespace System.Net
         public TimeSpan HeaderWait
         {
             get => TimeSpan.Zero;
+            [MinimumOSPlatform("windows7.0")]
             set
             {
                 ValidateTimeout(value);
@@ -57,6 +61,7 @@ namespace System.Net
         public long MinSendBytesPerSecond
         {
             get => 0;
+            [MinimumOSPlatform("windows7.0")]
             set
             {
                 if (value < 0 || value > uint.MaxValue)
@@ -70,6 +75,7 @@ namespace System.Net
         public TimeSpan RequestQueue
         {
             get => TimeSpan.Zero;
+            [MinimumOSPlatform("windows7.0")]
             set
             {
                 ValidateTimeout(value);
index d967a73..3de0781 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 
 using System.Diagnostics;
+using System.Runtime.Versioning;
 
 namespace System.Net
 {
@@ -82,6 +83,7 @@ namespace System.Net
             {
                 return GetTimeout(Interop.HttpApi.HTTP_TIMEOUT_TYPE.EntityBody);
             }
+            [MinimumOSPlatform("windows7.0")]
             set
             {
                 SetTimespanTimeout(Interop.HttpApi.HTTP_TIMEOUT_TYPE.EntityBody, value);
@@ -119,6 +121,7 @@ namespace System.Net
             {
                 return GetTimeout(Interop.HttpApi.HTTP_TIMEOUT_TYPE.RequestQueue);
             }
+            [MinimumOSPlatform("windows7.0")]
             set
             {
                 SetTimespanTimeout(Interop.HttpApi.HTTP_TIMEOUT_TYPE.RequestQueue, value);
@@ -154,6 +157,7 @@ namespace System.Net
             {
                 return GetTimeout(Interop.HttpApi.HTTP_TIMEOUT_TYPE.HeaderWait);
             }
+            [MinimumOSPlatform("windows7.0")]
             set
             {
                 SetTimespanTimeout(Interop.HttpApi.HTTP_TIMEOUT_TYPE.HeaderWait, value);
@@ -173,6 +177,7 @@ namespace System.Net
                 //
                 return _minSendBytesPerSecond;
             }
+            [MinimumOSPlatform("windows7.0")]
             set
             {
                 //
index 465e111..42c6eaf 100644 (file)
@@ -3,5 +3,6 @@
   <PropertyGroup>
     <StrongNameKeyId>Microsoft</StrongNameKeyId>
     <IsNETCoreApp>true</IsNETCoreApp>
+    <IncludePlatformAttributes>true</IncludePlatformAttributes>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index 0a983f4..0917f00 100644 (file)
@@ -8,39 +8,70 @@ namespace System.Net.Sockets
 {
     public enum IOControlCode : long
     {
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         EnableCircularQueuing = (long)671088642,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         Flush = (long)671088644,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         AddressListChange = (long)671088663,
         DataToRead = (long)1074030207,
         OobDataRead = (long)1074033415,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         GetBroadcastAddress = (long)1207959557,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         AddressListQuery = (long)1207959574,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         QueryTargetPnpHandle = (long)1207959576,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         AsyncIO = (long)2147772029,
         NonBlockingIO = (long)2147772030,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         AssociateHandle = (long)2281701377,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         MultipointLoopback = (long)2281701385,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         MulticastScope = (long)2281701386,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         SetQos = (long)2281701387,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         SetGroupQos = (long)2281701388,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         RoutingInterfaceChange = (long)2281701397,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         NamespaceChange = (long)2281701401,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         ReceiveAll = (long)2550136833,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         ReceiveAllMulticast = (long)2550136834,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         ReceiveAllIgmpMulticast = (long)2550136835,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         KeepAliveValues = (long)2550136836,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         AbsorbRouterAlert = (long)2550136837,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         UnicastInterface = (long)2550136838,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         LimitBroadcasts = (long)2550136839,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         BindToInterface = (long)2550136840,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         MulticastInterface = (long)2550136841,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         AddMulticastGroupOnInterface = (long)2550136842,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         DeleteMulticastGroupFromInterface = (long)2550136843,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         GetExtensionFunctionPointer = (long)3355443206,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         GetQos = (long)3355443207,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         GetGroupQos = (long)3355443208,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         TranslateHandle = (long)3355443213,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         RoutingInterfaceQuery = (long)3355443220,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         AddressListSort = (long)3355443225,
     }
     public partial struct IPPacketInformation
@@ -294,6 +325,7 @@ namespace System.Net.Sockets
         public bool DisconnectAsync(System.Net.Sockets.SocketAsyncEventArgs e) { throw null; }
         public void Dispose() { }
         protected virtual void Dispose(bool disposing) { }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public System.Net.Sockets.SocketInformation DuplicateAndClose(int targetProcessId) { throw null; }
         public System.Net.Sockets.Socket EndAccept(out byte[]? buffer, System.IAsyncResult asyncResult) { throw null; }
         public System.Net.Sockets.Socket EndAccept(out byte[]? buffer, out int bytesTransferred, System.IAsyncResult asyncResult) { throw null; }
@@ -358,6 +390,7 @@ namespace System.Net.Sockets
         public int SendTo(byte[] buffer, System.Net.EndPoint remoteEP) { throw null; }
         public int SendTo(byte[] buffer, System.Net.Sockets.SocketFlags socketFlags, System.Net.EndPoint remoteEP) { throw null; }
         public bool SendToAsync(System.Net.Sockets.SocketAsyncEventArgs e) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public void SetIPProtectionLevel(System.Net.Sockets.IPProtectionLevel level) { }
         public void SetRawSocketOption(int optionLevel, int optionName, System.ReadOnlySpan<byte> optionValue) { }
         public void SetSocketOption(System.Net.Sockets.SocketOptionLevel optionLevel, System.Net.Sockets.SocketOptionName optionName, bool optionValue) { }
@@ -592,6 +625,7 @@ namespace System.Net.Sockets
         public System.Threading.Tasks.Task<System.Net.Sockets.Socket> AcceptSocketAsync() { throw null; }
         public System.Net.Sockets.TcpClient AcceptTcpClient() { throw null; }
         public System.Threading.Tasks.Task<System.Net.Sockets.TcpClient> AcceptTcpClientAsync() { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public void AllowNatTraversal(bool allowed) { }
         public System.IAsyncResult BeginAcceptSocket(System.AsyncCallback? callback, object? state) { throw null; }
         public System.IAsyncResult BeginAcceptTcpClient(System.AsyncCallback? callback, object? state) { throw null; }
@@ -609,8 +643,11 @@ namespace System.Net.Sockets
         UseDefaultWorkerThread = 0,
         Disconnect = 1,
         ReuseSocket = 2,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         WriteBehind = 4,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         UseSystemThread = 16,
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         UseKernelApc = 32,
     }
     public partial class UdpClient : System.IDisposable
@@ -629,6 +666,7 @@ namespace System.Net.Sockets
         public bool ExclusiveAddressUse { get { throw null; } set { } }
         public bool MulticastLoopback { get { throw null; } set { } }
         public short Ttl { get { throw null; } set { } }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public void AllowNatTraversal(bool allowed) { }
         public System.IAsyncResult BeginReceive(System.AsyncCallback? requestCallback, object? state) { throw null; }
         public System.IAsyncResult BeginSend(byte[] datagram, int bytes, System.AsyncCallback? requestCallback, object? state) { throw null; }
index 7ba90cc..fc1d691 100644 (file)
@@ -1,43 +1,76 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
+using System.Runtime.Versioning;
+
 namespace System.Net.Sockets
 {
     public enum IOControlCode : long
     {
+        [MinimumOSPlatform("windows7.0")]
         AsyncIO = 0x8004667D,
         NonBlockingIO = 0x8004667E,  // fionbio
         DataToRead = 0x4004667F,  // fionread
         OobDataRead = 0x40047307,
+        [MinimumOSPlatform("windows7.0")]
         AssociateHandle = 0x88000001,  // SIO_ASSOCIATE_HANDLE
+        [MinimumOSPlatform("windows7.0")]
         EnableCircularQueuing = 0x28000002,
+        [MinimumOSPlatform("windows7.0")]
         Flush = 0x28000004,
+        [MinimumOSPlatform("windows7.0")]
         GetBroadcastAddress = 0x48000005,
+        [MinimumOSPlatform("windows7.0")]
         GetExtensionFunctionPointer = 0xC8000006,
+        [MinimumOSPlatform("windows7.0")]
         GetQos = 0xC8000007,
+        [MinimumOSPlatform("windows7.0")]
         GetGroupQos = 0xC8000008,
+        [MinimumOSPlatform("windows7.0")]
         MultipointLoopback = 0x88000009,
+        [MinimumOSPlatform("windows7.0")]
         MulticastScope = 0x8800000A,
+        [MinimumOSPlatform("windows7.0")]
         SetQos = 0x8800000B,
+        [MinimumOSPlatform("windows7.0")]
         SetGroupQos = 0x8800000C,
+        [MinimumOSPlatform("windows7.0")]
         TranslateHandle = 0xC800000D,
+        [MinimumOSPlatform("windows7.0")]
         RoutingInterfaceQuery = 0xC8000014,
+        [MinimumOSPlatform("windows7.0")]
         RoutingInterfaceChange = 0x88000015,
+        [MinimumOSPlatform("windows7.0")]
         AddressListQuery = 0x48000016,
+        [MinimumOSPlatform("windows7.0")]
         AddressListChange = 0x28000017,
+        [MinimumOSPlatform("windows7.0")]
         QueryTargetPnpHandle = 0x48000018,
+        [MinimumOSPlatform("windows7.0")]
         NamespaceChange = 0x88000019,
+        [MinimumOSPlatform("windows7.0")]
         AddressListSort = 0xC8000019,
+        [MinimumOSPlatform("windows7.0")]
         ReceiveAll = 0x98000001,
+        [MinimumOSPlatform("windows7.0")]
         ReceiveAllMulticast = 0x98000002,
+        [MinimumOSPlatform("windows7.0")]
         ReceiveAllIgmpMulticast = 0x98000003,
+        [MinimumOSPlatform("windows7.0")]
         KeepAliveValues = 0x98000004,
+        [MinimumOSPlatform("windows7.0")]
         AbsorbRouterAlert = 0x98000005,
+        [MinimumOSPlatform("windows7.0")]
         UnicastInterface = 0x98000006,
+        [MinimumOSPlatform("windows7.0")]
         LimitBroadcasts = 0x98000007,
+        [MinimumOSPlatform("windows7.0")]
         BindToInterface = 0x98000008,
+        [MinimumOSPlatform("windows7.0")]
         MulticastInterface = 0x98000009,
+        [MinimumOSPlatform("windows7.0")]
         AddMulticastGroupOnInterface = 0x9800000A,
+        [MinimumOSPlatform("windows7.0")]
         DeleteMulticastGroupFromInterface = 0x9800000B
     }
 }
index b847617..0886dbf 100644 (file)
@@ -1,15 +1,16 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
-using Microsoft.Win32.SafeHandles;
 using System.Diagnostics;
 using System.IO;
 using System.Threading.Tasks;
+using System.Runtime.Versioning;
 
 namespace System.Net.Sockets
 {
     public partial class Socket
     {
+        [MinimumOSPlatform("windows7.0")]
         public Socket(SocketInformation socketInformation)
         {
             // This constructor works in conjunction with DuplicateAndClose, which is not supported on Unix.
@@ -17,6 +18,7 @@ namespace System.Net.Sockets
             throw new PlatformNotSupportedException(SR.net_sockets_duplicateandclose_notsupported);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public SocketInformation DuplicateAndClose(int targetProcessId)
         {
             // DuplicateAndClose is not supported on Unix, since passing file descriptors between processes
index d20fbea..d9c64a5 100644 (file)
@@ -6,8 +6,8 @@ using System.Collections;
 using System.Diagnostics;
 using System.IO;
 using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
 using System.Threading;
+using System.Runtime.Versioning;
 
 namespace System.Net.Sockets
 {
@@ -17,6 +17,7 @@ namespace System.Net.Sockets
 
         internal void ReplaceHandleIfNecessaryAfterFailedConnect() { /* nop on Windows */ }
 
+        [MinimumOSPlatform("windows7.0")]
         public Socket(SocketInformation socketInformation)
         {
             InitializeSockets();
@@ -105,6 +106,7 @@ namespace System.Net.Sockets
             blocking = true;
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public SocketInformation DuplicateAndClose(int targetProcessId)
         {
             ThrowIfDisposed();
index e75f084..a874c7f 100644 (file)
@@ -13,6 +13,7 @@ using System.Runtime.CompilerServices;
 using System.Runtime.ExceptionServices;
 using System.Runtime.InteropServices;
 using System.Threading;
+using System.Runtime.Versioning;
 
 namespace System.Net.Sockets
 {
@@ -1935,6 +1936,7 @@ namespace System.Net.Sockets
             return realOptionLength;
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public void SetIPProtectionLevel(IPProtectionLevel level)
         {
             if (level == IPProtectionLevel.Unspecified)
index d11d283..df906c1 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 
 using System.Threading.Tasks;
+using System.Runtime.Versioning;
 
 namespace System.Net.Sockets
 {
@@ -111,6 +112,7 @@ namespace System.Net.Sockets
             }
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public void AllowNatTraversal(bool allowed)
         {
             if (_active)
index 9d7e245..cc1d42c 100644 (file)
@@ -1,6 +1,8 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
+using System.Runtime.Versioning;
+
 namespace System.Net.Sockets
 {
     [Flags]
@@ -9,8 +11,11 @@ namespace System.Net.Sockets
         UseDefaultWorkerThread = 0x00,
         Disconnect = 0x01,
         ReuseSocket = 0x02,
+        [MinimumOSPlatform("windows7.0")]
         WriteBehind = 0x04,
+        [MinimumOSPlatform("windows7.0")]
         UseSystemThread = 0x10,
+        [MinimumOSPlatform("windows7.0")]
         UseKernelApc = 0x20,
     };
 }
index 83243cf..e5b9074 100644 (file)
@@ -3,6 +3,7 @@
 
 using System.Diagnostics.CodeAnalysis;
 using System.Threading.Tasks;
+using System.Runtime.Versioning;
 
 namespace System.Net.Sockets
 {
@@ -192,6 +193,7 @@ namespace System.Net.Sockets
             }
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public void AllowNatTraversal(bool allowed)
         {
             _clientSocket.SetIPProtectionLevel(allowed ? IPProtectionLevel.Unrestricted : IPProtectionLevel.EdgeRestricted);
index 1555dad..63314c0 100644 (file)
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Versioning\ComponentGuaranteesAttribute.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Versioning\ComponentGuaranteesOptions.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Versioning\FrameworkName.cs" />
-    <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Versioning\MinimumOSPlatformAttribute.cs" />
-    <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Versioning\ObsoletedInOSPlatformAttribute.cs" />
-    <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Versioning\OSPlatformAttribute.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Versioning\PlatformAttributes.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Versioning\ResourceConsumptionAttribute.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Versioning\ResourceExposureAttribute.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Versioning\ResourceScope.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Versioning\TargetFrameworkAttribute.cs" />
-    <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Versioning\TargetPlatformAttribute.cs" />
-    <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Versioning\RemovedInOSPlatformAttribute.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Versioning\VersioningHelper.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\RuntimeType.cs" Condition="'$(TargetsCoreRT)' != 'true'" />
     <Compile Include="$(MSBuildThisFileDirectory)System\SByte.cs" />
index c1e4e13..ff64dbf 100644 (file)
@@ -5,46 +5,46 @@ namespace System.Diagnostics.CodeAnalysis
 {
     /// <summary>Specifies that null is allowed as an input even if the corresponding type disallows it.</summary>
     [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property, Inherited = false)]
-#if INTERNAL_NULLABLE_ATTRIBUTES
-    internal
-#else
+#if SYSTEM_PRIVATE_CORELIB
     public
+#else
+    internal
 #endif
         sealed class AllowNullAttribute : Attribute { }
 
     /// <summary>Specifies that null is disallowed as an input even if the corresponding type allows it.</summary>
     [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property, Inherited = false)]
-#if INTERNAL_NULLABLE_ATTRIBUTES
-    internal
-#else
+#if SYSTEM_PRIVATE_CORELIB
     public
+#else
+    internal
 #endif
         sealed class DisallowNullAttribute : Attribute { }
 
     /// <summary>Specifies that an output may be null even if the corresponding type disallows it.</summary>
     [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, Inherited = false)]
-#if INTERNAL_NULLABLE_ATTRIBUTES
-    internal
-#else
+#if SYSTEM_PRIVATE_CORELIB
     public
+#else
+    internal
 #endif
         sealed class MaybeNullAttribute : Attribute { }
 
     /// <summary>Specifies that an output will not be null even if the corresponding type allows it. Specifies that an input argument was not null when the call returns.</summary>
     [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, Inherited = false)]
-#if INTERNAL_NULLABLE_ATTRIBUTES
-    internal
-#else
+#if SYSTEM_PRIVATE_CORELIB
     public
+#else
+    internal
 #endif
         sealed class NotNullAttribute : Attribute { }
 
     /// <summary>Specifies that when a method returns <see cref="ReturnValue"/>, the parameter may be null even if the corresponding type disallows it.</summary>
     [AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
-#if INTERNAL_NULLABLE_ATTRIBUTES
-    internal
-#else
+#if SYSTEM_PRIVATE_CORELIB
     public
+#else
+    internal
 #endif
         sealed class MaybeNullWhenAttribute : Attribute
     {
@@ -60,10 +60,10 @@ namespace System.Diagnostics.CodeAnalysis
 
     /// <summary>Specifies that when a method returns <see cref="ReturnValue"/>, the parameter will not be null even if the corresponding type allows it.</summary>
     [AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
-#if INTERNAL_NULLABLE_ATTRIBUTES
-    internal
-#else
+#if SYSTEM_PRIVATE_CORELIB
     public
+#else
+    internal
 #endif
         sealed class NotNullWhenAttribute : Attribute
     {
@@ -79,10 +79,10 @@ namespace System.Diagnostics.CodeAnalysis
 
     /// <summary>Specifies that the output will be non-null if the named parameter is non-null.</summary>
     [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)]
-#if INTERNAL_NULLABLE_ATTRIBUTES
-    internal
-#else
+#if SYSTEM_PRIVATE_CORELIB
     public
+#else
+    internal
 #endif
         sealed class NotNullIfNotNullAttribute : Attribute
     {
@@ -98,19 +98,19 @@ namespace System.Diagnostics.CodeAnalysis
 
     /// <summary>Applied to a method that will never return under any circumstance.</summary>
     [AttributeUsage(AttributeTargets.Method, Inherited = false)]
-#if INTERNAL_NULLABLE_ATTRIBUTES
-    internal
-#else
+#if SYSTEM_PRIVATE_CORELIB
     public
+#else
+    internal
 #endif
         sealed class DoesNotReturnAttribute : Attribute { }
 
     /// <summary>Specifies that the method will not return if the associated Boolean parameter is passed the specified value.</summary>
     [AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
-#if INTERNAL_NULLABLE_ATTRIBUTES
-    internal
-#else
+#if SYSTEM_PRIVATE_CORELIB
     public
+#else
+    internal
 #endif
         sealed class DoesNotReturnIfAttribute : Attribute
     {
@@ -127,10 +127,10 @@ namespace System.Diagnostics.CodeAnalysis
 
     /// <summary>Specifies that the method or property will ensure that the listed field and property members have not-null values.</summary>
     [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
-#if INTERNAL_NULLABLE_ATTRIBUTES
-    internal
-#else
+#if SYSTEM_PRIVATE_CORELIB
     public
+#else
+    internal
 #endif
         sealed class MemberNotNullAttribute : Attribute
     {
@@ -152,10 +152,10 @@ namespace System.Diagnostics.CodeAnalysis
 
     /// <summary>Specifies that the method or property will ensure that the listed field and property members have not-null values when returning with the specified return value condition.</summary>
     [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
-#if INTERNAL_NULLABLE_ATTRIBUTES
-    internal
-#else
+#if SYSTEM_PRIVATE_CORELIB
     public
+#else
+    internal
 #endif
         sealed class MemberNotNullWhenAttribute : Attribute
     {
index b18dc25..5be89fc 100644 (file)
@@ -1,6 +1,8 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
+using System.Runtime.Versioning;
+
 namespace System.Runtime.InteropServices
 {
     // Wrapper that is converted to a variant with VT_DISPATCH
@@ -20,6 +22,7 @@ namespace System.Runtime.InteropServices
             }
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public object? WrappedObject { get; }
     }
 }
index aa94a55..2e7c3b3 100644 (file)
@@ -4,6 +4,7 @@
 using System.Diagnostics.CodeAnalysis;
 using System.Reflection;
 using System.Runtime.InteropServices.ComTypes;
+using System.Runtime.Versioning;
 
 namespace System.Runtime.InteropServices
 {
@@ -14,6 +15,7 @@ namespace System.Runtime.InteropServices
             return e?.HResult ?? 0;
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static int AddRef(IntPtr pUnk)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
@@ -21,11 +23,13 @@ namespace System.Runtime.InteropServices
 
         public static bool AreComObjectsAvailableForCleanup() => false;
 
+        [MinimumOSPlatform("windows7.0")]
         public static IntPtr CreateAggregatedObject(IntPtr pOuter, object o)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static object BindToMoniker(string monikerName)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
@@ -35,46 +39,55 @@ namespace System.Runtime.InteropServices
         {
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static IntPtr CreateAggregatedObject<T>(IntPtr pOuter, T o) where T : notnull
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static object? CreateWrapperOfType(object? o, Type t)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static TWrapper CreateWrapperOfType<T, TWrapper>([AllowNull] T o)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static void ChangeWrapperHandleStrength(object otp, bool fIsWeak)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static int FinalReleaseComObject(object o)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static IntPtr GetComInterfaceForObject(object o, Type T)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static IntPtr GetComInterfaceForObject(object o, Type T, CustomQueryInterfaceMode mode)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static IntPtr GetComInterfaceForObject<T, TInterface>([DisallowNull] T o)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static object? GetComObjectData(object obj, object key)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
@@ -90,77 +103,92 @@ namespace System.Runtime.InteropServices
             return (IntPtr)(-1);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static IntPtr GetIDispatchForObject(object o)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static IntPtr GetIUnknownForObject(object o)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static void GetNativeVariantForObject(object? obj, IntPtr pDstNativeVariant)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static void GetNativeVariantForObject<T>([AllowNull] T obj, IntPtr pDstNativeVariant)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static object GetTypedObjectForIUnknown(IntPtr pUnk, Type t)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static object GetObjectForIUnknown(IntPtr pUnk)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static object? GetObjectForNativeVariant(IntPtr pSrcNativeVariant)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         [return: MaybeNull]
         public static T GetObjectForNativeVariant<T>(IntPtr pSrcNativeVariant)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static object?[] GetObjectsForNativeVariants(IntPtr aSrcNativeVariant, int cVars)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static T[] GetObjectsForNativeVariants<T>(IntPtr aSrcNativeVariant, int cVars)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static int GetStartComSlot(Type t)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static int GetEndComSlot(Type t)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static Type? GetTypeFromCLSID(Guid clsid)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static string GetTypeInfoName(ITypeInfo typeInfo)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static object GetUniqueObjectForIUnknown(IntPtr unknown)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
@@ -185,21 +213,25 @@ namespace System.Runtime.InteropServices
             return false;
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static int QueryInterface(IntPtr pUnk, ref Guid iid, out IntPtr ppv)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static int Release(IntPtr pUnk)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static int ReleaseComObject(object o)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static bool SetComObjectData(object obj, object key, object? data)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/MinimumOSPlatformAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/MinimumOSPlatformAttribute.cs
deleted file mode 100644 (file)
index 08b2899..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Runtime.Versioning
-{
-    /// <summary>
-    /// Records the operating system (and minimum version) that supports an API. Multiple attributes can be
-    /// applied to indicate support on multiple operating systems.
-    /// </summary>
-    /// <remarks>
-    /// Callers can apply a <see cref="System.Runtime.Versioning.MinimumOSPlatformAttribute" />
-    /// or use guards to prevent calls to APIs on unsupported operating systems.
-    ///
-    /// A given platform should only be specified once.
-    /// </remarks>
-    [AttributeUsage(AttributeTargets.Assembly |
-                    AttributeTargets.Class |
-                    AttributeTargets.Constructor |
-                    AttributeTargets.Event |
-                    AttributeTargets.Field |
-                    AttributeTargets.Method |
-                    AttributeTargets.Module |
-                    AttributeTargets.Property |
-                    AttributeTargets.Struct,
-                    AllowMultiple = true, Inherited = false)]
-    public sealed class MinimumOSPlatformAttribute : OSPlatformAttribute
-    {
-        public MinimumOSPlatformAttribute(string platformName) : base(platformName)
-        {
-        }
-    }
-}
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/OSPlatformAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/OSPlatformAttribute.cs
deleted file mode 100644 (file)
index c2cbda5..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Runtime.Versioning
-{
-    /// <summary>
-    /// Base type for all platform-specific API attributes.
-    /// </summary>
-#pragma warning disable CS3015 // Type has no accessible constructors which use only CLS-compliant types
-    public abstract class OSPlatformAttribute : Attribute
-#pragma warning restore CS3015
-    {
-        private protected OSPlatformAttribute(string platformName)
-        {
-            PlatformName = platformName;
-        }
-        public string PlatformName { get; }
-    }
-}
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/ObsoletedInOSPlatformAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/ObsoletedInOSPlatformAttribute.cs
deleted file mode 100644 (file)
index 24628a1..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Runtime.Versioning
-{
-    /// <summary>
-    /// Marks APIs that were obsoleted in a given operating system version.
-    ///
-    /// Primarily used by OS bindings to indicate APIs that should only be used in
-    /// earlier versions.
-    /// </summary>
-    [AttributeUsage(AttributeTargets.Assembly |
-                    AttributeTargets.Class |
-                    AttributeTargets.Constructor |
-                    AttributeTargets.Event |
-                    AttributeTargets.Field |
-                    AttributeTargets.Method |
-                    AttributeTargets.Module |
-                    AttributeTargets.Property |
-                    AttributeTargets.Struct,
-                    AllowMultiple = true, Inherited = false)]
-    public sealed class ObsoletedInOSPlatformAttribute : OSPlatformAttribute
-    {
-        public ObsoletedInOSPlatformAttribute(string platformName) : base(platformName)
-        {
-        }
-
-        public ObsoletedInOSPlatformAttribute(string platformName, string message) : base(platformName)
-        {
-            Message = message;
-        }
-
-        public string? Message { get; }
-        public string? Url { get; set; }
-    }
-}
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/PlatformAttributes.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/PlatformAttributes.cs
new file mode 100644 (file)
index 0000000..c230113
--- /dev/null
@@ -0,0 +1,142 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+#nullable enable
+namespace System.Runtime.Versioning
+{
+    /// <summary>
+    /// Base type for all platform-specific API attributes.
+    /// </summary>
+#pragma warning disable CS3015 // Type has no accessible constructors which use only CLS-compliant types
+#if SYSTEM_PRIVATE_CORELIB
+    public
+#else
+    internal
+#endif
+        abstract class OSPlatformAttribute : Attribute
+#pragma warning restore CS3015
+    {
+        private protected OSPlatformAttribute(string platformName)
+        {
+            PlatformName = platformName;
+        }
+        public string PlatformName { get; }
+    }
+
+    /// <summary>
+    /// Records the platform that the project targeted.
+    /// </summary>
+    [AttributeUsage(AttributeTargets.Assembly,
+                    AllowMultiple = false, Inherited = false)]
+#if SYSTEM_PRIVATE_CORELIB
+    public
+#else
+    internal
+#endif
+        sealed class TargetPlatformAttribute : OSPlatformAttribute
+    {
+        public TargetPlatformAttribute(string platformName) : base(platformName)
+        {
+        }
+    }
+
+    /// <summary>
+    /// Records the operating system (and minimum version) that supports an API. Multiple attributes can be
+    /// applied to indicate support on multiple operating systems.
+    /// </summary>
+    /// <remarks>
+    /// Callers can apply a <see cref="System.Runtime.Versioning.MinimumOSPlatformAttribute" />
+    /// or use guards to prevent calls to APIs on unsupported operating systems.
+    ///
+    /// A given platform should only be specified once.
+    /// </remarks>
+    [AttributeUsage(AttributeTargets.Assembly |
+                    AttributeTargets.Class |
+                    AttributeTargets.Constructor |
+                    AttributeTargets.Enum |
+                    AttributeTargets.Event |
+                    AttributeTargets.Field |
+                    AttributeTargets.Method |
+                    AttributeTargets.Module |
+                    AttributeTargets.Property |
+                    AttributeTargets.Struct,
+                    AllowMultiple = true, Inherited = false)]
+#if SYSTEM_PRIVATE_CORELIB
+    public
+#else
+    internal
+#endif
+        sealed class MinimumOSPlatformAttribute : OSPlatformAttribute
+    {
+        public MinimumOSPlatformAttribute(string platformName) : base(platformName)
+        {
+        }
+    }
+
+    /// <summary>
+    /// Marks APIs that were obsoleted in a given operating system version.
+    ///
+    /// Primarily used by OS bindings to indicate APIs that should only be used in
+    /// earlier versions.
+    /// </summary>
+    [AttributeUsage(AttributeTargets.Assembly |
+                    AttributeTargets.Class |
+                    AttributeTargets.Constructor |
+                    AttributeTargets.Enum |
+                    AttributeTargets.Event |
+                    AttributeTargets.Field |
+                    AttributeTargets.Method |
+                    AttributeTargets.Module |
+                    AttributeTargets.Property |
+                    AttributeTargets.Struct,
+                    AllowMultiple = true, Inherited = false)]
+#if SYSTEM_PRIVATE_CORELIB
+    public
+#else
+    internal
+#endif
+        sealed class ObsoletedInOSPlatformAttribute : OSPlatformAttribute
+    {
+        public ObsoletedInOSPlatformAttribute(string platformName) : base(platformName)
+        {
+        }
+
+        public ObsoletedInOSPlatformAttribute(string platformName, string message) : base(platformName)
+        {
+            Message = message;
+        }
+
+        public string? Message { get; }
+        public string? Url { get; set; }
+    }
+
+    /// <summary>
+    /// Marks APIs that were removed in a given operating system version.
+    /// </summary>
+    /// <remarks>
+    /// Primarily used by OS bindings to indicate APIs that are only available in
+    /// earlier versions.
+    /// </remarks>
+    [AttributeUsage(AttributeTargets.Assembly |
+                    AttributeTargets.Class |
+                    AttributeTargets.Constructor |
+                    AttributeTargets.Enum |
+                    AttributeTargets.Event |
+                    AttributeTargets.Field |
+                    AttributeTargets.Method |
+                    AttributeTargets.Module |
+                    AttributeTargets.Property |
+                    AttributeTargets.Struct,
+                    AllowMultiple = true, Inherited = false)]
+#if SYSTEM_PRIVATE_CORELIB
+    public
+#else
+    internal
+#endif
+        sealed class RemovedInOSPlatformAttribute : OSPlatformAttribute
+    {
+        public RemovedInOSPlatformAttribute(string platformName) : base(platformName)
+        {
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/RemovedInOSPlatformAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/RemovedInOSPlatformAttribute.cs
deleted file mode 100644 (file)
index 688fae0..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Runtime.Versioning
-{
-    /// <summary>
-    /// Marks APIs that were removed in a given operating system version.
-    /// </summary>
-    /// <remarks>
-    /// Primarily used by OS bindings to indicate APIs that are only available in
-    /// earlier versions.
-    /// </remarks>
-    [AttributeUsage(AttributeTargets.Assembly |
-                    AttributeTargets.Class |
-                    AttributeTargets.Constructor |
-                    AttributeTargets.Event |
-                    AttributeTargets.Field |
-                    AttributeTargets.Method |
-                    AttributeTargets.Module |
-                    AttributeTargets.Property |
-                    AttributeTargets.Struct,
-                    AllowMultiple = true, Inherited = false)]
-    public sealed class RemovedInOSPlatformAttribute : OSPlatformAttribute
-    {
-        public RemovedInOSPlatformAttribute(string platformName) : base(platformName)
-        {
-        }
-    }
-}
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/TargetPlatformAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/TargetPlatformAttribute.cs
deleted file mode 100644 (file)
index f327530..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Runtime.Versioning
-{
-    /// <summary>
-    /// Records the platform that the project targeted.
-    /// </summary>
-    [AttributeUsage(AttributeTargets.Assembly,
-                    AllowMultiple = false, Inherited = false)]
-    public sealed class TargetPlatformAttribute : OSPlatformAttribute
-    {
-        public TargetPlatformAttribute(string platformName) : base(platformName)
-        {
-        }
-    }
-}
index dd27d93..6d95be7 100644 (file)
@@ -4,6 +4,7 @@
 using System.Diagnostics;
 using System.Diagnostics.CodeAnalysis;
 using System.IO;
+using System.Runtime.Versioning;
 
 namespace System.Threading
 {
@@ -27,6 +28,7 @@ namespace System.Threading
             CreateEventCore(initialState, mode, name, out createdNew);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static EventWaitHandle OpenExisting(string name)
         {
             switch (OpenExistingWorker(name, out EventWaitHandle? result))
@@ -43,6 +45,7 @@ namespace System.Threading
             }
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static bool TryOpenExisting(string name, [NotNullWhen(true)] out EventWaitHandle? result) =>
             OpenExistingWorker(name, out result!) == OpenExistingResult.Success;
     }
index 80f4c4b..40555cc 100644 (file)
@@ -4,6 +4,7 @@
 using System.Diagnostics;
 using System.Diagnostics.CodeAnalysis;
 using System.IO;
+using System.Runtime.Versioning;
 
 namespace System.Threading
 {
@@ -32,6 +33,7 @@ namespace System.Threading
             CreateSemaphoreCore(initialCount, maximumCount, name, out createdNew);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static Semaphore OpenExisting(string name)
         {
             switch (OpenExistingWorker(name, out Semaphore? result))
@@ -48,6 +50,7 @@ namespace System.Threading
             }
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public static bool TryOpenExisting(string name, [NotNullWhen(true)] out Semaphore? result) =>
             OpenExistingWorker(name, out result!) == OpenExistingResult.Success;
 
index e603933..edc0566 100644 (file)
@@ -7,6 +7,7 @@ using System.Diagnostics.CodeAnalysis;
 using System.Globalization;
 using System.Runtime.ConstrainedExecution;
 using System.Security.Principal;
+using System.Runtime.Versioning;
 
 namespace System.Threading
 {
@@ -224,6 +225,7 @@ namespace System.Threading
             set => TrySetApartmentState(value);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public void SetApartmentState(ApartmentState state)
         {
             if (!TrySetApartmentState(state))
index 465e111..42c6eaf 100644 (file)
@@ -3,5 +3,6 @@
   <PropertyGroup>
     <StrongNameKeyId>Microsoft</StrongNameKeyId>
     <IsNETCoreApp>true</IsNETCoreApp>
+    <IncludePlatformAttributes>true</IncludePlatformAttributes>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index d85496a..62a7124 100644 (file)
@@ -316,6 +316,7 @@ namespace System.Runtime.InteropServices
     public sealed partial class DispatchWrapper
     {
         public DispatchWrapper(object? obj) { }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public object? WrappedObject { get { throw null; } }
     }
     [System.AttributeUsageAttribute(System.AttributeTargets.Event | System.AttributeTargets.Field | System.AttributeTargets.Method | System.AttributeTargets.Property, Inherited=false)]
@@ -461,12 +462,15 @@ namespace System.Runtime.InteropServices
     {
         public static readonly int SystemDefaultCharSize;
         public static readonly int SystemMaxDBCSCharSize;
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static int AddRef(System.IntPtr pUnk) { throw null; }
         public static System.IntPtr AllocCoTaskMem(int cb) { throw null; }
         public static System.IntPtr AllocHGlobal(int cb) { throw null; }
         public static System.IntPtr AllocHGlobal(System.IntPtr cb) { throw null; }
         public static bool AreComObjectsAvailableForCleanup() { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static object BindToMoniker(string monikerName) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static void ChangeWrapperHandleStrength(object otp, bool fIsWeak) { }
         public static void CleanupUnusedObjectsInCurrentContext() { }
         public static void Copy(byte[] source, int startIndex, System.IntPtr destination, int length) { }
@@ -485,31 +489,40 @@ namespace System.Runtime.InteropServices
         public static void Copy(System.IntPtr source, float[] destination, int startIndex, int length) { }
         public static void Copy(System.IntPtr[] source, int startIndex, System.IntPtr destination, int length) { }
         public static void Copy(float[] source, int startIndex, System.IntPtr destination, int length) { }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
         public static System.IntPtr CreateAggregatedObject(System.IntPtr pOuter, object o) { throw null; }
         public static System.IntPtr CreateAggregatedObject<T>(System.IntPtr pOuter, T o) where T : notnull { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
         [return: System.Diagnostics.CodeAnalysis.NotNullIfNotNullAttribute("o")]
         public static object? CreateWrapperOfType(object? o, System.Type t) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static TWrapper CreateWrapperOfType<T, TWrapper>([System.Diagnostics.CodeAnalysis.AllowNullAttribute] T o) { throw null; }
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
         public static void DestroyStructure(System.IntPtr ptr, System.Type structuretype) { }
         public static void DestroyStructure<T>(System.IntPtr ptr) { }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static int FinalReleaseComObject(object o) { throw null; }
         public static void FreeBSTR(System.IntPtr ptr) { }
         public static void FreeCoTaskMem(System.IntPtr ptr) { }
         public static void FreeHGlobal(System.IntPtr hglobal) { }
         public static System.Guid GenerateGuidForType(System.Type type) { throw null; }
         public static string? GenerateProgIdForType(System.Type type) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
         public static System.IntPtr GetComInterfaceForObject(object o, System.Type T) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
         public static System.IntPtr GetComInterfaceForObject(object o, System.Type T, System.Runtime.InteropServices.CustomQueryInterfaceMode mode) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static System.IntPtr GetComInterfaceForObject<T, TInterface>([System.Diagnostics.CodeAnalysis.DisallowNullAttribute] T o) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static object? GetComObjectData(object obj, object key) { throw null; }
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
         public static System.Delegate GetDelegateForFunctionPointer(System.IntPtr ptr, System.Type t) { throw null; }
         public static TDelegate GetDelegateForFunctionPointer<TDelegate>(System.IntPtr ptr) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static int GetEndComSlot(System.Type t) { throw null; }
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
         [System.ObsoleteAttribute("GetExceptionCode() may be unavailable in future releases.")]
@@ -523,27 +536,41 @@ namespace System.Runtime.InteropServices
         public static System.IntPtr GetHINSTANCE(System.Reflection.Module m) { throw null; }
         public static int GetHRForException(System.Exception? e) { throw null; }
         public static int GetHRForLastWin32Error() { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static System.IntPtr GetIDispatchForObject(object o) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static System.IntPtr GetIUnknownForObject(object o) { throw null; }
         public static int GetLastWin32Error() { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
         public static void GetNativeVariantForObject(object? obj, System.IntPtr pDstNativeVariant) { }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
         public static void GetNativeVariantForObject<T>([System.Diagnostics.CodeAnalysis.AllowNullAttribute] T obj, System.IntPtr pDstNativeVariant) { }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static object GetObjectForIUnknown(System.IntPtr pUnk) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
         public static object? GetObjectForNativeVariant(System.IntPtr pSrcNativeVariant) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
         [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
         public static T GetObjectForNativeVariant<T>(System.IntPtr pSrcNativeVariant) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
         public static object?[] GetObjectsForNativeVariants(System.IntPtr aSrcNativeVariant, int cVars) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
         public static T[] GetObjectsForNativeVariants<T>(System.IntPtr aSrcNativeVariant, int cVars) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static int GetStartComSlot(System.Type t) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static object GetTypedObjectForIUnknown(System.IntPtr pUnk, System.Type t) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static System.Type GetTypeFromCLSID(System.Guid clsid) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static string GetTypeInfoName(System.Runtime.InteropServices.ComTypes.ITypeInfo typeInfo) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static object GetUniqueObjectForIUnknown(System.IntPtr unknown) { throw null; }
         public static bool IsComObject(object o) { throw null; }
         public static bool IsTypeVisibleFromCom(System.Type t) { throw null; }
@@ -568,6 +595,7 @@ namespace System.Runtime.InteropServices
         [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
         public static T PtrToStructure<T>(System.IntPtr ptr) { throw null; }
         public static void PtrToStructure<T>(System.IntPtr ptr, [System.Diagnostics.CodeAnalysis.DisallowNullAttribute] T structure) { }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static int QueryInterface(System.IntPtr pUnk, ref System.Guid iid, out System.IntPtr ppv) { throw null; }
         public static byte ReadByte(System.IntPtr ptr) { throw null; }
         public static byte ReadByte(System.IntPtr ptr, int ofs) { throw null; }
@@ -596,13 +624,16 @@ namespace System.Runtime.InteropServices
         public static System.IntPtr ReadIntPtr(object ptr, int ofs) { throw null; }
         public static System.IntPtr ReAllocCoTaskMem(System.IntPtr pv, int cb) { throw null; }
         public static System.IntPtr ReAllocHGlobal(System.IntPtr pv, System.IntPtr cb) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static int Release(System.IntPtr pUnk) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static int ReleaseComObject(object o) { throw null; }
         public static System.IntPtr SecureStringToBSTR(System.Security.SecureString s) { throw null; }
         public static System.IntPtr SecureStringToCoTaskMemAnsi(System.Security.SecureString s) { throw null; }
         public static System.IntPtr SecureStringToCoTaskMemUnicode(System.Security.SecureString s) { throw null; }
         public static System.IntPtr SecureStringToGlobalAllocAnsi(System.Security.SecureString s) { throw null; }
         public static System.IntPtr SecureStringToGlobalAllocUnicode(System.Security.SecureString s) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static bool SetComObjectData(object obj, object key, object? data) { throw null; }
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
         public static int SizeOf(object structure) { throw null; }
index 8c72c62..27a4a55 100644 (file)
@@ -4,5 +4,6 @@
     <StrongNameKeyId>Microsoft</StrongNameKeyId>
     <IsNETCoreApp>true</IsNETCoreApp>
     <IsNETCoreAppRef>false</IsNETCoreAppRef>
+    <IsWindowsSpecific>true</IsWindowsSpecific>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index 8c72c62..27a4a55 100644 (file)
@@ -4,5 +4,6 @@
     <StrongNameKeyId>Microsoft</StrongNameKeyId>
     <IsNETCoreApp>true</IsNETCoreApp>
     <IsNETCoreAppRef>false</IsNETCoreAppRef>
+    <IsWindowsSpecific>true</IsWindowsSpecific>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index 465e111..42c6eaf 100644 (file)
@@ -3,5 +3,6 @@
   <PropertyGroup>
     <StrongNameKeyId>Microsoft</StrongNameKeyId>
     <IsNETCoreApp>true</IsNETCoreApp>
+    <IncludePlatformAttributes>true</IncludePlatformAttributes>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index 88a0df0..f4bbc11 100644 (file)
@@ -27,6 +27,7 @@ namespace System.Security.Cryptography
         public override void GenerateIV() { }
         public override void GenerateKey() { }
     }
+    [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
     public sealed partial class CspKeyContainerInfo
     {
         public CspKeyContainerInfo(System.Security.Cryptography.CspParameters parameters) { }
@@ -86,8 +87,11 @@ namespace System.Security.Cryptography
     {
         public DSACryptoServiceProvider() { }
         public DSACryptoServiceProvider(int dwKeySize) { }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public DSACryptoServiceProvider(int dwKeySize, System.Security.Cryptography.CspParameters? parameters) { }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public DSACryptoServiceProvider(System.Security.Cryptography.CspParameters? parameters) { }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public System.Security.Cryptography.CspKeyContainerInfo CspKeyContainerInfo { get { throw null; } }
         public override string? KeyExchangeAlgorithm { get { throw null; } }
         public override int KeySize { get { throw null; } }
@@ -148,6 +152,7 @@ namespace System.Security.Cryptography
         public string HashName { get { throw null; } set { } }
         public int IterationCount { get { throw null; } set { } }
         public byte[]? Salt { get { throw null; } set { } }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public byte[] CryptDeriveKey(string? algname, string? alghashname, int keySize, byte[] rgbIV) { throw null; }
         protected override void Dispose(bool disposing) { }
         [System.ObsoleteAttribute("Rfc2898DeriveBytes replaces PasswordDeriveBytes for deriving key material from a password and is preferred in new applications.")]
@@ -159,7 +164,7 @@ namespace System.Security.Cryptography
     {
         public RC2CryptoServiceProvider() { }
         public override int EffectiveKeySize { get { throw null; } set { } }
-        public bool UseSalt { get { throw null; } set { } }
+        public bool UseSalt { get { throw null; } [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")] set { } }
         public override System.Security.Cryptography.ICryptoTransform CreateDecryptor(byte[] rgbKey, byte[]? rgbIV) { throw null; }
         public override System.Security.Cryptography.ICryptoTransform CreateEncryptor(byte[] rgbKey, byte[]? rgbIV) { throw null; }
         public override void GenerateIV() { }
@@ -183,8 +188,11 @@ namespace System.Security.Cryptography
     {
         public RSACryptoServiceProvider() { }
         public RSACryptoServiceProvider(int dwKeySize) { }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public RSACryptoServiceProvider(int dwKeySize, System.Security.Cryptography.CspParameters? parameters) { }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public RSACryptoServiceProvider(System.Security.Cryptography.CspParameters? parameters) { }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public System.Security.Cryptography.CspKeyContainerInfo CspKeyContainerInfo { get { throw null; } }
         public override string? KeyExchangeAlgorithm { get { throw null; } }
         public override int KeySize { get { throw null; } }
index b2f7c83..8433529 100644 (file)
@@ -1,8 +1,11 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
+using System.Runtime.Versioning;
+
 namespace System.Security.Cryptography
 {
+    [MinimumOSPlatform("windows7.0")]
     public sealed class CspKeyContainerInfo
     {
         public CspKeyContainerInfo(CspParameters parameters) { throw GetPlatformNotSupported(); }
index 149551b..25021e8 100644 (file)
@@ -3,9 +3,11 @@
 
 using Internal.NativeCrypto;
 using Microsoft.Win32.SafeHandles;
+using System.Runtime.Versioning;
 
 namespace System.Security.Cryptography
 {
+    [MinimumOSPlatform("windows7.0")]
     public sealed class CspKeyContainerInfo
     {
         private readonly CspParameters _parameters;
index 325c651..74811cb 100644 (file)
@@ -5,6 +5,7 @@ using Internal.Cryptography;
 using Internal.NativeCrypto;
 using System.IO;
 using System.Diagnostics;
+using System.Runtime.Versioning;
 
 namespace System.Security.Cryptography
 {
@@ -37,11 +38,13 @@ namespace System.Security.Cryptography
             KeySize = dwKeySize;
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public DSACryptoServiceProvider(int dwKeySize, CspParameters parameters)
         {
             throw new PlatformNotSupportedException(SR.Format(SR.Cryptography_CAPI_Required, nameof(CspParameters)));
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public DSACryptoServiceProvider(CspParameters parameters)
         {
             throw new PlatformNotSupportedException(SR.Format(SR.Cryptography_CAPI_Required, nameof(CspParameters)));
@@ -53,6 +56,7 @@ namespace System.Security.Cryptography
         public override bool TryCreateSignature(ReadOnlySpan<byte> hash, Span<byte> destination, out int bytesWritten) =>
             _impl.TryCreateSignature(hash, destination, out bytesWritten);
 
+        [MinimumOSPlatform("windows7.0")]
         public CspKeyContainerInfo CspKeyContainerInfo
         {
             get { throw new PlatformNotSupportedException(SR.Format(SR.Cryptography_CAPI_Required, nameof(CspKeyContainerInfo))); }
index c9a58c2..686728e 100644 (file)
@@ -4,6 +4,7 @@
 using System.Buffers.Binary;
 using System.Diagnostics;
 using System.IO;
+using System.Runtime.Versioning;
 using Internal.NativeCrypto;
 
 namespace System.Security.Cryptography
@@ -49,6 +50,7 @@ namespace System.Security.Cryptography
         /// for the cryptographic service provider (CSP).
         /// </summary>
         /// <param name="parameters">The parameters for the CSP.</param>
+        [MinimumOSPlatform("windows7.0")]
         public DSACryptoServiceProvider(CspParameters? parameters)
             : this(0, parameters)
         {
@@ -61,6 +63,7 @@ namespace System.Security.Cryptography
         /// <param name="dwKeySize">The size of the key for the cryptographic algorithm in bits.</param>
         /// <param name="parameters">The parameters for the CSP.</param>
         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA5350", Justification = "SHA1 is required by the FIPS 186-2 DSA spec.")]
+        [MinimumOSPlatform("windows7.0")]
         public DSACryptoServiceProvider(int dwKeySize, CspParameters? parameters)
         {
             if (dwKeySize < 0)
@@ -182,6 +185,7 @@ namespace System.Security.Cryptography
         /// <summary>
         /// Gets a CspKeyContainerInfo object that describes additional information about a cryptographic key pair.
         /// </summary>
+        [MinimumOSPlatform("windows7.0")]
         public CspKeyContainerInfo CspKeyContainerInfo
         {
             get
index f2ee01b..2627057 100644 (file)
@@ -1,10 +1,13 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
+using System.Runtime.Versioning;
+
 namespace System.Security.Cryptography
 {
     public partial class PasswordDeriveBytes : DeriveBytes
     {
+        [MinimumOSPlatform("windows7.0")]
         public byte[] CryptDeriveKey(string? algname, string? alghashname, int keySize, byte[] rgbIV)
         {
             throw new PlatformNotSupportedException(SR.Format(SR.Cryptography_CAPI_Required, nameof(CryptDeriveKey)));
index 7fa944a..58c546e 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 
 using Internal.NativeCrypto;
+using System.Runtime.Versioning;
 
 #pragma warning disable CA5373 // Call to obsolete key derivation function PasswordDeriveBytes.*
 
@@ -11,6 +12,7 @@ namespace System.Security.Cryptography
     {
         private SafeProvHandle? _safeProvHandle;
 
+        [MinimumOSPlatform("windows7.0")]
         public byte[] CryptDeriveKey(string? algname, string? alghashname, int keySize, byte[] rgbIV)
         {
             if (keySize < 0)
index 02661fe..3cab203 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 
 using Internal.Cryptography;
+using System.Runtime.Versioning;
 
 namespace System.Security.Cryptography
 {
@@ -103,6 +104,7 @@ namespace System.Security.Cryptography
         public bool UseSalt
         {
             get { return false; }
+            [MinimumOSPlatform("windows7.0")]
             set
             {
                 // Don't allow a true value
index c9b4e70..a7c1c42 100644 (file)
@@ -4,6 +4,7 @@
 using Internal.Cryptography;
 using Internal.NativeCrypto;
 using System.ComponentModel;
+using System.Runtime.Versioning;
 
 namespace System.Security.Cryptography
 {
@@ -43,6 +44,7 @@ namespace System.Security.Cryptography
             {
                 return _use40bitSalt;
             }
+            [MinimumOSPlatform("windows7.0")]
             set
             {
                 _use40bitSalt = value;
index 8cc80fa..d36a068 100644 (file)
@@ -4,6 +4,7 @@
 using Internal.Cryptography;
 using Internal.NativeCrypto;
 using System.IO;
+using System.Runtime.Versioning;
 
 namespace System.Security.Cryptography
 {
@@ -26,12 +27,15 @@ namespace System.Security.Cryptography
             _impl = RSA.Create(dwKeySize);
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public RSACryptoServiceProvider(int dwKeySize, CspParameters parameters) =>
             throw new PlatformNotSupportedException(SR.Format(SR.Cryptography_CAPI_Required, nameof(CspParameters)));
 
+        [MinimumOSPlatform("windows7.0")]
         public RSACryptoServiceProvider(CspParameters parameters) =>
             throw new PlatformNotSupportedException(SR.Format(SR.Cryptography_CAPI_Required, nameof(CspParameters)));
 
+        [MinimumOSPlatform("windows7.0")]
         public CspKeyContainerInfo CspKeyContainerInfo =>
             throw new PlatformNotSupportedException(SR.Format(SR.Cryptography_CAPI_Required, nameof(CspKeyContainerInfo)));
 
index c3fb318..7a22b93 100644 (file)
@@ -3,6 +3,7 @@
 
 using System.Diagnostics;
 using System.IO;
+using System.Runtime.Versioning;
 using Internal.Cryptography;
 using Internal.NativeCrypto;
 using Microsoft.Win32.SafeHandles;
@@ -38,11 +39,13 @@ namespace System.Security.Cryptography
         {
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public RSACryptoServiceProvider(int dwKeySize, CspParameters? parameters)
             : this(dwKeySize, parameters, false)
         {
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public RSACryptoServiceProvider(CspParameters? parameters)
             : this(0, parameters, true)
         {
@@ -170,6 +173,7 @@ namespace System.Security.Cryptography
         /// <summary>
         /// CspKeyContainerInfo property
         /// </summary>
+        [MinimumOSPlatform("windows7.0")]
         public CspKeyContainerInfo CspKeyContainerInfo
         {
             get
index 63f02a0..33e65b7 100644 (file)
@@ -2,5 +2,6 @@
   <Import Project="..\Directory.Build.props" />
   <PropertyGroup>
     <StrongNameKeyId>Microsoft</StrongNameKeyId>
+    <IsWindowsSpecific>true</IsWindowsSpecific>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index 465e111..42c6eaf 100644 (file)
@@ -3,5 +3,6 @@
   <PropertyGroup>
     <StrongNameKeyId>Microsoft</StrongNameKeyId>
     <IsNETCoreApp>true</IsNETCoreApp>
+    <IncludePlatformAttributes>true</IncludePlatformAttributes>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index f133b0e..07b51c0 100644 (file)
@@ -332,6 +332,7 @@ namespace System.Security.Cryptography.X509Certificates
     {
         public X509Chain() { }
         public X509Chain(bool useMachineContext) { }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public X509Chain(System.IntPtr chainContext) { }
         public System.IntPtr ChainContext { get { throw null; } }
         public System.Security.Cryptography.X509Certificates.X509ChainElementCollection ChainElements { get { throw null; } }
index 52e7cce..51d4001 100644 (file)
@@ -4,6 +4,7 @@
 using SafeX509ChainHandle = Microsoft.Win32.SafeHandles.SafeX509ChainHandle;
 using Internal.Cryptography.Pal;
 using System.Diagnostics;
+using System.Runtime.Versioning;
 
 namespace System.Security.Cryptography.X509Certificates
 {
@@ -23,6 +24,7 @@ namespace System.Security.Cryptography.X509Certificates
             _useMachineContext = useMachineContext;
         }
 
+        [MinimumOSPlatform("windows7.0")]
         public X509Chain(IntPtr chainContext)
         {
             _pal = ChainPal.FromHandle(chainContext);
index 8c72c62..27a4a55 100644 (file)
@@ -4,5 +4,6 @@
     <StrongNameKeyId>Microsoft</StrongNameKeyId>
     <IsNETCoreApp>true</IsNETCoreApp>
     <IsNETCoreAppRef>false</IsNETCoreAppRef>
+    <IsWindowsSpecific>true</IsWindowsSpecific>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index 63f02a0..33e65b7 100644 (file)
@@ -2,5 +2,6 @@
   <Import Project="..\Directory.Build.props" />
   <PropertyGroup>
     <StrongNameKeyId>Microsoft</StrongNameKeyId>
+    <IsWindowsSpecific>true</IsWindowsSpecific>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index 63f02a0..33e65b7 100644 (file)
@@ -2,5 +2,6 @@
   <Import Project="..\Directory.Build.props" />
   <PropertyGroup>
     <StrongNameKeyId>Microsoft</StrongNameKeyId>
+    <IsWindowsSpecific>true</IsWindowsSpecific>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index 465e111..0f058f1 100644 (file)
@@ -3,5 +3,6 @@
   <PropertyGroup>
     <StrongNameKeyId>Microsoft</StrongNameKeyId>
     <IsNETCoreApp>true</IsNETCoreApp>
+    <IsWindowsSpecific>true</IsWindowsSpecific>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index a2ef24a..142afde 100644 (file)
@@ -78,6 +78,7 @@ namespace System.Threading
         public static void ResetAbort() { }
         [System.ObsoleteAttribute("Thread.Resume has been deprecated.  Please use other classes in System.Threading, such as Monitor, Mutex, Event, and Semaphore, to synchronize Threads or protect resources.  https://go.microsoft.com/fwlink/?linkid=14202", false)]
         public void Resume() { }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public void SetApartmentState(System.Threading.ApartmentState state) { }
         [System.ObsoleteAttribute("Thread.SetCompressedStack is no longer supported. Please use the System.Threading.CompressedStack class")]
         public void SetCompressedStack(System.Threading.CompressedStack stack) { }
index 98124d7..d0f85e2 100644 (file)
@@ -115,9 +115,11 @@ namespace System.Threading
         public EventWaitHandle(bool initialState, System.Threading.EventResetMode mode) { }
         public EventWaitHandle(bool initialState, System.Threading.EventResetMode mode, string? name) { }
         public EventWaitHandle(bool initialState, System.Threading.EventResetMode mode, string? name, out bool createdNew) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static System.Threading.EventWaitHandle OpenExisting(string name) { throw null; }
         public bool Reset() { throw null; }
         public bool Set() { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static bool TryOpenExisting(string name, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Threading.EventWaitHandle? result) { throw null; }
     }
     public sealed partial class ExecutionContext : System.IDisposable, System.Runtime.Serialization.ISerializable
@@ -348,9 +350,11 @@ namespace System.Threading
         public Semaphore(int initialCount, int maximumCount) { }
         public Semaphore(int initialCount, int maximumCount, string? name) { }
         public Semaphore(int initialCount, int maximumCount, string? name, out bool createdNew) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static System.Threading.Semaphore OpenExisting(string name) { throw null; }
         public int Release() { throw null; }
         public int Release(int releaseCount) { throw null; }
+        [System.Runtime.Versioning.MinimumOSPlatformAttribute("windows7.0")]
         public static bool TryOpenExisting(string name, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Threading.Semaphore? result) { throw null; }
     }
     public partial class SemaphoreFullException : System.SystemException