Skip to content

Commit

Permalink
Added support for detecting .NET 5.0+ as .NET Core
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Seller authored and AndersAbel committed Nov 25, 2021
1 parent 75e1a8f commit 9fccf41
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
10 changes: 5 additions & 5 deletions Sustainsys.Saml2.Metadata/Helpers/EnvironmentHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ internal class EnvironmentHelpers
{
public static bool IsNetCore =>
#if NETSTANDARD2_0
RuntimeInformation.FrameworkDescription.
StartsWith(".NET Core", StringComparison.OrdinalIgnoreCase);

// To support .NET 5.0 and up, specifically check if this is not .NET Framework.
// Since .NET 5.0, the description no longer starts with ".NET Core", but simply ".NET".
!RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework", StringComparison.OrdinalIgnoreCase);
#else
// If not netstandard, then it is one of the .NET Framework targets. And
// If not netstandard, then it is one of the .NET Framework targets. And
// obviously not running on core.
false;
#endif
}
}
}
9 changes: 5 additions & 4 deletions Sustainsys.Saml2/Internal/EnvironmentHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
namespace Sustainsys.Saml2.Internal
{
public class EnvironmentHelpers
{
public static bool IsNetCore =>
{
public static bool IsNetCore =>
#if NETSTANDARD2_0
RuntimeInformation.FrameworkDescription.
StartsWith(".NET Core", StringComparison.OrdinalIgnoreCase);
// To support .NET 5.0 and up, specifically check if this is not .NET Framework.
// Since .NET 5.0, the description no longer starts with ".NET Core", but simply ".NET".
!RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework", StringComparison.OrdinalIgnoreCase);
#else
// If not netstandard, then it is one of the .NET Framework targets. And
// obviously not running on core.
Expand Down

0 comments on commit 9fccf41

Please sign in to comment.