Compze.Underscore
0.6.0-beta
dotnet add package Compze.Underscore --version 0.6.0-beta
NuGet\Install-Package Compze.Underscore -Version 0.6.0-beta
<PackageReference Include="Compze.Underscore" Version="0.6.0-beta" />
<PackageVersion Include="Compze.Underscore" Version="0.6.0-beta" />
<PackageReference Include="Compze.Underscore" />
paket add Compze.Underscore --version 0.6.0-beta
#r "nuget: Compze.Underscore, 0.6.0-beta"
#:package Compze.Underscore@0.6.0-beta
#addin nuget:?package=Compze.Underscore&version=0.6.0-beta&prerelease
#tool nuget:?package=Compze.Underscore&version=0.6.0-beta&prerelease
Compze.Underscore
Code that reads the way you would describe the algorithm in words. Powered by the pipe forward operator and friends.
Sometimes very little goes a very long way. With just a handful of trivially simple extension methods we enable you to write code like this:
public OperationResult SomeBusinessMethod(Guid userId) =>
userId
._(LoadFromDatabase)
._tap(it => { /*log*/ })
._assert(MayExecuteThisOperation)
._(ActualOperationLogic)
._tap(it => { /*log*/ })
._assert(ResultIsWhatWeExpected);
._( The Pipe forward operator. Invokes the next step in a pipeline, passing the previous value as the it parameter.
var result = initialValue
._(it => Transform(it))
._(Validate)
._(Format);
.__( The then/discard operator. Ignores the previous value in the pipeline and starts over with a value or by invoking a Func or Action
string ValidatedName(string name) => Argument.Assert(!string.IsNullOrWhiteSpace(name))
.__(DoSomething(name));
IDisposable StartOperation(string name) => _logger.Log($"Starting {name}")
.__(() => new OperationScope(name));
Unit EnsureInitialized() => State.Assert(!_disposed).__(() =>
{
/*logic here */
});
._tap() — side effect, then continue
Executes a side effect on it without changing the pipeline value:
return userId
._tap(it => _logger.Log($"processing user {it}"))
._(DoSomething);
._mutate() — mutate and return
Declares that you're modifying it in-place and returning it for further chaining:
public static Command SetText(this Command @this, string text) => @this._mutate(it => it.CommandText = text);
What's with the naming?
These extensions apply to every type, so name collisions and polluting auto-complete lists are a very real concern. _camelCase provides:
- Near zero collision risk — no standard .NET method starts with
_. - Clear visuals — instantly recognizable as something other than regular methods.
- Great discoverability — type
._and all these extensions are right there grouped together.
_ "operators", vs words
._( and .__( should be thought of as operators: they glue expressions together, like ., (), or |> in other languages. Naming them with words (.Pipe(, .Then() makes the code stutter. Imagine if file.Open() had to be written as file.DOT.Invoke(Open) and you should see what we mean. You don't want words for . and (), nor do you want them for ._( or .__(:
// Compare:
return startValue.Pipe(DoSomething).Then(returnValue)
// And
return startValue._(DoSomething).__(returnValue)
Once you have internalized the meaning of ._( and .__( the readability of the two play in different leagues.
Related packages
| Package | Description |
|---|---|
| Compze.Unit | The Unit type — unifies Action and Func, enabling void methods to participate in pipelines |
| Compze.Contracts | Design-by-contract assertions, including the _assert() pipeline operator |
License
Apache-2.0
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Compze.Unit (>= 0.6.0-beta)
NuGet packages (20)
Showing the top 5 NuGet packages that depend on Compze.Underscore:
| Package | Downloads |
|---|---|
|
Compze.Threading
Pit of success threading primitives. Impossible to forget to lock. Automatically resolves and diagnoses deadlocks, including both the involved stack traces in the exception. |
|
|
Compze.DependencyInjection
Package Description |
|
|
Compze.Internals.Logging
Package Description |
|
|
Compze.Internals.SystemCE
For Compze internal use only. Do not take a direct dependency on this package. |
|
|
Compze.Tessaging
Messaging infrastructure for the Compze framework including command, query, and event handling. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.6.0-beta | 1,064 | 6/4/2026 |
| 0.5.0-beta | 96 | 3/4/2026 |