Table of Contents

Class BenchmarkWorkspaceOptionsExtensions

Namespace
Codebelt.Extensions.BenchmarkDotNet
Assembly
Codebelt.Extensions.BenchmarkDotNet.dll

Extension methods for the BenchmarkWorkspaceOptions class.

public static class BenchmarkWorkspaceOptionsExtensions
Inheritance
BenchmarkWorkspaceOptionsExtensions

Methods

ConfigureBenchmarkDotNet(BenchmarkWorkspaceOptions, Func<IConfig, IConfig>)

Configures the BenchmarkDotNet configuration for the specified options.

public static BenchmarkWorkspaceOptions ConfigureBenchmarkDotNet(this BenchmarkWorkspaceOptions options, Func<IConfig, IConfig> configure)

Parameters

options BenchmarkWorkspaceOptions

The BenchmarkWorkspaceOptions to extend.

configure Func<IConfig, IConfig>

The function delegate that configures the BenchmarkDotNet.Configs.IConfig.

Returns

BenchmarkWorkspaceOptions

The options instance for chaining.

Remarks

BenchmarkDotNet's configuration model is intentionally immutable-ish: methods such as AddJob, AddColumn, and AddDiagnoser do not mutate the incoming BenchmarkDotNet.Configs.IConfig instance. Instead, they produce and return a new configuration object. This behavior is powerful but can be unintuitive when used inside option delegates where callers naturally expect fluent configuration to modify the underlying options instance.

Without this helper, callers would need to explicitly reassign:

options.Configuration = options.Configuration.AddJob(job);

This extension method abstracts away that requirement by:

  • Forcing initialization of the default configuration if needed,
  • Passing the current configuration to the delegate for fluent BenchmarkDotNet operations,
  • Assigning the delegate’s returned configuration back to Configuration.

This preserves BenchmarkDotNet's design while providing an intuitive experience for users configuring BenchmarkWorkspaceOptions via delegates.

Exceptions

ArgumentNullException

options cannot be null -or- configure cannot be null.

InvalidOperationException

configure must not return null.

ArgumentNullException

options cannot be null -or- configure cannot be null.

InvalidOperationException

configure must not return null.