diff --git a/src/BenchmarkDotNet/Characteristics/CharacteristicPresenter.cs b/src/BenchmarkDotNet/Characteristics/CharacteristicPresenter.cs
index 4e90742b73..063991d47b 100644
--- a/src/BenchmarkDotNet/Characteristics/CharacteristicPresenter.cs
+++ b/src/BenchmarkDotNet/Characteristics/CharacteristicPresenter.cs
@@ -81,7 +81,7 @@ public override string ToPresentation(object characteristicValue, Characteristic
{
// TODO: DO NOT hardcode Characteristic suffix
string id = characteristic.Id;
- string type = characteristic.DeclaringType.FullName;
+ string type = characteristic.DeclaringType.GetCorrectCSharpTypeName();
string value = SourceCodeHelper.ToSourceCode(characteristicValue);
return $"{type}.{id}Characteristic[job] = {value}";
}
diff --git a/src/BenchmarkDotNet/Code/DeclarationsProvider.cs b/src/BenchmarkDotNet/Code/DeclarationsProvider.cs
index 7528e8ed62..169ee5d822 100644
--- a/src/BenchmarkDotNet/Code/DeclarationsProvider.cs
+++ b/src/BenchmarkDotNet/Code/DeclarationsProvider.cs
@@ -36,11 +36,15 @@ internal abstract class DeclarationsProvider
public virtual string WorkloadMethodReturnTypeName => WorkloadMethodReturnType.GetCorrectCSharpTypeName();
- public virtual string WorkloadMethodDelegate(string passArguments) => Descriptor.WorkloadMethod.Name;
+ public string WorkloadMethodPrefix => Descriptor.WorkloadMethod.IsStatic ? Descriptor.WorkloadMethod.DeclaringType.GetCorrectCSharpTypeName() : "base";
+
+ public virtual string WorkloadMethodDelegate(string passArguments)
+ => $"{WorkloadMethodPrefix}.{Descriptor.WorkloadMethod.Name}";
public virtual string WorkloadMethodReturnTypeModifiers => null;
- public virtual string GetWorkloadMethodCall(string passArguments) => $"{Descriptor.WorkloadMethod.Name}({passArguments})";
+ public virtual string GetWorkloadMethodCall(string passArguments)
+ => $"{WorkloadMethodPrefix}.{Descriptor.WorkloadMethod.Name}({passArguments})";
public virtual string ConsumeField => null;
@@ -150,9 +154,10 @@ internal class TaskDeclarationsProvider : VoidDeclarationsProvider
public TaskDeclarationsProvider(Descriptor descriptor) : base(descriptor) { }
public override string WorkloadMethodDelegate(string passArguments)
- => $"({passArguments}) => {{ BenchmarkDotNet.Helpers.AwaitHelper.GetResult({Descriptor.WorkloadMethod.Name}({passArguments})); }}";
+ => $"({passArguments}) => {{ BenchmarkDotNet.Helpers.AwaitHelper.GetResult({WorkloadMethodPrefix}.{Descriptor.WorkloadMethod.Name}({passArguments})); }}";
- public override string GetWorkloadMethodCall(string passArguments) => $"BenchmarkDotNet.Helpers.AwaitHelper.GetResult({Descriptor.WorkloadMethod.Name}({passArguments}))";
+ public override string GetWorkloadMethodCall(string passArguments)
+ => $"BenchmarkDotNet.Helpers.AwaitHelper.GetResult({WorkloadMethodPrefix}.{Descriptor.WorkloadMethod.Name}({passArguments}))";
protected override Type WorkloadMethodReturnType => typeof(void);
}
@@ -167,8 +172,9 @@ public GenericTaskDeclarationsProvider(Descriptor descriptor) : base(descriptor)
protected override Type WorkloadMethodReturnType => Descriptor.WorkloadMethod.ReturnType.GetTypeInfo().GetGenericArguments().Single();
public override string WorkloadMethodDelegate(string passArguments)
- => $"({passArguments}) => {{ return BenchmarkDotNet.Helpers.AwaitHelper.GetResult({Descriptor.WorkloadMethod.Name}({passArguments})); }}";
+ => $"({passArguments}) => {{ return BenchmarkDotNet.Helpers.AwaitHelper.GetResult({WorkloadMethodPrefix}.{Descriptor.WorkloadMethod.Name}({passArguments})); }}";
- public override string GetWorkloadMethodCall(string passArguments) => $"BenchmarkDotNet.Helpers.AwaitHelper.GetResult({Descriptor.WorkloadMethod.Name}({passArguments}))";
+ public override string GetWorkloadMethodCall(string passArguments)
+ => $"BenchmarkDotNet.Helpers.AwaitHelper.GetResult({WorkloadMethodPrefix}.{Descriptor.WorkloadMethod.Name}({passArguments}))";
}
}
\ No newline at end of file
diff --git a/src/BenchmarkDotNet/Extensions/ReflectionExtensions.cs b/src/BenchmarkDotNet/Extensions/ReflectionExtensions.cs
index 5708ba7a38..8e67a28e8c 100644
--- a/src/BenchmarkDotNet/Extensions/ReflectionExtensions.cs
+++ b/src/BenchmarkDotNet/Extensions/ReflectionExtensions.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
using BenchmarkDotNet.Attributes;
namespace BenchmarkDotNet.Extensions
@@ -36,7 +37,7 @@ public static bool IsInitOnly(this PropertyInfo propertyInfo)
///
/// returns type name which can be used in generated C# code
///
- internal static string GetCorrectCSharpTypeName(this Type type, bool includeNamespace = true, bool includeGenericArgumentsNamespace = true)
+ internal static string GetCorrectCSharpTypeName(this Type type, bool includeNamespace = true, bool includeGenericArgumentsNamespace = true, bool prefixWithGlobal = true)
{
while (!(type.IsPublic || type.IsNestedPublic) && type.BaseType != null)
type = type.BaseType;
@@ -49,16 +50,23 @@ internal static string GetCorrectCSharpTypeName(this Type type, bool includeName
return "void";
if (type == typeof(void*))
return "void*";
+
string prefix = "";
+
if (!string.IsNullOrEmpty(type.Namespace) && includeNamespace)
+ {
prefix += type.Namespace + ".";
+ if (prefixWithGlobal)
+ prefix = $"global::{prefix}";
+ }
+
if (type.GetTypeInfo().IsGenericParameter)
return type.Name;
if (type.IsArray)
{
- var typeName = GetCorrectCSharpTypeName(type.GetElementType());
+ var typeName = GetCorrectCSharpTypeName(type.GetElementType(), includeNamespace, includeGenericArgumentsNamespace, prefixWithGlobal);
var parts = typeName.Split(['['], count: 2);
string repr = parts[0] + '[' + new string(',', type.GetArrayRank() - 1) + ']';
@@ -68,11 +76,11 @@ internal static string GetCorrectCSharpTypeName(this Type type, bool includeName
return repr;
}
- return prefix + string.Join(".", GetNestedTypeNames(type, includeGenericArgumentsNamespace).Reverse());
+ return prefix + string.Join(".", GetNestedTypeNames(type, includeGenericArgumentsNamespace, prefixWithGlobal).Reverse());
}
// from most nested to least
- private static IEnumerable GetNestedTypeNames(Type type, bool includeGenericArgumentsNamespace)
+ private static IEnumerable GetNestedTypeNames(Type type, bool includeGenericArgumentsNamespace, bool prefixWithGlobal)
{
var allTypeParameters = new Stack(type.GetGenericArguments());
@@ -92,7 +100,7 @@ private static IEnumerable GetNestedTypeNames(Type type, bool includeGen
.Select(_ => allTypeParameters.Pop())
.Reverse();
- var args = string.Join(", ", typeParameters.Select(T => GetCorrectCSharpTypeName(T, includeGenericArgumentsNamespace, includeGenericArgumentsNamespace)));
+ var args = string.Join(", ", typeParameters.Select(T => GetCorrectCSharpTypeName(T, includeGenericArgumentsNamespace, includeGenericArgumentsNamespace, prefixWithGlobal)));
name = $"{mainName}<{args}>";
}
diff --git a/src/BenchmarkDotNet/Helpers/FolderNameHelper.cs b/src/BenchmarkDotNet/Helpers/FolderNameHelper.cs
index 01bb71dd36..c2e4c845e9 100644
--- a/src/BenchmarkDotNet/Helpers/FolderNameHelper.cs
+++ b/src/BenchmarkDotNet/Helpers/FolderNameHelper.cs
@@ -42,7 +42,7 @@ public static string ToFolderName(object value)
// we can't simply use type.FullName, because for generics it's too long
// example: typeof(List).FullName => "System.Collections.Generic.List`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"
public static string ToFolderName(Type type, bool includeNamespace = true, bool includeGenericArgumentsNamespace = false)
- => Escape(new StringBuilder(type.GetCorrectCSharpTypeName(includeNamespace, includeGenericArgumentsNamespace)));
+ => Escape(new StringBuilder(type.GetCorrectCSharpTypeName(includeNamespace, includeGenericArgumentsNamespace, prefixWithGlobal: false)));
private static string Escape(StringBuilder builder)
{
diff --git a/src/BenchmarkDotNet/Running/BenchmarkRunnerClean.cs b/src/BenchmarkDotNet/Running/BenchmarkRunnerClean.cs
index 69ef36d8be..3f7c7aad1d 100644
--- a/src/BenchmarkDotNet/Running/BenchmarkRunnerClean.cs
+++ b/src/BenchmarkDotNet/Running/BenchmarkRunnerClean.cs
@@ -137,7 +137,7 @@ internal static Summary[] Run(BenchmarkRunInfo[] benchmarkRunInfos)
var benchmarkWithHighestIdForGivenType = benchmarkRunInfo.BenchmarksCases.Last();
if (benchmarkToBuildResult[benchmarkWithHighestIdForGivenType].Id.Value <= idToResume)
{
- compositeLogger.WriteLineInfo($"Skipping {benchmarkRunInfo.BenchmarksCases.Length} benchmark(s) defined by {benchmarkRunInfo.Type.GetCorrectCSharpTypeName()}.");
+ compositeLogger.WriteLineInfo($"Skipping {benchmarkRunInfo.BenchmarksCases.Length} benchmark(s) defined by {benchmarkRunInfo.Type.GetCorrectCSharpTypeName(prefixWithGlobal: false)}.");
continue;
}
}
diff --git a/src/BenchmarkDotNet/Running/Descriptor.cs b/src/BenchmarkDotNet/Running/Descriptor.cs
index 4ff74fced7..87df323646 100644
--- a/src/BenchmarkDotNet/Running/Descriptor.cs
+++ b/src/BenchmarkDotNet/Running/Descriptor.cs
@@ -71,7 +71,7 @@ public Descriptor(
public bool HasCategory(string category) => Categories.Any(c => c.EqualsWithIgnoreCase(category));
- public string GetFilterName() => $"{Type.GetCorrectCSharpTypeName(includeGenericArgumentsNamespace: false)}.{WorkloadMethod.Name}";
+ public string GetFilterName() => $"{Type.GetCorrectCSharpTypeName(includeGenericArgumentsNamespace: false, prefixWithGlobal: false)}.{WorkloadMethod.Name}";
public bool Equals(Descriptor? other) => GetFilterName().Equals(other?.GetFilterName());
diff --git a/src/BenchmarkDotNet/Templates/BenchmarkProgram.txt b/src/BenchmarkDotNet/Templates/BenchmarkProgram.txt
index fa830ecd09..2ceeda3a9b 100644
--- a/src/BenchmarkDotNet/Templates/BenchmarkProgram.txt
+++ b/src/BenchmarkDotNet/Templates/BenchmarkProgram.txt
@@ -11,7 +11,7 @@ namespace BenchmarkDotNet.Autogenerated
public class UniqueProgramName // we need different name than typical "Program" to avoid problems with referencing "Program" types from benchmarked code, #691
{
$ExtraAttribute$
- public static System.Int32 Main(System.String[] args)
+ public static global::System.Int32 Main(global::System.String[] args)
{
// this method MUST NOT have any dependencies to BenchmarkDotNet and any other external dlls! (CoreRT is exception from this rule)
// otherwise if LINQPad's shadow copy is enabled, we will not register for AssemblyLoading event
@@ -22,17 +22,17 @@ namespace BenchmarkDotNet.Autogenerated
return AfterAssemblyLoadingAttached(args);
}
- private static System.Int32 AfterAssemblyLoadingAttached(System.String[] args)
+ private static global::System.Int32 AfterAssemblyLoadingAttached(global::System.String[] args)
{
- BenchmarkDotNet.Engines.IHost host; // this variable name is used by CodeGenerator.GetCoreRtSwitch, do NOT change it
- if (BenchmarkDotNet.Engines.AnonymousPipesHost.TryGetFileHandles(args, out System.String writeHandle, out System.String readHandle))
- host = new BenchmarkDotNet.Engines.AnonymousPipesHost(writeHandle, readHandle);
+ global::BenchmarkDotNet.Engines.IHost host; // this variable name is used by CodeGenerator.GetCoreRtSwitch, do NOT change it
+ if (global::BenchmarkDotNet.Engines.AnonymousPipesHost.TryGetFileHandles(args, out global::System.String writeHandle, out global::System.String readHandle))
+ host = new global::BenchmarkDotNet.Engines.AnonymousPipesHost(writeHandle, readHandle);
else
- host = new BenchmarkDotNet.Engines.NoAcknowledgementConsoleHost();
+ host = new global::BenchmarkDotNet.Engines.NoAcknowledgementConsoleHost();
// the first thing to do is to let diagnosers hook in before anything happens
// so all jit-related diagnosers can catch first jit compilation!
- BenchmarkDotNet.Engines.HostExtensions.BeforeAnythingElse(host);
+ global::BenchmarkDotNet.Engines.HostExtensions.BeforeAnythingElse(host);
try
{
@@ -41,10 +41,10 @@ namespace BenchmarkDotNet.Autogenerated
// we have some jitting diagnosers and we want them to catch all the informations!!
// this variable name is used by CodeGenerator.GetCoreRtSwitch, do NOT change it
- System.String benchmarkName = System.Linq.Enumerable.FirstOrDefault(System.Linq.Enumerable.Skip(System.Linq.Enumerable.SkipWhile(args, arg => arg != "--benchmarkName"), 1)) ?? "not provided";
- BenchmarkDotNet.Diagnosers.RunMode diagnoserRunMode = (BenchmarkDotNet.Diagnosers.RunMode) System.Int32.Parse(System.Linq.Enumerable.FirstOrDefault(System.Linq.Enumerable.Skip(System.Linq.Enumerable.SkipWhile(args, arg => arg != "--diagnoserRunMode"), 1)) ?? "0");
- System.Int32 id = args.Length > 0
- ? System.Int32.Parse(args[args.Length - 1]) // this variable name is used by CodeGenerator.GetCoreRtSwitch, do NOT change it
+ global::System.String benchmarkName = global::System.Linq.Enumerable.FirstOrDefault(global::System.Linq.Enumerable.Skip(global::System.Linq.Enumerable.SkipWhile(args, arg => arg != "--benchmarkName"), 1)) ?? "not provided";
+ global::BenchmarkDotNet.Diagnosers.RunMode diagnoserRunMode = (global::BenchmarkDotNet.Diagnosers.RunMode) global::System.Int32.Parse(global::System.Linq.Enumerable.FirstOrDefault(global::System.Linq.Enumerable.Skip(global::System.Linq.Enumerable.SkipWhile(args, arg => arg != "--diagnoserRunMode"), 1)) ?? "0");
+ global::System.Int32 id = args.Length > 0
+ ? global::System.Int32.Parse(args[args.Length - 1]) // this variable name is used by CodeGenerator.GetCoreRtSwitch, do NOT change it
: 0; // used when re-using generated exe without BDN (typically to repro a bug)
if (args.Length == 0)
@@ -54,12 +54,12 @@ namespace BenchmarkDotNet.Autogenerated
#if NATIVEAOT
$NativeAotSwitch$
#else
- System.Type type = typeof(BenchmarkDotNet.Autogenerated.UniqueProgramName).Assembly.GetType($"BenchmarkDotNet.Autogenerated.Runnable_{id}");
- type.GetMethod("Run", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static).Invoke(null, new System.Object[] { host, benchmarkName, diagnoserRunMode });
+ global::System.Type type = typeof(global::BenchmarkDotNet.Autogenerated.UniqueProgramName).Assembly.GetType($"BenchmarkDotNet.Autogenerated.Runnable_{id}");
+ type.GetMethod("Run", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Static).Invoke(null, new global::System.Object[] { host, benchmarkName, diagnoserRunMode });
#endif
return 0;
}
- catch (System.Exception oom) when (oom is System.OutOfMemoryException || oom is System.Reflection.TargetInvocationException reflection && reflection.InnerException is System.OutOfMemoryException)
+ catch (global::System.Exception oom) when (oom is global::System.OutOfMemoryException || oom is global::System.Reflection.TargetInvocationException reflection && reflection.InnerException is global::System.OutOfMemoryException)
{
host.WriteLine();
host.WriteLine("OutOfMemoryException!");
@@ -71,7 +71,7 @@ namespace BenchmarkDotNet.Autogenerated
return -1;
}
- catch(System.Exception ex)
+ catch(global::System.Exception ex)
{
host.WriteLine();
host.WriteLine(ex.ToString());
@@ -79,7 +79,7 @@ namespace BenchmarkDotNet.Autogenerated
}
finally
{
- BenchmarkDotNet.Engines.HostExtensions.AfterAll(host);
+ global::BenchmarkDotNet.Engines.HostExtensions.AfterAll(host);
host.Dispose();
}
@@ -87,34 +87,34 @@ namespace BenchmarkDotNet.Autogenerated
}
#if NETFRAMEWORK
- internal class DirtyAssemblyResolveHelper : System.IDisposable
+ internal class DirtyAssemblyResolveHelper : global::System.IDisposable
{
- internal DirtyAssemblyResolveHelper() => System.AppDomain.CurrentDomain.AssemblyResolve += HelpTheFrameworkToResolveTheAssembly;
+ internal DirtyAssemblyResolveHelper() => global::System.AppDomain.CurrentDomain.AssemblyResolve += HelpTheFrameworkToResolveTheAssembly;
- public void Dispose() => System.AppDomain.CurrentDomain.AssemblyResolve -= HelpTheFrameworkToResolveTheAssembly;
+ public void Dispose() => global::System.AppDomain.CurrentDomain.AssemblyResolve -= HelpTheFrameworkToResolveTheAssembly;
///
/// according to https://msdn.microsoft.com/en-us/library/ff527268(v=vs.110).aspx
/// "the handler is invoked whenever the runtime fails to bind to an assembly by name."
///
/// not null when we find it manually, null when can't help
- private System.Reflection.Assembly HelpTheFrameworkToResolveTheAssembly(System.Object sender, System.ResolveEventArgs args)
+ private global::System.Reflection.Assembly HelpTheFrameworkToResolveTheAssembly(global::System.Object sender, global::System.ResolveEventArgs args)
{
#if SHADOWCOPY // used for LINQPad
- const System.String shadowCopyFolderPath = @"$ShadowCopyFolderPath$";
+ const global::System.String shadowCopyFolderPath = @"$ShadowCopyFolderPath$";
- System.String guessedPath = System.IO.Path.Combine(shadowCopyFolderPath, $"{new System.Reflection.AssemblyName(args.Name).Name}.dll");
+ global::System.String guessedPath = global::System.IO.Path.Combine(shadowCopyFolderPath, $"{new global::System.Reflection.AssemblyName(args.Name).Name}.dll");
- return System.IO.File.Exists(guessedPath) ? System.Reflection.Assembly.LoadFrom(guessedPath) : null;
+ return global::System.IO.File.Exists(guessedPath) ? global::System.Reflection.Assembly.LoadFrom(guessedPath) : null;
#else
- System.Reflection.AssemblyName fullName = new System.Reflection.AssemblyName(args.Name);
- System.String simpleName = fullName.Name;
+ global::System.Reflection.AssemblyName fullName = new global::System.Reflection.AssemblyName(args.Name);
+ global::System.String simpleName = fullName.Name;
- System.String guessedPath = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, $"{simpleName}.dll");
+ global::System.String guessedPath = global::System.IO.Path.Combine(global::System.AppDomain.CurrentDomain.BaseDirectory, $"{simpleName}.dll");
- if (!System.IO.File.Exists(guessedPath))
+ if (!global::System.IO.File.Exists(guessedPath))
{
- System.Console.WriteLine($"// Wrong assembly binding redirects for {args.Name}.");
+ global::System.Console.WriteLine($"// Wrong assembly binding redirects for {args.Name}.");
return null; // we can't help, and we also don't call Assembly.Load which if fails comes back here, creates endless loop and causes StackOverflow
}
@@ -122,9 +122,9 @@ namespace BenchmarkDotNet.Autogenerated
// so we just load it and ignore the version mismatch
// we warn the user about that, in case some Super User want to be aware of that
- System.Console.WriteLine($"// Wrong assembly binding redirects for {simpleName}, loading it from disk anyway.");
+ global::System.Console.WriteLine($"// Wrong assembly binding redirects for {simpleName}, loading it from disk anyway.");
- return System.Reflection.Assembly.LoadFrom(guessedPath);
+ return global::System.Reflection.Assembly.LoadFrom(guessedPath);
#endif // SHADOWCOPY
}
}
diff --git a/src/BenchmarkDotNet/Templates/BenchmarkType.txt b/src/BenchmarkDotNet/Templates/BenchmarkType.txt
index 3b059fd5e5..7d9c629d8d 100644
--- a/src/BenchmarkDotNet/Templates/BenchmarkType.txt
+++ b/src/BenchmarkDotNet/Templates/BenchmarkType.txt
@@ -1,42 +1,42 @@
// the type name must be in sync with WindowsDisassembler.BuildArguments
- public unsafe class Runnable_$ID$ : global::$WorkloadTypeName$
+ public unsafe class Runnable_$ID$ : $WorkloadTypeName$
{
- public static void Run(BenchmarkDotNet.Engines.IHost host, System.String benchmarkName, BenchmarkDotNet.Diagnosers.RunMode diagnoserRunMode)
+ public static void Run(global::BenchmarkDotNet.Engines.IHost host, global::System.String benchmarkName, global::BenchmarkDotNet.Diagnosers.RunMode diagnoserRunMode)
{
- BenchmarkDotNet.Autogenerated.Runnable_$ID$ instance = new BenchmarkDotNet.Autogenerated.Runnable_$ID$ { $ParamsInitializer$ }; // do NOT change name "instance" (used in SmartParamameter)
+ global::BenchmarkDotNet.Autogenerated.Runnable_$ID$ instance = new global::BenchmarkDotNet.Autogenerated.Runnable_$ID$ { $ParamsInitializer$ }; // do NOT change name "instance" (used in SmartParamameter)
$ParamsContent$
host.WriteLine();
- foreach (System.String infoLine in BenchmarkDotNet.Environments.BenchmarkEnvironmentInfo.GetCurrent().ToFormattedString())
+ foreach (global::System.String infoLine in global::BenchmarkDotNet.Environments.BenchmarkEnvironmentInfo.GetCurrent().ToFormattedString())
{
host.WriteLine($"// {infoLine}");
}
- BenchmarkDotNet.Jobs.Job job = new BenchmarkDotNet.Jobs.Job(); // use full name to avoid naming conflicts, #778
+ global::BenchmarkDotNet.Jobs.Job job = new global::BenchmarkDotNet.Jobs.Job(); // use full name to avoid naming conflicts, #778
$JobSetDefinition$;
job.Freeze();
host.WriteLine($"// Job: {job.DisplayInfo}");
host.WriteLine();
- System.Collections.Generic.IEnumerable errors = BenchmarkDotNet.Environments.BenchmarkEnvironmentInfo.Validate(job);
- if (BenchmarkDotNet.Validators.ValidationErrorReporter.ReportIfAny(errors, host))
+ global::System.Collections.Generic.IEnumerable errors = global::BenchmarkDotNet.Environments.BenchmarkEnvironmentInfo.Validate(job);
+ if (global::BenchmarkDotNet.Validators.ValidationErrorReporter.ReportIfAny(errors, host))
return;
- BenchmarkDotNet.Diagnosers.CompositeInProcessDiagnoserHandler compositeInProcessDiagnoserHandler = new BenchmarkDotNet.Diagnosers.CompositeInProcessDiagnoserHandler(
- new BenchmarkDotNet.Diagnosers.InProcessDiagnoserRouter[] {
+ global::BenchmarkDotNet.Diagnosers.CompositeInProcessDiagnoserHandler compositeInProcessDiagnoserHandler = new global::BenchmarkDotNet.Diagnosers.CompositeInProcessDiagnoserHandler(
+ new global::BenchmarkDotNet.Diagnosers.InProcessDiagnoserRouter[] {
$InProcessDiagnoserRouters$
},
host,
diagnoserRunMode,
- new BenchmarkDotNet.Diagnosers.InProcessDiagnoserActionArgs(instance)
+ new global::BenchmarkDotNet.Diagnosers.InProcessDiagnoserActionArgs(instance)
);
- if (diagnoserRunMode == BenchmarkDotNet.Diagnosers.RunMode.SeparateLogic)
+ if (diagnoserRunMode == global::BenchmarkDotNet.Diagnosers.RunMode.SeparateLogic)
{
- compositeInProcessDiagnoserHandler.Handle(BenchmarkDotNet.Engines.BenchmarkSignal.SeparateLogic);
+ compositeInProcessDiagnoserHandler.Handle(global::BenchmarkDotNet.Engines.BenchmarkSignal.SeparateLogic);
return;
}
- compositeInProcessDiagnoserHandler.Handle(BenchmarkDotNet.Engines.BenchmarkSignal.BeforeEngine);
+ compositeInProcessDiagnoserHandler.Handle(global::BenchmarkDotNet.Engines.BenchmarkSignal.BeforeEngine);
- BenchmarkDotNet.Engines.EngineParameters engineParameters = new BenchmarkDotNet.Engines.EngineParameters()
+ global::BenchmarkDotNet.Engines.EngineParameters engineParameters = new global::BenchmarkDotNet.Engines.EngineParameters()
{
Host = host,
WorkloadActionUnroll = instance.WorkloadActionUnroll,
@@ -54,15 +54,15 @@
InProcessDiagnoserHandler = compositeInProcessDiagnoserHandler
};
- using (BenchmarkDotNet.Engines.IEngine engine = new $EngineFactoryType$().CreateReadyToRun(engineParameters))
+ using (global::BenchmarkDotNet.Engines.IEngine engine = new $EngineFactoryType$().CreateReadyToRun(engineParameters))
{
- BenchmarkDotNet.Engines.RunResults results = engine.Run();
+ global::BenchmarkDotNet.Engines.RunResults results = engine.Run();
host.ReportResults(results); // printing costs memory, do this after runs
instance.__TrickTheJIT__(); // compile the method for disassembler, but without actual run of the benchmark ;)
}
- compositeInProcessDiagnoserHandler.Handle(BenchmarkDotNet.Engines.BenchmarkSignal.AfterEngine);
+ compositeInProcessDiagnoserHandler.Handle(global::BenchmarkDotNet.Engines.BenchmarkSignal.AfterEngine);
}
public delegate $OverheadMethodReturnTypeName$ OverheadDelegate($ArgumentsDefinition$);
@@ -71,30 +71,30 @@
public Runnable_$ID$()
{
- globalSetupAction = $GlobalSetupMethodName$;
- globalCleanupAction = $GlobalCleanupMethodName$;
- iterationSetupAction = $IterationSetupMethodName$;
- iterationCleanupAction = $IterationCleanupMethodName$;
- overheadDelegate = __Overhead;
- workloadDelegate = $WorkloadMethodDelegate$;
+ this.globalSetupAction = $GlobalSetupMethodName$;
+ this.globalCleanupAction = $GlobalCleanupMethodName$;
+ this.iterationSetupAction = $IterationSetupMethodName$;
+ this.iterationCleanupAction = $IterationCleanupMethodName$;
+ this.overheadDelegate = this.__Overhead;
+ this.workloadDelegate = $WorkloadMethodDelegate$;
$InitializeArgumentFields$
}
- private System.Action globalSetupAction;
- private System.Action globalCleanupAction;
- private System.Action iterationSetupAction;
- private System.Action iterationCleanupAction;
- private BenchmarkDotNet.Autogenerated.Runnable_$ID$.OverheadDelegate overheadDelegate;
- private BenchmarkDotNet.Autogenerated.Runnable_$ID$.WorkloadDelegate workloadDelegate;
+ private global::System.Action globalSetupAction;
+ private global::System.Action globalCleanupAction;
+ private global::System.Action iterationSetupAction;
+ private global::System.Action iterationCleanupAction;
+ private global::BenchmarkDotNet.Autogenerated.Runnable_$ID$.OverheadDelegate overheadDelegate;
+ private global::BenchmarkDotNet.Autogenerated.Runnable_$ID$.WorkloadDelegate workloadDelegate;
$DeclareArgumentFields$
// this method is used only for the disassembly diagnoser purposes
// the goal is to get this and the benchmarked method jitted, but without executing the benchmarked method itself
- public System.Int32 NotEleven;
- [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoOptimization | System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
+ public global::System.Int32 NotEleven;
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.NoOptimization | global::System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public void __TrickTheJIT__()
{
- NotEleven = new System.Random(123).Next(0, 10);
+ this.NotEleven = new global::System.Random(123).Next(0, 10);
$DisassemblerEntryMethodName$();
}
@@ -105,52 +105,52 @@
#if RETURNS_CONSUMABLE_$ID$
- private BenchmarkDotNet.Engines.Consumer consumer = new BenchmarkDotNet.Engines.Consumer();
+ private global::BenchmarkDotNet.Engines.Consumer consumer = new global::BenchmarkDotNet.Engines.Consumer();
- [System.Runtime.CompilerServices.MethodImpl(BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
- private void OverheadActionUnroll(System.Int64 invokeCount)
+ [global::System.Runtime.CompilerServices.MethodImpl(global::BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
+ private void OverheadActionUnroll(global::System.Int64 invokeCount)
{
$LoadArguments$
- for (System.Int64 i = 0; i < invokeCount; i++)
+ for (global::System.Int64 i = 0; i < invokeCount; i++)
{
- consumer.Consume(overheadDelegate($PassArguments$));@Unroll@
+ this.consumer.Consume(this.overheadDelegate($PassArguments$));@Unroll@
}
}
- [System.Runtime.CompilerServices.MethodImpl(BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
- private void OverheadActionNoUnroll(System.Int64 invokeCount)
+ [global::System.Runtime.CompilerServices.MethodImpl(global::BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
+ private void OverheadActionNoUnroll(global::System.Int64 invokeCount)
{
$LoadArguments$
- for (System.Int64 i = 0; i < invokeCount; i++)
+ for (global::System.Int64 i = 0; i < invokeCount; i++)
{
- consumer.Consume(overheadDelegate($PassArguments$));
+ this.consumer.Consume(this.overheadDelegate($PassArguments$));
}
}
- [System.Runtime.CompilerServices.MethodImpl(BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
- private void WorkloadActionUnroll(System.Int64 invokeCount)
+ [global::System.Runtime.CompilerServices.MethodImpl(global::BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
+ private void WorkloadActionUnroll(global::System.Int64 invokeCount)
{
$LoadArguments$
- for (System.Int64 i = 0; i < invokeCount; i++)
+ for (global::System.Int64 i = 0; i < invokeCount; i++)
{
- consumer.Consume(workloadDelegate($PassArguments$)$ConsumeField$);@Unroll@
+ this.consumer.Consume(this.workloadDelegate($PassArguments$)$ConsumeField$);@Unroll@
}
}
- [System.Runtime.CompilerServices.MethodImpl(BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
- private void WorkloadActionNoUnroll(System.Int64 invokeCount)
+ [global::System.Runtime.CompilerServices.MethodImpl(global::BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
+ private void WorkloadActionNoUnroll(global::System.Int64 invokeCount)
{
$LoadArguments$
- for (System.Int64 i = 0; i < invokeCount; i++)
+ for (global::System.Int64 i = 0; i < invokeCount; i++)
{
- consumer.Consume(workloadDelegate($PassArguments$)$ConsumeField$);
+ this.consumer.Consume(this.workloadDelegate($PassArguments$)$ConsumeField$);
}
}
- [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoOptimization | System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.NoOptimization | global::System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public $WorkloadMethodReturnType$ $DisassemblerEntryMethodName$()
{
- if (NotEleven == 11)
+ if (this.NotEleven == 11)
{
$LoadArguments$
return $WorkloadMethodCall$;
@@ -161,63 +161,63 @@
#elif RETURNS_NON_CONSUMABLE_STRUCT_$ID$
- [System.Runtime.CompilerServices.MethodImpl(BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
- private void OverheadActionUnroll(System.Int64 invokeCount)
+ [global::System.Runtime.CompilerServices.MethodImpl(global::BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
+ private void OverheadActionUnroll(global::System.Int64 invokeCount)
{
$LoadArguments$
$OverheadMethodReturnTypeName$ result = default($OverheadMethodReturnTypeName$);
- for (System.Int64 i = 0; i < invokeCount; i++)
+ for (global::System.Int64 i = 0; i < invokeCount; i++)
{
- result = overheadDelegate($PassArguments$);@Unroll@
+ result = this.overheadDelegate($PassArguments$);@Unroll@
}
- BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxing(result);
+ global::BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxing(result);
}
- [System.Runtime.CompilerServices.MethodImpl(BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
- private void OverheadActionNoUnroll(System.Int64 invokeCount)
+ [global::System.Runtime.CompilerServices.MethodImpl(global::BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
+ private void OverheadActionNoUnroll(global::System.Int64 invokeCount)
{
$LoadArguments$
$OverheadMethodReturnTypeName$ result = default($OverheadMethodReturnTypeName$);
- for (System.Int64 i = 0; i < invokeCount; i++)
+ for (global::System.Int64 i = 0; i < invokeCount; i++)
{
- result = overheadDelegate($PassArguments$);
+ result = this.overheadDelegate($PassArguments$);
}
- BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxing(result);
+ global::BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxing(result);
}
- [System.Runtime.CompilerServices.MethodImpl(BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
- private void WorkloadActionUnroll(System.Int64 invokeCount)
+ [global::System.Runtime.CompilerServices.MethodImpl(global::BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
+ private void WorkloadActionUnroll(global::System.Int64 invokeCount)
{
$LoadArguments$
$WorkloadMethodReturnType$ result = default($WorkloadMethodReturnType$);
- for (System.Int64 i = 0; i < invokeCount; i++)
+ for (global::System.Int64 i = 0; i < invokeCount; i++)
{
- result = workloadDelegate($PassArguments$);@Unroll@
+ result = this.workloadDelegate($PassArguments$);@Unroll@
}
- NonGenericKeepAliveWithoutBoxing(result);
+ this.NonGenericKeepAliveWithoutBoxing(result);
}
- [System.Runtime.CompilerServices.MethodImpl(BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
- private void WorkloadActionNoUnroll(System.Int64 invokeCount)
+ [global::System.Runtime.CompilerServices.MethodImpl(global::BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
+ private void WorkloadActionNoUnroll(global::System.Int64 invokeCount)
{
$LoadArguments$
$WorkloadMethodReturnType$ result = default($WorkloadMethodReturnType$);
- for (System.Int64 i = 0; i < invokeCount; i++)
+ for (global::System.Int64 i = 0; i < invokeCount; i++)
{
- result = workloadDelegate($PassArguments$);
+ result = this.workloadDelegate($PassArguments$);
}
- NonGenericKeepAliveWithoutBoxing(result);
+ this.NonGenericKeepAliveWithoutBoxing(result);
}
// we must not simply use DeadCodeEliminationHelper.KeepAliveWithoutBoxing because it's generic method
// and stack-only types like Span can not be generic type arguments http://adamsitnik.com/Span/#span-must-not-be-a-generic-type-argument
- [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private void NonGenericKeepAliveWithoutBoxing($WorkloadMethodReturnType$ _) { }
- [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoOptimization | System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.NoOptimization | global::System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public $WorkloadMethodReturnType$ $DisassemblerEntryMethodName$()
{
- if (NotEleven == 11)
+ if (this.NotEleven == 11)
{
$LoadArguments$
return $WorkloadMethodCall$;
@@ -228,176 +228,176 @@
#elif RETURNS_BYREF_$ID$
- [System.Runtime.CompilerServices.MethodImpl(BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
- private void OverheadActionUnroll(System.Int64 invokeCount)
+ [global::System.Runtime.CompilerServices.MethodImpl(global::BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
+ private void OverheadActionUnroll(global::System.Int64 invokeCount)
{
$LoadArguments$
$OverheadMethodReturnTypeName$ value = default($OverheadMethodReturnTypeName$);
- for (System.Int64 i = 0; i < invokeCount; i++)
+ for (global::System.Int64 i = 0; i < invokeCount; i++)
{
- value = overheadDelegate($PassArguments$);@Unroll@
+ value = this.overheadDelegate($PassArguments$);@Unroll@
}
- BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxing(value);
+ global::BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxing(value);
}
- [System.Runtime.CompilerServices.MethodImpl(BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
- private void OverheadActionNoUnroll(System.Int64 invokeCount)
+ [global::System.Runtime.CompilerServices.MethodImpl(global::BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
+ private void OverheadActionNoUnroll(global::System.Int64 invokeCount)
{
$LoadArguments$
$OverheadMethodReturnTypeName$ value = default($OverheadMethodReturnTypeName$);
- for (System.Int64 i = 0; i < invokeCount; i++)
+ for (global::System.Int64 i = 0; i < invokeCount; i++)
{
- value = overheadDelegate($PassArguments$);
+ value = this.overheadDelegate($PassArguments$);
}
- BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxing(value);
+ global::BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxing(value);
}
private $WorkloadMethodReturnType$ workloadDefaultValueHolder = default($WorkloadMethodReturnType$);
- [System.Runtime.CompilerServices.MethodImpl(BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
- private void WorkloadActionUnroll(System.Int64 invokeCount)
+ [global::System.Runtime.CompilerServices.MethodImpl(global::BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
+ private void WorkloadActionUnroll(global::System.Int64 invokeCount)
{
$LoadArguments$
- ref $WorkloadMethodReturnType$ alias = ref workloadDefaultValueHolder;
- for (System.Int64 i = 0; i < invokeCount; i++)
+ ref $WorkloadMethodReturnType$ alias = ref this.workloadDefaultValueHolder;
+ for (global::System.Int64 i = 0; i < invokeCount; i++)
{
- alias = workloadDelegate($PassArguments$);@Unroll@
+ alias = this.workloadDelegate($PassArguments$);@Unroll@
}
- BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxing(ref alias);
+ global::BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxing(ref alias);
}
- [System.Runtime.CompilerServices.MethodImpl(BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
- private void WorkloadActionNoUnroll(System.Int64 invokeCount)
+ [global::System.Runtime.CompilerServices.MethodImpl(global::BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
+ private void WorkloadActionNoUnroll(global::System.Int64 invokeCount)
{
$LoadArguments$
- ref $WorkloadMethodReturnType$ alias = ref workloadDefaultValueHolder;
- for (System.Int64 i = 0; i < invokeCount; i++)
+ ref $WorkloadMethodReturnType$ alias = ref this.workloadDefaultValueHolder;
+ for (global::System.Int64 i = 0; i < invokeCount; i++)
{
- alias = workloadDelegate($PassArguments$);
+ alias = this.workloadDelegate($PassArguments$);
}
- BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxing(ref alias);
+ global::BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxing(ref alias);
}
- [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoOptimization | System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.NoOptimization | global::System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public ref $WorkloadMethodReturnType$ $DisassemblerEntryMethodName$()
{
- if (NotEleven == 11)
+ if (this.NotEleven == 11)
{
$LoadArguments$
return ref $WorkloadMethodCall$;
}
- return ref workloadDefaultValueHolder;
+ return ref this.workloadDefaultValueHolder;
}
#elif RETURNS_BYREF_READONLY_$ID$
- [System.Runtime.CompilerServices.MethodImpl(BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
- private void OverheadActionUnroll(System.Int64 invokeCount)
+ [global::System.Runtime.CompilerServices.MethodImpl(global::BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
+ private void OverheadActionUnroll(global::System.Int64 invokeCount)
{
$LoadArguments$
$OverheadMethodReturnTypeName$ value = default($OverheadMethodReturnTypeName$);
- for (System.Int64 i = 0; i < invokeCount; i++)
+ for (global::System.Int64 i = 0; i < invokeCount; i++)
{
- value = overheadDelegate($PassArguments$);@Unroll@
+ value = this.overheadDelegate($PassArguments$);@Unroll@
}
- BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxing(value);
+ global::BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxing(value);
}
- [System.Runtime.CompilerServices.MethodImpl(BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
- private void OverheadActionNoUnroll(System.Int64 invokeCount)
+ [global::System.Runtime.CompilerServices.MethodImpl(global::BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
+ private void OverheadActionNoUnroll(global::System.Int64 invokeCount)
{
$LoadArguments$
$OverheadMethodReturnTypeName$ value = default($OverheadMethodReturnTypeName$);
- for (System.Int64 i = 0; i < invokeCount; i++)
+ for (global::System.Int64 i = 0; i < invokeCount; i++)
{
- value = overheadDelegate($PassArguments$);
+ value = this.overheadDelegate($PassArguments$);
}
- BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxing(value);
+ global::BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxing(value);
}
private $WorkloadMethodReturnType$ workloadDefaultValueHolder = default($WorkloadMethodReturnType$);
- [System.Runtime.CompilerServices.MethodImpl(BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
- private void WorkloadActionUnroll(System.Int64 invokeCount)
+ [global::System.Runtime.CompilerServices.MethodImpl(global::BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
+ private void WorkloadActionUnroll(global::System.Int64 invokeCount)
{
$LoadArguments$
- ref $WorkloadMethodReturnType$ alias = ref workloadDefaultValueHolder;
- for (System.Int64 i = 0; i < invokeCount; i++)
+ ref $WorkloadMethodReturnType$ alias = ref this.workloadDefaultValueHolder;
+ for (global::System.Int64 i = 0; i < invokeCount; i++)
{
- alias = workloadDelegate($PassArguments$);@Unroll@
+ alias = this.workloadDelegate($PassArguments$);@Unroll@
}
- BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxingReadonly(alias);
+ global::BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxingReadonly(alias);
}
- [System.Runtime.CompilerServices.MethodImpl(BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
- private void WorkloadActionNoUnroll(System.Int64 invokeCount)
+ [global::System.Runtime.CompilerServices.MethodImpl(global::BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
+ private void WorkloadActionNoUnroll(global::System.Int64 invokeCount)
{
$LoadArguments$
- ref $WorkloadMethodReturnType$ alias = ref workloadDefaultValueHolder;
- for (System.Int64 i = 0; i < invokeCount; i++)
+ ref $WorkloadMethodReturnType$ alias = ref this.workloadDefaultValueHolder;
+ for (global::System.Int64 i = 0; i < invokeCount; i++)
{
- alias = workloadDelegate($PassArguments$);
+ alias = this.workloadDelegate($PassArguments$);
}
- BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxingReadonly(alias);
+ global::BenchmarkDotNet.Engines.DeadCodeEliminationHelper.KeepAliveWithoutBoxingReadonly(alias);
}
- [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoOptimization | System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.NoOptimization | global::System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public ref readonly $WorkloadMethodReturnType$ $DisassemblerEntryMethodName$()
{
- if (NotEleven == 11)
+ if (this.NotEleven == 11)
{
$LoadArguments$
return ref $WorkloadMethodCall$;
}
- return ref workloadDefaultValueHolder;
+ return ref this.workloadDefaultValueHolder;
}
#elif RETURNS_VOID_$ID$
- [System.Runtime.CompilerServices.MethodImpl(BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
- private void OverheadActionUnroll(System.Int64 invokeCount)
+ [global::System.Runtime.CompilerServices.MethodImpl(global::BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
+ private void OverheadActionUnroll(global::System.Int64 invokeCount)
{
$LoadArguments$
- for (System.Int64 i = 0; i < invokeCount; i++)
+ for (global::System.Int64 i = 0; i < invokeCount; i++)
{
- overheadDelegate($PassArguments$);@Unroll@
+ this.overheadDelegate($PassArguments$);@Unroll@
}
}
- [System.Runtime.CompilerServices.MethodImpl(BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
- private void OverheadActionNoUnroll(System.Int64 invokeCount)
+ [global::System.Runtime.CompilerServices.MethodImpl(global::BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
+ private void OverheadActionNoUnroll(global::System.Int64 invokeCount)
{
$LoadArguments$
- for (System.Int64 i = 0; i < invokeCount; i++)
+ for (global::System.Int64 i = 0; i < invokeCount; i++)
{
- overheadDelegate($PassArguments$);
+ this.overheadDelegate($PassArguments$);
}
}
- [System.Runtime.CompilerServices.MethodImpl(BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
- private void WorkloadActionUnroll(System.Int64 invokeCount)
+ [global::System.Runtime.CompilerServices.MethodImpl(global::BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
+ private void WorkloadActionUnroll(global::System.Int64 invokeCount)
{
$LoadArguments$
- for (System.Int64 i = 0; i < invokeCount; i++)
+ for (global::System.Int64 i = 0; i < invokeCount; i++)
{
- workloadDelegate($PassArguments$);@Unroll@
+ this.workloadDelegate($PassArguments$);@Unroll@
}
}
- [System.Runtime.CompilerServices.MethodImpl(BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
- private void WorkloadActionNoUnroll(System.Int64 invokeCount)
+ [global::System.Runtime.CompilerServices.MethodImpl(global::BenchmarkDotNet.Portability.CodeGenHelper.AggressiveOptimizationOption)]
+ private void WorkloadActionNoUnroll(global::System.Int64 invokeCount)
{
$LoadArguments$
- for (System.Int64 i = 0; i < invokeCount; i++)
+ for (global::System.Int64 i = 0; i < invokeCount; i++)
{
- workloadDelegate($PassArguments$);
+ this.workloadDelegate($PassArguments$);
}
}
- [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoOptimization | System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
+ [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.NoOptimization | global::System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public void $DisassemblerEntryMethodName$()
{
- if (NotEleven == 11)
+ if (this.NotEleven == 11)
{
$LoadArguments$
$WorkloadMethodCall$;
diff --git a/tests/BenchmarkDotNet.IntegrationTests/ConflictingNamesTests.cs b/tests/BenchmarkDotNet.IntegrationTests/ConflictingNamesTests.cs
new file mode 100644
index 0000000000..86a5ddbc7d
--- /dev/null
+++ b/tests/BenchmarkDotNet.IntegrationTests/ConflictingNamesTests.cs
@@ -0,0 +1,29 @@
+using BenchmarkDotNet.Attributes;
+using Xunit;
+using Xunit.Abstractions;
+
+namespace BenchmarkDotNet.IntegrationTests
+{
+ public class ConflictingNamesTests : BenchmarkTestExecutor
+ {
+ public ConflictingNamesTests(ITestOutputHelper output) : base(output) { }
+
+ [Fact]
+ public void BenchmarkMethodsCanUseTemplateNames() => CanExecute();
+
+ public class WithNamesUsedByTemplate
+ {
+ [Benchmark]
+ public void System()
+ {
+
+ }
+
+ [Benchmark]
+ public void BenchmarkDotNet()
+ {
+
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/BenchmarkDotNet.Tests/ReflectionTests.cs b/tests/BenchmarkDotNet.Tests/ReflectionTests.cs
index 0d1ea69673..d8e138cc24 100644
--- a/tests/BenchmarkDotNet.Tests/ReflectionTests.cs
+++ b/tests/BenchmarkDotNet.Tests/ReflectionTests.cs
@@ -14,18 +14,18 @@ public class ReflectionTests
[Fact]
public void GetCorrectCSharpTypeNameReturnsCSharpFriendlyTypeName()
{
- CheckCorrectTypeName("System.Int32", typeof(int));
- CheckCorrectTypeName("System.Int32[]", typeof(int[]));
- CheckCorrectTypeName("System.Int32[][]", typeof(int[][]));
- CheckCorrectTypeName("System.Int32[,]", typeof(int[,]));
- CheckCorrectTypeName("System.Tuple[]", typeof(Tuple[]));
- CheckCorrectTypeName("System.ValueTuple[]", typeof(ValueTuple[]));
+ CheckCorrectTypeName("global::System.Int32", typeof(int));
+ CheckCorrectTypeName("global::System.Int32[]", typeof(int[]));
+ CheckCorrectTypeName("global::System.Int32[][]", typeof(int[][]));
+ CheckCorrectTypeName("global::System.Int32[,]", typeof(int[,]));
+ CheckCorrectTypeName("global::System.Tuple[]", typeof(Tuple[]));
+ CheckCorrectTypeName("global::System.ValueTuple[]", typeof(ValueTuple[]));
CheckCorrectTypeName("void", typeof(void));
CheckCorrectTypeName("void*", typeof(void*));
- CheckCorrectTypeName("System.IEquatable", typeof(IEquatable<>));
- CheckCorrectTypeName("System.Type", typeof(Type));
+ CheckCorrectTypeName("global::System.IEquatable", typeof(IEquatable<>));
+ CheckCorrectTypeName("global::System.Type", typeof(Type));
// ReSharper disable once PossibleMistakenCallToGetType.2
- CheckCorrectTypeName("System.Reflection.TypeInfo", typeof(string).GetType()); // typeof(string).GetType() == System.RuntimeType which is not public
+ CheckCorrectTypeName("global::System.Reflection.TypeInfo", typeof(string).GetType()); // typeof(string).GetType() == System.RuntimeType which is not public
}
[Fact]
@@ -33,7 +33,7 @@ public void GetCorrectCSharpTypeNameSupportsGenericTypesPassedByReference()
{
var byRefGenericType = typeof(GenericByRef).GetMethod(nameof(GenericByRef.TheMethod)).GetParameters().Single().ParameterType;
- CheckCorrectTypeName("System.ValueTuple", byRefGenericType);
+ CheckCorrectTypeName("global::System.ValueTuple", byRefGenericType);
}
public class GenericByRef
@@ -44,32 +44,32 @@ public void TheMethod(ref (int, short) _) { }
[Fact]
public void GetCorrectCSharpTypeNameSupportsNestedTypes()
{
- CheckCorrectTypeName("BenchmarkDotNet.Tests.ReflectionTests.Nested", typeof(Nested));
+ CheckCorrectTypeName("global::BenchmarkDotNet.Tests.ReflectionTests.Nested", typeof(Nested));
- CheckCorrectTypeName("BenchmarkDotNet.Tests.ReflectionTests.NestedNonGeneric1.NestedNonGeneric2",
+ CheckCorrectTypeName("global::BenchmarkDotNet.Tests.ReflectionTests.NestedNonGeneric1.NestedNonGeneric2",
typeof(NestedNonGeneric1.NestedNonGeneric2));
- CheckCorrectTypeName("BenchmarkDotNet.Tests.ReflectionTests.NestedNonGeneric1.NestedGeneric2",
+ CheckCorrectTypeName("global::BenchmarkDotNet.Tests.ReflectionTests.NestedNonGeneric1.NestedGeneric2",
typeof(NestedNonGeneric1.NestedGeneric2));
- CheckCorrectTypeName("BenchmarkDotNet.Tests.ReflectionTests.NestedNonGeneric1.NestedGeneric2.NestedNonGeneric3",
+ CheckCorrectTypeName("global::BenchmarkDotNet.Tests.ReflectionTests.NestedNonGeneric1.NestedGeneric2.NestedNonGeneric3",
typeof(NestedNonGeneric1.NestedGeneric2.NestedNonGeneric3));
- CheckCorrectTypeName("BenchmarkDotNet.Tests.ReflectionTests.NestedGeneric1",
+ CheckCorrectTypeName("global::BenchmarkDotNet.Tests.ReflectionTests.NestedGeneric1",
typeof(NestedGeneric1));
- CheckCorrectTypeName("BenchmarkDotNet.Tests.ReflectionTests.NestedGeneric1.NonGeneric2",
+ CheckCorrectTypeName("global::BenchmarkDotNet.Tests.ReflectionTests.NestedGeneric1.NonGeneric2",
typeof(NestedGeneric1.NonGeneric2));
- CheckCorrectTypeName("BenchmarkDotNet.Tests.ReflectionTests.NestedGeneric1.NonGeneric2.Generic3",
+ CheckCorrectTypeName("global::BenchmarkDotNet.Tests.ReflectionTests.NestedGeneric1.NonGeneric2.Generic3",
typeof(NestedGeneric1.NonGeneric2.Generic3));
- CheckCorrectTypeName("BenchmarkDotNet.Tests.ReflectionTests.NestedGeneric1.NonGeneric2.Generic3.NonGeneric4",
+ CheckCorrectTypeName("global::BenchmarkDotNet.Tests.ReflectionTests.NestedGeneric1.NonGeneric2.Generic3.NonGeneric4",
typeof(NestedGeneric1.NonGeneric2.Generic3.NonGeneric4));
- CheckCorrectTypeName("BenchmarkDotNet.Tests.ReflectionTests.NestedGeneric1.NonGeneric2.Generic3.Generic4",
+ CheckCorrectTypeName("global::BenchmarkDotNet.Tests.ReflectionTests.NestedGeneric1.NonGeneric2.Generic3.Generic4",
typeof(NestedGeneric1.NonGeneric2.Generic3.Generic4));
- CheckCorrectTypeName("BenchmarkDotNet.Tests.ReflectionTests.NestedGeneric1",
+ CheckCorrectTypeName("global::BenchmarkDotNet.Tests.ReflectionTests.NestedGeneric1",
typeof(NestedGeneric1<,>));
- CheckCorrectTypeName("BenchmarkDotNet.Tests.ReflectionTests.NestedGeneric1.NonGeneric2.Generic3.NonGeneric4",
+ CheckCorrectTypeName("global::BenchmarkDotNet.Tests.ReflectionTests.NestedGeneric1.NonGeneric2.Generic3.NonGeneric4",
typeof(NestedGeneric1<,>.NonGeneric2.Generic3<,,>.NonGeneric4));
- CheckCorrectTypeName("BenchmarkDotNet.Tests.ReflectionTests.NestedGeneric1.NonGeneric2.Generic3.Generic4",
+ CheckCorrectTypeName("global::BenchmarkDotNet.Tests.ReflectionTests.NestedGeneric1.NonGeneric2.Generic3.Generic4",
typeof(NestedGeneric1<,>.NonGeneric2.Generic3<,,>.Generic4<,>));
}
@@ -78,7 +78,7 @@ public void GetCorrectCSharpTypeNameSupportsNestedTypesPassedByReference()
{
var byRefNestedType = typeof(Nested).GetMethod(nameof(Nested.TheMethod)).GetParameters().Single().ParameterType;
- CheckCorrectTypeName("BenchmarkDotNet.Tests.ReflectionTests.Nested", byRefNestedType);
+ CheckCorrectTypeName("global::BenchmarkDotNet.Tests.ReflectionTests.Nested", byRefNestedType);
}
public class Nested
diff --git a/tests/BenchmarkDotNet.Tests/SourceCodeHelperTests.cs b/tests/BenchmarkDotNet.Tests/SourceCodeHelperTests.cs
index 6e8e504a60..b8126cbef8 100644
--- a/tests/BenchmarkDotNet.Tests/SourceCodeHelperTests.cs
+++ b/tests/BenchmarkDotNet.Tests/SourceCodeHelperTests.cs
@@ -23,7 +23,7 @@ public class SourceCodeHelperTests
[InlineData('\\', "'\\\\'")]
[InlineData(0.123f, "0.123f")]
[InlineData(0.123d, "0.123d")]
- [InlineData(BindingFlags.Public, "(System.Reflection.BindingFlags)(16)")]
+ [InlineData(BindingFlags.Public, "(global::System.Reflection.BindingFlags)(16)")]
public void ToSourceCodeSimpleTest(object? original, string expected)
{
string actual = SourceCodeHelper.ToSourceCode(original);