Skip to content

Commit 2af26c2

Browse files
authored
Removed unused AdditionalLogic. (#2940)
1 parent c106b65 commit 2af26c2

File tree

5 files changed

+1
-23
lines changed

5 files changed

+1
-23
lines changed

src/BenchmarkDotNet/Code/CodeGenerator.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ internal static string Generate(BuildPartition buildPartition)
2828
var benchmarksCode = new List<string>(buildPartition.Benchmarks.Length);
2929

3030
var extraDefines = new List<string>();
31-
var additionalLogic = new HashSet<string>();
3231

3332
foreach (var buildInfo in buildPartition.Benchmarks)
3433
{
@@ -38,8 +37,6 @@ internal static string Generate(BuildPartition buildPartition)
3837

3938
string passArguments = GetPassArguments(benchmark);
4039

41-
AddNonEmptyUnique(additionalLogic, benchmark.Descriptor.AdditionalLogic);
42-
4340
string benchmarkTypeCode = new SmartStringBuilder(ResourceHelper.LoadTemplate("BenchmarkType.txt"))
4441
.Replace("$ID$", buildInfo.Id.ToString())
4542
.Replace("$OperationsPerInvoke$", provider.OperationsPerInvoke)
@@ -77,7 +74,6 @@ internal static string Generate(BuildPartition buildPartition)
7774
string benchmarkProgramContent = new SmartStringBuilder(ResourceHelper.LoadTemplate("BenchmarkProgram.txt"))
7875
.Replace("$ShadowCopyDefines$", useShadowCopy ? "#define SHADOWCOPY" : null).Replace("$ShadowCopyFolderPath$", shadowCopyFolderPath)
7976
.Replace("$ExtraDefines$", string.Join(Environment.NewLine, extraDefines))
80-
.Replace("$AdditionalLogic$", string.Join(Environment.NewLine, additionalLogic))
8177
.Replace("$DerivedTypes$", string.Join(Environment.NewLine, benchmarksCode))
8278
.Replace("$ExtraAttribute$", GetExtraAttributes(buildPartition.RepresentativeBenchmarkCase.Descriptor))
8379
.Replace("$NativeAotSwitch$", GetNativeAotSwitch(buildPartition))

src/BenchmarkDotNet/Running/BenchmarkPartitioner.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ public bool Equals(BenchmarkCase x, BenchmarkCase y)
4949
if (x.Descriptor.Type.Assembly.Location != y.Descriptor.Type.Assembly.Location) // some toolchains produce the exe in the same folder as .dll (to get some scenarios like native dependencies work)
5050
return false;
5151

52-
if (x.Descriptor.AdditionalLogic != y.Descriptor.AdditionalLogic) // it can be anything
53-
return false;
54-
5552
if (x.Descriptor.WorkloadMethod.GetCustomAttributes(false).OfType<STAThreadAttribute>().Count() !=
5653
y.Descriptor.WorkloadMethod.GetCustomAttributes(false).OfType<STAThreadAttribute>().Count()) // STA vs STA
5754
return false;
@@ -65,7 +62,6 @@ public int GetHashCode(BenchmarkCase obj)
6562
hashCode.Add(obj.GetToolchain());
6663
hashCode.Add(obj.GetRuntime());
6764
hashCode.Add(obj.Descriptor.Type.Assembly.Location);
68-
hashCode.Add(obj.Descriptor.AdditionalLogic);
6965
hashCode.Add(obj.Descriptor.WorkloadMethod.GetCustomAttributes(false).OfType<STAThreadAttribute>().Any());
7066
var job = obj.Job;
7167
hashCode.Add(job.Environment.Jit);

src/BenchmarkDotNet/Running/Descriptor.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public class Descriptor : IEquatable<Descriptor>
1515
public MethodInfo? GlobalCleanupMethod { get; }
1616
public MethodInfo? IterationSetupMethod { get; }
1717
public MethodInfo? IterationCleanupMethod { get; }
18-
public string AdditionalLogic { get; }
1918
public int OperationsPerInvoke { get; }
2019
public string WorkloadMethodDisplayInfo { get; }
2120
public int MethodIndex { get; }
@@ -36,7 +35,6 @@ public Descriptor(
3635
MethodInfo? iterationSetupMethod = null,
3736
MethodInfo? iterationCleanupMethod = null,
3837
string? description = null,
39-
string? additionalLogic = null,
4038
bool baseline = false,
4139
string[]? categories = null,
4240
int operationsPerInvoke = 1,
@@ -52,10 +50,9 @@ public Descriptor(
5250
IterationSetupMethod = iterationSetupMethod;
5351
IterationCleanupMethod = iterationCleanupMethod;
5452
OperationsPerInvoke = operationsPerInvoke;
55-
AdditionalLogic = additionalLogic ?? string.Empty;
5653
WorkloadMethodDisplayInfo = FormatDescription(description) ?? workloadMethod?.Name ?? "Untitled";
5754
Baseline = baseline;
58-
Categories = categories ?? Array.Empty<string>();
55+
Categories = categories ?? [];
5956
MethodIndex = methodIndex;
6057
}
6158

src/BenchmarkDotNet/Templates/BenchmarkProgram.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
$ShadowCopyDefines$
22
$ExtraDefines$
33
// <auto-generated />
4-
$AdditionalLogic$
54
// this file must not be importing any namespaces
65
// we should use full names everywhere to avoid any potential naming conflicts, example: #1007, #778
76

src/BenchmarkDotNet/Toolchains/InProcess/InProcessValidator.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,6 @@ private InProcessValidator(bool failOnErrors)
144144
/// <returns>Enumerable of validation errors.</returns>
145145
public IEnumerable<ValidationError> Validate(ValidationParameters validationParameters)
146146
{
147-
foreach (var target in validationParameters.Benchmarks
148-
.Where(benchmark => benchmark.Descriptor.AdditionalLogic.IsNotBlank())
149-
.Select(b => b.Descriptor)
150-
.Distinct())
151-
{
152-
yield return new ValidationError(
153-
false,
154-
$"Target {target} has {nameof(target.AdditionalLogic)} filled. AdditionalLogic is not supported by in-process toolchain.");
155-
}
156-
157147
foreach (var benchmarkWithArguments in validationParameters.Benchmarks.Where(benchmark => benchmark.HasArguments && benchmark.GetToolchain() is InProcessNoEmitToolchain))
158148
yield return new ValidationError(true, "Arguments are not supported by the InProcessNoEmitToolchain, see #687 for more details", benchmarkWithArguments);
159149

0 commit comments

Comments
 (0)