You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow benchmark methods to use names that are used by code generation templates (fixes#2821) (#2897)
* Allow benchmark methods to use names that appear in source generation templates
* Use global:: prefix for setup, cleanup, and async benchmarks.
Fix missing prefixes.
Update Params and Arguments.
Remove ValidateNamingConflicts and test more name conflicts.
* Fix SmartParam and SmartArgument.
* Fix static param.
* Re-add sealed modifier.
* Fix InProcessBenchmarkEmitsSameIL test.
* Update comments.
---------
Co-authored-by: Tim Cassell <cassell.timothy@gmail.com>
.Select((parameter,index)=>$"__argField{index} = {benchmarkCase.Parameters.GetArgument(parameter.Name).ToSourceCode()};"));// we init the fields in ctor to provoke all possible allocations and overhead of other type
187
+
.Select((parameter,index)=>$"this.__argField{index} = {benchmarkCase.Parameters.GetArgument(parameter.Name).ToSourceCode()};"));// we init the fields in ctor to provoke all possible allocations and overhead of other type
Copy file name to clipboardExpand all lines: src/BenchmarkDotNet/Parameters/SmartParamBuilder.cs
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -125,7 +125,7 @@ public string ToSourceCode()
125
125
else
126
126
{
127
127
// If the source member is non-static, we mustn't include the type name, as this would be a compiler error when accessing a non-static source member in the base class of this generated type.
128
-
methodCall=source.Name;
128
+
methodCall=$"base.{source.Name}";
129
129
}
130
130
131
131
// we do something like enumerable.ElementAt(sourceIndex)[argumentIndex];
@@ -157,12 +157,12 @@ public string ToSourceCode()
157
157
{
158
158
stringcast=$"({parameterType.GetCorrectCSharpTypeName()})";// it's an object so we need to cast it to the right type
compositeLogger.WriteLineInfo($"Skipping {benchmarkRunInfo.BenchmarksCases.Length} benchmark(s) defined by {benchmarkRunInfo.Type.GetCorrectCSharpTypeName()}.");
140
+
compositeLogger.WriteLineInfo($"Skipping {benchmarkRunInfo.BenchmarksCases.Length} benchmark(s) defined by {benchmarkRunInfo.Type.GetCorrectCSharpTypeName(prefixWithGlobal:false)}.");
0 commit comments