Scope functions Map, Apply, ApplyForEach and ApplyForEachEager. They apply passed functions to a given object and return that same object or it's equivalent (or function return for Map), allowing you to have seamless side-effects and manipulate objects in fluent invocation chains or object iniatlizers, i.e. GetConfig().Apply(changes).Build()
$ dotnet add package Object.Extensions.ScopeFunctionFunctions Apply, ApplyForEach and Map allow you to have side-effects or manipulate objects in fluent invocation chains or object initializers.
var permissionsMissingTestContext = new TestContext
{
Users = GetStandardUsers().ApplyForEach(x => x.Permissions = new Permission[0]),
SecurityPolicy = GetStandardSecurityPolicy().Apply(x => x.ShowWarningWhenPermissionsMissing = true),
AnonymousPageUrl = GetStandardConfig().Map(x => new Url(x.PermissionsMissingScreenUrl)),
Timeout = GetTestTimeout()?.Map(x => TimeSpan.FromSeconds(x)) ?? TimeSpan.FromSeconds(30)
}