Skip to content

Update remarks for Enviroment.OSVersion #8996

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

Merged
merged 3 commits into from
May 5, 2023
Merged
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
4 changes: 3 additions & 1 deletion xml/System/Environment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1765,7 +1765,9 @@ The following example creates environment variables for the <xref:System.Environ

## Remarks

In .NET versions prior to .NET 5, <xref:System.Environment.OSVersion?displayProperty=nameWithType> returns an OS version that may be incorrect when an application runs under Windows compatibility mode. For more information, see [GetVersionExA function remarks](/windows/win32/api/sysinfoapi/nf-sysinfoapi-getversionexa#remarks). In .NET 5 and later versions, <xref:System.Environment.OSVersion?displayProperty=nameWithType> always returns the actual OS version. For more information, see [Environment.OSVersion returns the correct operating system version](/dotnet/core/compatibility/core-libraries/5.0/environment-osversion-returns-correct-version).
<xref:System.Environment.OSVersion?displayProperty=nameWithType> returns an OS version that may be incorrect when an application runs under Windows compatibility mode. For more information, see [GetVersionExA function remarks](/windows/win32/api/sysinfoapi/nf-sysinfoapi-getversionexa#remarks).

In .NET 5 and later versions, <xref:System.Environment.OSVersion?displayProperty=nameWithType> returns the actual OS version in compatibility modes specified by the [application manifest](/windows/win32/sysinfo/targeting-your-application-at-windows-8-1). For more information, see [Environment.OSVersion returns the correct operating system version](/dotnet/core/compatibility/core-libraries/5.0/environment-osversion-returns-correct-version).

To identify the operating system platform, for example, Linux or Windows, you can use the <xref:System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform%2A?displayProperty=nameWithType> method.

Expand Down