File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
src/BenchmarkDotNet/Environments/Runtimes Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,13 @@ internal static bool TryGetVersion(out Version version)
76
76
// we can't just use System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription
77
77
// because it can be null and it reports versions like 4.6.* for .NET Core 2.*
78
78
79
+ // for .NET 5+ we can use Environment.Version
80
+ if ( Environment . Version . Major >= 5 )
81
+ {
82
+ version = Environment . Version ;
83
+ return true ;
84
+ }
85
+
79
86
string runtimeDirectory = System . Runtime . InteropServices . RuntimeEnvironment . GetRuntimeDirectory ( ) ;
80
87
if ( TryGetVersionFromRuntimeDirectory ( runtimeDirectory , out version ) )
81
88
{
@@ -89,6 +96,9 @@ internal static bool TryGetVersion(out Version version)
89
96
return true ;
90
97
}
91
98
99
+ // it's OK to use this method only after checking the previous ones
100
+ // because we might have a benchmark app build for .NET Core X but executed using CoreRun Y
101
+ // example: -f netcoreapp3.1 --corerun $omittedForBrevity\Microsoft.NETCore.App\6.0.0\CoreRun.exe - built as 3.1, run as 6.0 (#1576)
92
102
string frameworkName = Assembly . GetEntryAssembly ( ) ? . GetCustomAttribute < TargetFrameworkAttribute > ( ) ? . FrameworkName ;
93
103
if ( TryGetVersionFromFrameworkName ( frameworkName , out version ) )
94
104
{
You can’t perform that action at this time.
0 commit comments