-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathCsProjClassicNetToolchain.cs
More file actions
59 lines (53 loc) · 3.02 KB
/
CsProjClassicNetToolchain.cs
File metadata and controls
59 lines (53 loc) · 3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System.Collections.Generic;
using BenchmarkDotNet.Characteristics;
using BenchmarkDotNet.Portability;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Toolchains.DotNetCli;
using BenchmarkDotNet.Validators;
using JetBrains.Annotations;
namespace BenchmarkDotNet.Toolchains.CsProj
{
/// <summary>
/// this toolchain is designed for the new .csprojs, to build .NET 4.x benchmarks from the context of .NET Core host process
/// it does not work with the old .csprojs or project.json!
/// </summary>
[PublicAPI]
public class CsProjClassicNetToolchain : Toolchain
{
[PublicAPI] public static readonly IToolchain Net461 = new CsProjClassicNetToolchain("net461", ".NET Framework 4.6.1");
[PublicAPI] public static readonly IToolchain Net462 = new CsProjClassicNetToolchain("net462", ".NET Framework 4.6.2");
[PublicAPI] public static readonly IToolchain Net47 = new CsProjClassicNetToolchain("net47", ".NET Framework 4.7");
[PublicAPI] public static readonly IToolchain Net471 = new CsProjClassicNetToolchain("net471", ".NET Framework 4.7.1");
[PublicAPI] public static readonly IToolchain Net472 = new CsProjClassicNetToolchain("net472", ".NET Framework 4.7.2");
[PublicAPI] public static readonly IToolchain Net48 = new CsProjClassicNetToolchain("net48", ".NET Framework 4.8");
[PublicAPI] public static readonly IToolchain Net481 = new CsProjClassicNetToolchain("net481", ".NET Framework 4.8.1");
internal string CustomDotNetCliPath { get; }
private CsProjClassicNetToolchain(string targetFrameworkMoniker, string name, string packagesPath = null, string customDotNetCliPath = null)
: base(name,
new CsProjGenerator(targetFrameworkMoniker, customDotNetCliPath, packagesPath, runtimeFrameworkVersion: null, isNetCore: false),
new DotNetCliBuilder(targetFrameworkMoniker, customDotNetCliPath),
new Executor())
{
CustomDotNetCliPath = customDotNetCliPath;
}
public static IToolchain From(string targetFrameworkMoniker, string packagesPath = null, string customDotNetCliPath = null)
=> new CsProjClassicNetToolchain(targetFrameworkMoniker, targetFrameworkMoniker, packagesPath, customDotNetCliPath);
public override IEnumerable<ValidationError> Validate(BenchmarkCase benchmarkCase, IResolver resolver)
{
foreach (var validationError in base.Validate(benchmarkCase, resolver))
{
yield return validationError;
}
if (!RuntimeInformation.IsWindows())
{
yield return new ValidationError(true,
$"Classic .NET toolchain is supported only for Windows, benchmark '{benchmarkCase.DisplayInfo}' will not be executed",
benchmarkCase);
}
else if (IsCliPathInvalid(CustomDotNetCliPath, benchmarkCase, out var invalidCliError))
{
yield return invalidCliError;
}
}
}
}