3
3
using BenchmarkDotNet . Configs ;
4
4
using BenchmarkDotNet . Extensions ;
5
5
using BenchmarkDotNet . Jobs ;
6
+ using BenchmarkDotNet . Portability ;
6
7
using Xunit ;
7
8
8
9
namespace BenchmarkDotNet . IntegrationTests
9
10
{
11
+ // Note: To properly test this locally, modify
12
+ // BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.csproj,
13
+ // following the comments in that file.
10
14
public class MultipleFrameworksTest : BenchmarkTestExecutor
11
15
{
12
16
private const string TfmEnvVarName = "TfmEnvVarName" ;
@@ -15,9 +19,23 @@ public class MultipleFrameworksTest : BenchmarkTestExecutor
15
19
[ InlineData ( RuntimeMoniker . Net461 ) ]
16
20
[ InlineData ( RuntimeMoniker . Net48 ) ]
17
21
[ InlineData ( RuntimeMoniker . NetCoreApp20 ) ]
18
- [ InlineData ( RuntimeMoniker . Net70 ) ]
22
+ [ InlineData ( RuntimeMoniker . Net80 ) ]
19
23
public void EachFrameworkIsRebuilt ( RuntimeMoniker runtime )
20
24
{
25
+ #if NET461
26
+ // We cannot detect what target framework version the host was compiled for on full Framework,
27
+ // which causes the RoslynToolchain to be used instead of CsProjClassicNetToolchain when the host is full Framework
28
+ // (because full Framework always uses the version that's installed on the machine, unlike Core),
29
+ // which means if the machine has net48 installed (not net481), the net461 host with net48 runtime moniker
30
+ // will not be recompiled, causing the test to fail.
31
+
32
+ // If we ever change the default toolchain to CsProjClassicNetToolchain instead of RoslynToolchain, we can remove this check.
33
+ if ( runtime == RuntimeMoniker . Net48 )
34
+ {
35
+ // XUnit doesn't provide Assert.Skip API yet.
36
+ return ;
37
+ }
38
+ #endif
21
39
var config = ManualConfig . CreateEmpty ( ) . AddJob ( Job . Dry . WithRuntime ( runtime . GetRuntime ( ) ) . WithEnvironmentVariable ( TfmEnvVarName , runtime . ToString ( ) ) ) ;
22
40
CanExecute < ValuePerTfm > ( config ) ;
23
41
}
@@ -31,8 +49,8 @@ public class ValuePerTfm
31
49
RuntimeMoniker . Net48 ;
32
50
#elif NETCOREAPP2_0
33
51
RuntimeMoniker . NetCoreApp20 ;
34
- #elif NET7_0
35
- RuntimeMoniker . Net70 ;
52
+ #elif NET8_0
53
+ RuntimeMoniker . Net80 ;
36
54
#else
37
55
RuntimeMoniker . NotRecognized ;
38
56
#endif
0 commit comments