Git Product home page Git Product logo

dotstuff's Introduction

About

DotStuff is a source-only NuGet package that adds few helpful extensions for method chaining in C#.

Source-only here means that DotStuff adds a single, hidden C# file to your project. There is no extra DLL to ship. For libraries, there is no extra dependency that referencing projects see. This is ideal for a micro-package like DotStuff that consists of a single file. The file itself is written carefully to avoid conflicts with existing code.

Status

Build NuGet NuGet

  • Tested: 100% coverage by automated tests.

  • Documented: IntelliSense on everything. Examples below.

Installation

Install this NuGet Package in your project.

Usage

// Right assign
foo.AssignTo(out bar)       // => bar = foo;

// Right coalesce
foo.CoalesceTo(ref bar)     // => bar ??= foo;

// Tap
foo.Tap(action)             // { action(foo);       return foo; }
foo.Tap(x, action)          // { action(foo, x);    return foo; }
foo.Tap(x, y, action)       // { action(foo, x, y); return foo; }
// ... up to 3 extra arguments

// Apply
foo.Apply(function)         // => function(foo);
foo.Apply(x, function)      // => function(foo, x);
foo.Apply(x, y, function)   // => function(foo, x, y);
// ... up to 3 extra arguments

For Ruby developers, Tap and Apply are the C# equivalents of tap and then. AssignTo is similar to using Ruby's => pattern-matching operator for rightward assignment.

Options

DotStuff responds to the following preprocessor symbols.

  • DOTSTUFF_DISABLE

    Define this symbol to disable DotStuff completely.

  • DOTSTUFF_ENABLE_CODE_COVERAGE

    Define this symbol to include the DotStuff extension methods in code coverage. By default, the extension methods are excluded.

  • DOTSTUFF_HAS_CSHARP_8_OR_GREATER

    If this symbol is defined, DotStuff uses C# 8.0 features, such as the ??= operator required for CoalesceTo.

    This symbol is defined by default for target frameworks that use C# 8.0 or later by default: .NET 5.0, .NET Core 3.0, .NET Standard 2.1, and later.

    Define this symbol to use C# 8.0 features on older target frameworks. Make sure to configure the language version of the project to C# 8.0 or later.

  • DOTSTUFF_HAS_NULLABLE

    If this symbol is defined, DotStuff uses nullability attributes.

    This symbol is defined by default for target frameworks that provide these attributes: .NET 5.0, .NET Core 3.0, .NET Standard 2.1, and later.

    Define this symbol to use nullability attributes on older target frameworks. Some source of those attributes will be required. One easy option is to use Manuel Römer's Nullable package.

dotstuff's People

Contributors

sharpjs avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.