Skip to content

Latest commit

 

History

History
75 lines (50 loc) · 2.25 KB

README.md

File metadata and controls

75 lines (50 loc) · 2.25 KB

DestructureExtensions

Destructuring extension methods for awesome C#

Quickstart

In C# 7.0:

using DestructureExtensions;

/*...*/
var stringToSplit = "foo,bar,bam,baz";
var (first, _, third, rest) = stringToSplit.Split(',');

// first == "foo"
// third == "bam"
// rest == IEnumerable<string> containing "baz"

var one = Task.FromResult(1);
var two = Task.FromResult("foo");
var three = Task.FromResult(DateTimeOffset.Now);

var (first, second, third) = await (one, two, three).WhenAll();

var tasks = Enumerable.Range(1, 10).Select(Task.FromResult);
var results = await tasks.WhenAll();

var dictionary = new Dictionary<string, int>()
{
    { "one", 1 },
    { "two", 2 },
    { "three", 3 },
}
foreach (var (key, value) in dictionary)
{
    // ...
}

More examples in the unit tests.

Building

Travis NuGet

Ensure you have installed .NET Core

To build a local/development NuGet package, run the following:

dotnet restore
dotnet build
dotnet pack

This will produce bin/Debug/DestructureExtensions.0.0.0.nupkg.

Code of Conduct

We are committed to fostering an open and welcoming environment. Please read our code of conduct before participating in or contributing to this project.

Contributing

We welcome contributions and collaboration on this project. Please read our contributor's guide to understand how best to work with us.

License and Authors

Daniel James logo Daniel James

license GitHub contributors

This software is made available by Daniel James under the MIT license.