-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Mark existing Windows-specific APIs without a version number #40095
Labels
api-approved
API was approved in API review, it can be implemented
area-System.Runtime.InteropServices
code-analyzer
Marks an issue that suggests a Roslyn analyzer
Milestone
Comments
/cc @adamsitnik |
Contributor
Author
[SupportedOSPlatform("windows")]
public void TheRegistry() { ... }
public void DoSomething()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
TheRegistry();
} |
@adamsitnik, please replace
with
|
adamsitnik
added a commit
to adamsitnik/runtime
that referenced
this issue
Aug 5, 2020
adamsitnik
added a commit
that referenced
this issue
Aug 5, 2020
Jacksondr5
pushed a commit
to Jacksondr5/runtime
that referenced
this issue
Aug 10, 2020
# for free
to subscribe to this conversation on GitHub.
Already have an account?
#.
Labels
api-approved
API was approved in API review, it can be implemented
area-System.Runtime.InteropServices
code-analyzer
Marks an issue that suggests a Roslyn analyzer
We'd like change our stance on marking the existing Windows-specific not as
windows7.0
but as justwindows
.From the spec:
The lowest version of Windows that we support with .NET Core is Windows 7. Also, we generally don't expose functionality that requires a higher version of Windows.
We originally said we'll mark these APIs as
windows7.0
but this would mean that callers have to call guard these APIs with a7.0
version check too, which isn't really necessary. But what's worse is that many developers already have written code that checks for the OS but not version, and due to the version support that is perfectly correct code.We decided that it's better for our analyzer to special case version-less checks and let it be equivalent of a check for
0.0
. We also decided that applying the attribute without a version is the same as stating the API was introduced in0.0
.The net effect is that consumers of the existing Windows-specific APIs will get away with just checking for the OS. So the existing code in
DoSomething()
will not cause a warning when we add the annotation toTheRegistry()
:Moving forward, we'll only tag Windows-specific APIs without version if they are supported by Windows 7 or earlier. APIs requiring newer OS versions will be marked with the corresponding OS version.
/cc @jeffhandley @eerhardt @buyaa-n @bartonjs
The text was updated successfully, but these errors were encountered: