Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Change Environment.Version to return product version
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotas committed Feb 17, 2019
1 parent 7760228 commit 472e3b8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/System.Private.CoreLib/shared/System/Environment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,22 @@ public static OperatingSystem OSVersion

public static bool UserInteractive => true;

// Previously this represented the File version of mscorlib.dll. Many other libraries in the framework and outside took dependencies on the first three parts of this version
// remaining constant throughout 4.x. From 4.0 to 4.5.2 this was fine since the file version only incremented the last part. Starting with 4.6 we switched to a file versioning
// scheme that matched the product version. In order to preserve compatibility with existing libraries, this needs to be hard-coded.
public static Version Version => new Version(4, 0, 30319, 42000);
public static Version Version
{
get
{
// FX_PRODUCT_VERSION is expected to be set by the host
ReadOnlySpan<char> versionString = ((string)AppContext.GetData("FX_PRODUCT_VERSION")).AsSpan();

// Strip optional suffix for previews, e.g. 3.0.0-preview-27331-3
int dashIndex = versionString.IndexOf('-');
if (dashIndex != -1)
versionString = versionString.Slice(0, dashIndex);

// Return zeros rather then failing if the version string fails to parse
return Version.TryParse(versionString, out Version version) ? version : new Version();
}
}

public static long WorkingSet
{
Expand Down
4 changes: 4 additions & 0 deletions tests/CoreFX/CoreFX.issues.json
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,10 @@
"name": "System.Tests.MathFTests.Min",
"reason": "https://github.com/dotnet/coreclr/pull/20912"
},
{
"name": "System.Tests.EnvironmentTests.Version_MatchesFixedVersion",
"reason": "outdated"
},
]
}
},
Expand Down

0 comments on commit 472e3b8

Please sign in to comment.