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

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

merged 1 commit into from
Jul 21, 2020

Conversation

jeffhandley
Copy link
Member

@jeffhandley jeffhandley commented Jul 20, 2020

Port of #39265 into the release/5.0-preview8 branch.

Description

As part of the Platform Compatibility Analyzer feature set, this PR applies the new [MinimumOSPlatform("windows-7.0")] attribute to all Windows-specific APIs that shipped in or before .NET Core 3.1 and updates the project builds to indicate Windows-specific builds with a minimum version of 7.0.

Customer Impact

The Platform Compatibility Analyzer itself is being finished up and is expected to ship in the Preview 8 SDK through the roslyn-analyzers repo. The attributes this PR uses already exist in the Preview 8 branch, as do the IsOSPlatformOrLater and IsOSPlatformEarlierThan methods. This PR allows those features and the analyzer to work together in Preview 8 so that customers can preview the experience when consuming Windows-specific APIs.

Risk

Low. The only consumer of this metadata is the analyzer and the PR.

* 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>
@jeffhandley jeffhandley merged commit 42f89f5 into dotnet:release/5.0-preview8 Jul 21, 2020
@jeffhandley jeffhandley deleted the platform-compat-39265 branch July 21, 2020 03:10
@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants