SumHardwareCountersPerMethod(Di
foreach (var hardwareCounter in pmcStats.Counters)
{
// most probably asm.StartAddress would be enough, but I don't want to miss any edge case
- for (ulong instructionPointer = asm.InstructionPointer; instructionPointer < asm.InstructionPointer + (ulong)asm.InstructionLength; instructionPointer++)
+ for (ulong instructionPointer = asm.InstructionPointer; instructionPointer < asm.InstructionPointer + (ulong) asm.InstructionLength; instructionPointer++)
if (hardwareCounter.Value.PerInstructionPointer.TryGetValue(instructionPointer, out ulong value))
totalsPerCounter[hardwareCounter.Key] = totalsPerCounter[hardwareCounter.Key] + value;
}
@@ -214,7 +214,7 @@ private async ValueTask ExportAsync(
ulong forRange = instruction.SumPerCounter[hardwareCounter];
await writer.WriteAsync(forRange != 0
- ? $"| {(double)forRange / totalWithoutNoise:P} | "
+ ? $"{(double) forRange / totalWithoutNoise:P} | "
: "- | ", cancellationToken).ConfigureAwait(false);
}
@@ -237,7 +237,7 @@ await writer.WriteAsync(forRange != 0
ulong forMethod = method.SumPerCounter[hardwareCounter];
await writer.WriteAsync(forMethod != 0
- ? $"{(double)forMethod / totalWithoutNoise:P} | "
+ ? $"{(double) forMethod / totalWithoutNoise:P} | "
: "- | ", cancellationToken).ConfigureAwait(false);
}
await writer.WriteLineAsync(" | ", cancellationToken).ConfigureAwait(false);
diff --git a/src/BenchmarkDotNet/Exporters/RPlotExporter.cs b/src/BenchmarkDotNet/Exporters/RPlotExporter.cs
index c4765cf8db..dd9297dff3 100644
--- a/src/BenchmarkDotNet/Exporters/RPlotExporter.cs
+++ b/src/BenchmarkDotNet/Exporters/RPlotExporter.cs
@@ -78,7 +78,7 @@ public async ValueTask ExportAsync(Summary summary, ILogger logger, Cancellation
await streamWriter.WriteLineAsync(line, cancellationToken).ConfigureAwait(false);
}
- if (!process.WaitForExit(milliseconds: (int)ExecuteParameters.ProcessExitTimeout.TotalMilliseconds))
+ if (!process.WaitForExit(milliseconds: (int) ExecuteParameters.ProcessExitTimeout.TotalMilliseconds))
{
logger.WriteLineInfo("// The R script process did not quit on time, it's going to get force killed now.");
}
diff --git a/src/BenchmarkDotNet/Exporters/Xml/XmlSerializer.cs b/src/BenchmarkDotNet/Exporters/Xml/XmlSerializer.cs
index 430a90004e..1be2bbba95 100644
--- a/src/BenchmarkDotNet/Exporters/Xml/XmlSerializer.cs
+++ b/src/BenchmarkDotNet/Exporters/Xml/XmlSerializer.cs
@@ -102,7 +102,7 @@ private void WriteComplexProperty(object? source, PropertyInfo propertyInfo)
[SuppressMessage("ReSharper", "PossibleMultipleEnumeration")]
private void WriteCollectionProperty(object source, PropertyInfo property)
{
- var collection = (IEnumerable?)property.GetValue(source);
+ var collection = (IEnumerable?) property.GetValue(source);
if (collection == null || !IsCollectionWritable(collection))
return;
diff --git a/src/BenchmarkDotNet/Extensions/MathExtensions.cs b/src/BenchmarkDotNet/Extensions/MathExtensions.cs
index e7e1a34676..fcf54ca395 100644
--- a/src/BenchmarkDotNet/Extensions/MathExtensions.cs
+++ b/src/BenchmarkDotNet/Extensions/MathExtensions.cs
@@ -2,6 +2,6 @@ namespace BenchmarkDotNet.Extensions;
internal static class MathExtensions
{
- public static int RoundToInt(this double x) => (int)Math.Round(x);
- public static long RoundToLong(this double x) => (long)Math.Round(x);
+ public static int RoundToInt(this double x) => (int) Math.Round(x);
+ public static long RoundToLong(this double x) => (long) Math.Round(x);
}
diff --git a/src/BenchmarkDotNet/Extensions/MethodInfoExtensions.cs b/src/BenchmarkDotNet/Extensions/MethodInfoExtensions.cs
index 66b443089c..6064b521c7 100644
--- a/src/BenchmarkDotNet/Extensions/MethodInfoExtensions.cs
+++ b/src/BenchmarkDotNet/Extensions/MethodInfoExtensions.cs
@@ -11,13 +11,13 @@ internal static class MethodInfoExtensions
public static T CreateDelegate(this MethodInfo methodInfo)
where T : Delegate
{
- return (T)methodInfo.CreateDelegate(typeof(T));
+ return (T) methodInfo.CreateDelegate(typeof(T));
}
public static T CreateDelegate(this MethodInfo methodInfo, object? target)
where T : Delegate
{
- return (T)methodInfo.CreateDelegate(typeof(T), target);
+ return (T) methodInfo.CreateDelegate(typeof(T), target);
}
}
diff --git a/src/BenchmarkDotNet/Extensions/PathFeatures.cs b/src/BenchmarkDotNet/Extensions/PathFeatures.cs
index c084f6756b..38c09a456d 100644
--- a/src/BenchmarkDotNet/Extensions/PathFeatures.cs
+++ b/src/BenchmarkDotNet/Extensions/PathFeatures.cs
@@ -62,7 +62,7 @@ private static bool HasLegacyIoBehavior(string propertyName)
var p = t.GetProperty(propertyName, BindingFlags.Static | BindingFlags.Public);
// If the switch actually exists use it, otherwise we predate the switch and are effectively on
- return (bool)(p?.GetValue(null) ?? true);
+ return (bool) (p?.GetValue(null) ?? true);
}
private static bool RunningOnCoreLib
diff --git a/src/BenchmarkDotNet/Extensions/Polyfills/EnumExtensions.cs b/src/BenchmarkDotNet/Extensions/Polyfills/EnumExtensions.cs
index 14c25fd250..0188e5251a 100644
--- a/src/BenchmarkDotNet/Extensions/Polyfills/EnumExtensions.cs
+++ b/src/BenchmarkDotNet/Extensions/Polyfills/EnumExtensions.cs
@@ -17,7 +17,7 @@ public static TEnum[] GetValues()
public static TEnum Parse(string value)
where TEnum : struct, Enum
{
- return (TEnum)Enum.Parse(typeof(TEnum), value);
+ return (TEnum) Enum.Parse(typeof(TEnum), value);
}
public static string[] GetNames()
diff --git a/src/BenchmarkDotNet/Extensions/ProcessExtensions.cs b/src/BenchmarkDotNet/Extensions/ProcessExtensions.cs
index 0460afb936..13de386adb 100644
--- a/src/BenchmarkDotNet/Extensions/ProcessExtensions.cs
+++ b/src/BenchmarkDotNet/Extensions/ProcessExtensions.cs
@@ -42,7 +42,7 @@ internal static string ToPresentation(this IntPtr processorAffinity, int process
private static IntPtr FixAffinity(IntPtr processorAffinity)
{
// Max supported affinity without CPU groups is 64
- long cpuMask = Environment.ProcessorCount >= 64 ? unchecked((long)0xFFFF_FFFF_FFFF_FFFF) : (1L << Environment.ProcessorCount) - 1;
+ long cpuMask = Environment.ProcessorCount >= 64 ? unchecked((long) 0xFFFF_FFFF_FFFF_FFFF) : (1L << Environment.ProcessorCount) - 1;
return RuntimeInformation.Is64BitPlatform()
? new IntPtr(processorAffinity.ToInt64() & cpuMask)
@@ -84,7 +84,7 @@ public static bool TrySetAffinity(
catch (Exception ex)
{
logger.WriteLineError(
- $"// ! Failed to set up processor affinity 0x{(long)processorAffinity:X} for process {process}. Make sure you have the right permissions. Message: {ex.Message}");
+ $"// ! Failed to set up processor affinity 0x{(long) processorAffinity:X} for process {process}. Make sure you have the right permissions. Message: {ex.Message}");
}
return false;
@@ -214,7 +214,7 @@ private static (int exitCode, string output) RunProcessAndReadOutput(string file
{
process.Start();
processOutputReader.BeginRead();
- process.WaitForExit((int)timeout.TotalMilliseconds);
+ process.WaitForExit((int) timeout.TotalMilliseconds);
}
return (process.HasExited ? process.ExitCode : -1, processOutputReader.GetOutputText());
}
@@ -233,7 +233,7 @@ private static int RunProcessAndIgnoreOutput(string fileName, string arguments,
using (var process = Process.Start(startInfo)!)
{
- if (!process.WaitForExit((int)timeout.TotalMilliseconds))
+ if (!process.WaitForExit((int) timeout.TotalMilliseconds))
process.Kill();
return process.ExitCode;
diff --git a/src/BenchmarkDotNet/Extensions/ReflectionExtensions.cs b/src/BenchmarkDotNet/Extensions/ReflectionExtensions.cs
index 8fca6d5f2f..9371b675b5 100644
--- a/src/BenchmarkDotNet/Extensions/ReflectionExtensions.cs
+++ b/src/BenchmarkDotNet/Extensions/ReflectionExtensions.cs
@@ -499,7 +499,7 @@ internal static bool TryGetSourceElementType(this Type sourceReturnType, [NotNul
// different members of the same name. A generic method definition is passed over rather than matched, so a
// property of that name serves the name instead of an unusable method.
internal static MemberInfo? FindSourceMember(this Type sourceType, string sourceName)
- => (MemberInfo?)sourceType.GetAllMethods()
+ => (MemberInfo?) sourceType.GetAllMethods()
.FirstOrDefault(method => method.Name == sourceName && method.IsPublic
&& !method.IsGenericMethodDefinition
&& method.GetParameters().All(parameter => parameter.IsOptional))
@@ -571,7 +571,7 @@ PropertyInfo property when property.GetIndexParameters().Length == 0 => property
// The type a source member hands back, which is what the generated code infers the element type from.
internal static Type GetSourceReturnType(this MemberInfo source)
- => source is PropertyInfo property ? property.GetMethod!.ReturnType : ((MethodInfo)source).ReturnType;
+ => source is PropertyInfo property ? property.GetMethod!.ReturnType : ((MethodInfo) source).ReturnType;
internal static Attribute? GetAsyncMethodBuilderAttribute(this MemberInfo memberInfo)
// AsyncMethodBuilderAttribute can come from any assembly, so we need to use reflection by name instead of searching for the exact type.
diff --git a/src/BenchmarkDotNet/Extensions/StringAndTextExtensions.cs b/src/BenchmarkDotNet/Extensions/StringAndTextExtensions.cs
index bb564331c8..4bb1cf00a9 100644
--- a/src/BenchmarkDotNet/Extensions/StringAndTextExtensions.cs
+++ b/src/BenchmarkDotNet/Extensions/StringAndTextExtensions.cs
@@ -70,7 +70,7 @@ private static Dictionary BuildInvalidPathCharactersMappings()
return invalidFileNameChars.ToDictionary(
character => character.ToString(),
- character => $"char{(short)character}");
+ character => $"char{(short) character}");
}
///
diff --git a/src/BenchmarkDotNet/Helpers/DefaultCultureInfo.cs b/src/BenchmarkDotNet/Helpers/DefaultCultureInfo.cs
index 72b921a1d5..38eb0ac4cc 100644
--- a/src/BenchmarkDotNet/Helpers/DefaultCultureInfo.cs
+++ b/src/BenchmarkDotNet/Helpers/DefaultCultureInfo.cs
@@ -8,7 +8,7 @@ internal static class DefaultCultureInfo
static DefaultCultureInfo()
{
- Instance = (CultureInfo)CultureInfo.InvariantCulture.Clone();
+ Instance = (CultureInfo) CultureInfo.InvariantCulture.Clone();
Instance.NumberFormat.NumberDecimalSeparator = ".";
}
}
diff --git a/src/BenchmarkDotNet/Helpers/DynamicAwaitHelper.cs b/src/BenchmarkDotNet/Helpers/DynamicAwaitHelper.cs
index bc5f588583..b1a517a159 100644
--- a/src/BenchmarkDotNet/Helpers/DynamicAwaitHelper.cs
+++ b/src/BenchmarkDotNet/Helpers/DynamicAwaitHelper.cs
@@ -17,7 +17,7 @@ internal static class DynamicAwaitHelper
// Sources are always read through IAsyncEnumerable, pattern-based await foreach types are not supported.
// A reference-type element needs no reflection at all: IAsyncEnumerable is covariant.
=> !elementType.IsValueType
- ? (IAsyncEnumerable