Skip to content

Mark existing Windows-specific APIs without a version number #40095

@terrajobst

Description

@terrajobst

We'd like change our stance on marking the existing Windows-specific not as windows7.0 but as just windows.

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 a 7.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 in 0.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 to TheRegistry():

[SupportedOSPlatform("windows")]
public void TheRegistry() { ... }

public void DoSomething()
{
    if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
        TheRegistry();
}

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

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions