Skip to content

Commit

Permalink
- Account for pre-4.0 .NET Framework versions
Browse files Browse the repository at this point in the history
  • Loading branch information
nwithan8 committed Jul 1, 2022
1 parent 63fd87f commit f84b4a6
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions EasyPost/RuntimeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,27 @@ internal static string DotNetVersion
{
get
{
string dotNetVersion = Environment.Version.ToString();
if (dotNetVersion == "4.0.30319.42000")
Version dotNetVersion = Environment.Version;
if (dotNetVersion == null)
{
/*
* We're on a pre-4.0 .NET Framework version, where Environment.Version is null.
*/
return "3.5-";
}

string versionString = dotNetVersion.ToString();
if (versionString == "4.0.30319.42000")
{
/*
* We're on a v4.6+ version (or pre-.NET Core 3.0, which we don't support),
* but we can't get the exact version.
* See: https://docs.microsoft.com/en-us/dotnet/api/system.environment.version?view=net-6.0#remarks
*/
dotNetVersion = "4.6+";
versionString = "4.6+";
}

return dotNetVersion;
return versionString;
}
}
}
Expand Down

0 comments on commit f84b4a6

Please sign in to comment.