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

Commit

Permalink
Better handling of VersionId being missing.
Browse files Browse the repository at this point in the history
  • Loading branch information
GurliGebis committed May 15, 2017
1 parent 7009256 commit b6aa0e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,8 @@ private static DistroInfo LoadDistroInfo()
// are backwards compatible.
private static DistroInfo NormalizeDistroInfo(DistroInfo distroInfo)
{
if (string.IsNullOrEmpty(distroInfo.VersionId))
{
// Some distribution does not have VERSION_ID defined.
// Since we need it, we workaround this by giving it the value "unavailable".
distroInfo.VersionId = "unavailable";
}

int minorVersionNumberSeparatorIndex = distroInfo.VersionId.IndexOf('.');
// Handle if VersionId is null by just setting the index to -1.
int minorVersionNumberSeparatorIndex = distroInfo.VersionId?.IndexOf('.') ?? -1;

if (distroInfo.Id == "rhel" && minorVersionNumberSeparatorIndex != -1)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ private static string GetRIDVersion()
case Platform.Windows:
return GetWindowsProductVersion();
case Platform.Linux:
if (string.IsNullOrEmpty(OperatingSystemVersion))
{
return string.Empty;
}

return $".{OperatingSystemVersion}";
case Platform.Darwin:
return $".{OperatingSystemVersion}";
Expand Down

0 comments on commit b6aa0e6

Please sign in to comment.