-
-
Notifications
You must be signed in to change notification settings - Fork 969
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rebuild .Net Framework projects (#2370)
* Added `CsProjWithRoslynFallbackToolchain` for .Net Framework projects to be able to be rebuilt per target framework. * Move manual tests to separate solution. * Test old frameworks and test that recompilation actually happens. * Removed ClassicNetFramework project. Moved manual test projects back to main sln. * Removed `CsProjWithRoslynFallbackToolchain`, default to `CsProjClassicNetToolchain` instead. * Use RoslynToolchain if dotnet SDK is not installed. * Fix test. * Revert xunit.runner.json. Implement feedback. * Try to fix json file * Removed redundant commented line.
- Loading branch information
1 parent
64d05c6
commit d93490d
Showing
6 changed files
with
122 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...ltipleFrameworks/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Import Project="..\..\build\common.props" /> | ||
<PropertyGroup> | ||
<AssemblyTitle>BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks</AssemblyTitle> | ||
<!-- We test the oldest frameworks supported by BDN (net461 and netcoreapp2.0), as well as newer versions of those frameworks. --> | ||
<TargetFrameworks>net461;net48;netcoreapp2.0;net7.0</TargetFrameworks> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<AssemblyName>BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks</AssemblyName> | ||
<PackageId>BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks</PackageId> | ||
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> | ||
<GenerateDocumentationFile>false</GenerateDocumentationFile> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="..\BenchmarkDotNet.IntegrationTests\BenchmarkTestExecutor.cs" Link="BenchmarkTestExecutor.cs" /> | ||
<Compile Include="..\BenchmarkDotNet.IntegrationTests\Xunit\MisconfiguredEnvironmentException.cs" Link="MisconfiguredEnvironmentException.cs" /> | ||
<Compile Include="..\BenchmarkDotNet.IntegrationTests\Xunit\Extensions.cs" Link="Extensions.cs" /> | ||
<Compile Include="..\BenchmarkDotNet.IntegrationTests\TestConfigs.cs" Link="TestConfigs.cs" /> | ||
<Compile Include="..\BenchmarkDotNet.Tests\Loggers\OutputLogger.cs" Link="OutputLogger.cs" /> | ||
<Compile Include="..\BenchmarkDotNet.Tests\XUnit\SmartAssert.cs" Link="SmartAssert.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NETCore.Platforms" Version="5.0.0" /> | ||
<PackageReference Include="System.Memory" Version="4.5.5" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Content Include="..\BenchmarkDotNet.IntegrationTests.ManualRunning\xunit.runner.json"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\BenchmarkDotNet.Annotations\BenchmarkDotNet.Annotations.csproj" /> | ||
<ProjectReference Include="..\..\src\BenchmarkDotNet\BenchmarkDotNet.csproj" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<!-- Microsoft.NET.Test.Sdk breaks netcoreapp2.0 --> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.3" Condition=" '$(TargetFramework)' != 'netcoreapp2.0' " /> | ||
<PackageReference Include="xunit" Version="2.5.0" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
</Project> |
50 changes: 50 additions & 0 deletions
50
...nchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/MultipleFrameworksTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System; | ||
using BenchmarkDotNet.Attributes; | ||
using BenchmarkDotNet.Configs; | ||
using BenchmarkDotNet.Extensions; | ||
using BenchmarkDotNet.Jobs; | ||
using Xunit; | ||
|
||
namespace BenchmarkDotNet.IntegrationTests | ||
{ | ||
public class MultipleFrameworksTest : BenchmarkTestExecutor | ||
{ | ||
private const string TfmEnvVarName = "TfmEnvVarName"; | ||
|
||
[Theory] | ||
[InlineData(RuntimeMoniker.Net461)] | ||
[InlineData(RuntimeMoniker.Net48)] | ||
[InlineData(RuntimeMoniker.NetCoreApp20)] | ||
[InlineData(RuntimeMoniker.Net70)] | ||
public void EachFrameworkIsRebuilt(RuntimeMoniker runtime) | ||
{ | ||
var config = ManualConfig.CreateEmpty().AddJob(Job.Dry.WithRuntime(runtime.GetRuntime()).WithEnvironmentVariable(TfmEnvVarName, runtime.ToString())); | ||
CanExecute<ValuePerTfm>(config); | ||
} | ||
|
||
public class ValuePerTfm | ||
{ | ||
private const RuntimeMoniker moniker = | ||
#if NET461 | ||
RuntimeMoniker.Net461; | ||
#elif NET48 | ||
RuntimeMoniker.Net48; | ||
#elif NETCOREAPP2_0 | ||
RuntimeMoniker.NetCoreApp20; | ||
#elif NET7_0 | ||
RuntimeMoniker.Net70; | ||
#else | ||
RuntimeMoniker.NotRecognized; | ||
#endif | ||
|
||
[Benchmark] | ||
public void ThrowWhenWrong() | ||
{ | ||
if (Environment.GetEnvironmentVariable(TfmEnvVarName) != moniker.ToString()) | ||
{ | ||
throw new InvalidOperationException($"Has not been recompiled, the value was {Environment.GetEnvironmentVariable(TfmEnvVarName)}"); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters