33using BenchmarkDotNet . Configs ;
44using BenchmarkDotNet . Extensions ;
55using BenchmarkDotNet . Jobs ;
6+ using BenchmarkDotNet . Portability ;
67using Xunit ;
78
89namespace BenchmarkDotNet . IntegrationTests
910{
11+ // Note: To properly test this locally, modify
12+ // BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.csproj,
13+ // following the comments in that file.
1014 public class MultipleFrameworksTest : BenchmarkTestExecutor
1115 {
1216 private const string TfmEnvVarName = "TfmEnvVarName" ;
@@ -15,9 +19,23 @@ public class MultipleFrameworksTest : BenchmarkTestExecutor
1519 [ InlineData ( RuntimeMoniker . Net461 ) ]
1620 [ InlineData ( RuntimeMoniker . Net48 ) ]
1721 [ InlineData ( RuntimeMoniker . NetCoreApp20 ) ]
18- [ InlineData ( RuntimeMoniker . Net70 ) ]
22+ [ InlineData ( RuntimeMoniker . Net80 ) ]
1923 public void EachFrameworkIsRebuilt ( RuntimeMoniker runtime )
2024 {
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
2139 var config = ManualConfig . CreateEmpty ( ) . AddJob ( Job . Dry . WithRuntime ( runtime . GetRuntime ( ) ) . WithEnvironmentVariable ( TfmEnvVarName , runtime . ToString ( ) ) ) ;
2240 CanExecute < ValuePerTfm > ( config ) ;
2341 }
@@ -31,8 +49,8 @@ public class ValuePerTfm
3149 RuntimeMoniker . Net48 ;
3250#elif NETCOREAPP2_0
3351 RuntimeMoniker . NetCoreApp20 ;
34- #elif NET7_0
35- RuntimeMoniker . Net70 ;
52+ #elif NET8_0
53+ RuntimeMoniker . Net80 ;
3654#else
3755 RuntimeMoniker . NotRecognized ;
3856#endif
0 commit comments