Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/5.0-preview8] Mark Windows-specific APIs as such (#39265) #39657

Merged
merged 1 commit into from
Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eng/Configurations.props
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<NetCoreAppCurrentBrandName>.NET $(NetCoreAppCurrentVersion)</NetCoreAppCurrentBrandName>

<NetFrameworkCurrent>net472</NetFrameworkCurrent>
<MinimiumSupportedWindowsPlatform>WINDOWS7.0</MinimiumSupportedWindowsPlatform>
</PropertyGroup>

<!-- Honor the generic RuntimeConfiguration property. -->
Expand Down
7 changes: 7 additions & 0 deletions eng/versioning.targets
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
</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'">

Expand Down
12 changes: 9 additions & 3 deletions src/libraries/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,6 @@
<!-- 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>
Expand All @@ -240,6 +237,15 @@
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<Import Project="..\Directory.Build.props" />
<PropertyGroup>
<StrongNameKeyId>Microsoft</StrongNameKeyId>
<IsWindowsSpecific>true</IsWindowsSpecific>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<StrongNameKeyId>Microsoft</StrongNameKeyId>
<IsNETCoreApp>true</IsNETCoreApp>
<IsNETCoreAppRef>false</IsNETCoreAppRef>
<IsWindowsSpecific>true</IsWindowsSpecific>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<Import Project="..\Directory.Build.props" />
<PropertyGroup>
<StrongNameKeyId>Open</StrongNameKeyId>
<IsWindowsSpecific>true</IsWindowsSpecific>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<Import Project="..\Directory.Build.props" />
<PropertyGroup>
<StrongNameKeyId>Open</StrongNameKeyId>
<IncludePlatformAttributes>true</IncludePlatformAttributes>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ public DictionarySectionHandler() { }
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() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
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;
Expand Down
1 change: 1 addition & 0 deletions src/libraries/System.Console/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<PropertyGroup>
<StrongNameKeyId>Microsoft</StrongNameKeyId>
<IsNETCoreApp>true</IsNETCoreApp>
<IncludePlatformAttributes>true</IncludePlatformAttributes>
</PropertyGroup>
</Project>
28 changes: 18 additions & 10 deletions src/libraries/System.Console/ref/System.Console.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; } }
Expand All @@ -27,20 +27,25 @@ public static partial class Console
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; }
Expand All @@ -53,12 +58,15 @@ public static void MoveBufferArea(int sourceLeft, int sourceTop, int sourceWidth
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) { }
Expand Down
19 changes: 18 additions & 1 deletion src/libraries/System.Console/src/System/Console.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -277,14 +277,17 @@ static StrongBox<bool> EnsureInitialized()
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; }
Expand Down Expand Up @@ -312,15 +315,18 @@ public static void ResetColor()
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);
Expand All @@ -329,32 +335,38 @@ public static void SetBufferSize(int width, int height)
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);
Expand All @@ -372,6 +384,7 @@ public static int LargestWindowHeight

public static bool CursorVisible
{
[MinimumOSPlatform("windows7.0")]
get { return ConsolePal.CursorVisible; }
set { ConsolePal.CursorVisible = value; }
}
Expand Down Expand Up @@ -400,6 +413,7 @@ public static (int Left, int Top) GetCursorPosition()

public static string Title
{
[MinimumOSPlatform("windows7.0")]
get { return ConsolePal.Title; }
set
{
Expand All @@ -412,16 +426,19 @@ public static void Beep()
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<Import Project="..\Directory.Build.props" />
<PropertyGroup>
<StrongNameKeyId>Open</StrongNameKeyId>
<IsWindowsSpecific>true</IsWindowsSpecific>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<Import Project="..\Directory.Build.props" />
<PropertyGroup>
<StrongNameKeyId>Open</StrongNameKeyId>
<IsWindowsSpecific>true</IsWindowsSpecific>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<PropertyGroup>
<StrongNameKeyId>Microsoft</StrongNameKeyId>
<IsNETCoreApp>true</IsNETCoreApp>
<IncludePlatformAttributes>true</IncludePlatformAttributes>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public Process() { }
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; } }
Expand Down Expand Up @@ -116,8 +116,10 @@ public void Refresh() { }
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() { }
Expand Down Expand Up @@ -163,15 +165,19 @@ public ProcessStartInfo(string fileName, string arguments) { }
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 { } }
Expand All @@ -196,8 +202,9 @@ internal ProcessThread() { }
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; } }
Expand Down
Loading