magic.node.extensions 17.1.7

dotnet add package magic.node.extensions --version 17.1.7
NuGet\Install-Package magic.node.extensions -Version 17.1.7
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="magic.node.extensions" Version="17.1.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add magic.node.extensions --version 17.1.7
#r "nuget: magic.node.extensions, 17.1.7"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install magic.node.extensions as a Cake Addin
#addin nuget:?package=magic.node.extensions&version=17.1.7

// Install magic.node.extensions as a Cake Tool
#tool nuget:?package=magic.node.extensions&version=17.1.7

magic.node - Nodes, the basic structure in Hyperlambda

magic.node is a simple name/value/children graph object, in addition to a "Hyperlambda" parser, allowing you to create a textual string representations of graph objects easily transformed to its relational graph object syntax and vice versa. This allows you to declaratively create "execution trees" using a format similar to YAML, for then to access each individual node, its value, name and children from your C#, CLR code, or Hyperlambda.

Hyperlambda is perfect for creating a highly humanly readable relational configuration format, or smaller DSL engines, especially when combined with magic.signals and magic.lambda. Below is a small example of Hyperlambda to give you an idea of how it looks like.


3 spaces (SP) opens up the children collection of a node, and allows you to create children associated with some other node. In the example above, the [child1] and the [child2] nodes, have [foo] as their parent. A colon : separates the name and the value of the node - The name is to the left of the colon, and the value to the right. You can optionally supply a type between a node's name and its value, which you can see above where we add the :int: parts between one of our [foo] nodes' name and value. If you don't explicitly declare a type string will be assumed.

Traversing Hyperlambda from C#

To traverse the nodes later in for instance C#, you could do something such as the following.

var root = var result = HyperlambdaParser.Parse(hyperlambda);

foreach (var idxChild in root.Children)
   var name = idxChild.Name;
   var value = idxChild.Value;
   /* ... etc ... */

Notice - When you parse Hyperlambda a "root node" is explicitly created wrapping all your nodes, and this is the node that's returned to you after parsing. All nodes you declare in your Hyperlambda will be returned to you as children of this root node.

Hyperlambda types

Although the node structure itself can hold any value type you need inside of its Value property, Hyperlambda only supports serialising the following types by default.

  • string = System.String
  • short = System.Int16
  • ushort = System.UInt16
  • int = System.Int32
  • uint = System.UInt32
  • long = System.Int64
  • ulong = System.UInt64
  • decimal = System.Decimal
  • double = System.Double
  • single = System.Float
  • float = System.Float - Alias for above
  • bool = System.Boolean
  • date = System.DateTime - Always interpreted and serialized as UTC time!
  • time = System.TimeSpan
  • guid = System.Guid
  • char = System.Char
  • byte = System.Byte
  • sbyte = System.SByte
  • x = magic.node.extensions.Expression
  • node = magic.node.Node

The type declaration should be declared in your Hyperlambda in between the name and its value, separated by colon (:). The default type if ommitted is string and strings do not need quotes or double quotes for this reason. An example of declaring a couple of types associated with a node's value can be found below.


Extending the Hyperlambda type system

The type system is extendible, and you can easily create support for serializing your own types, by using the Converter.AddConverter method, that can be found in the magic.node.extensions namespace. Below is an example of how to extend the typing system, to allow for serializing and de-serializing instances of a Foo class into Hyperlambda.

 * Class you want to serialize into Hyperlambda.
class Foo
    public int Value1 { get; set; }
    public decimal Value2 { get; set; }

 * Adding our converter functions, and associating them
 * with a type, and a Hyperlambda type name.
    (obj) => {
        var foo = obj as Foo;
        return ("foo", $"{foo.Value1}-{foo.Value2}");
    }, (obj) => {
        var str = (obj as string).Split('-');
        return new Foo
            Value1 = int.Parse(str[0]),
            Value2 = decimal.Parse(str[1]),

The above will allow you to serialize instances of Foo into your Hyperlambda, and de-serialize these instances once needed. An example of adding a Foo instance into your Hyperlambda can be found below.


Later you can retrieve your Foo instances in your slots, using something resembling the following, and all parsing and conversion will be automatically taken care of.

var foo = node.Get<Foo>();

String literals in Hyperlambda

Hyperlambda also support strings the same way C# supports strings, using any of the following string representations.

// Single quotes
.foo:'howdy world this is a string'

// Double quotes
.foo:"Howdy world, another string"

// Multiline strings
.foo:@"Notice how the new line doesn't end the string

Escape characters are supported for both single quote and double quote strings the same way they are supported in C#, allowing you to use e.g. \r\n etc.

Lambda expressions

Lambda expressions are kind of like XPath expressions, except they will references nodes in your Node graph object instead of XML nodes. Below is an example to give you an idea.

.foo:hello world

// After invocation of the above **[get-value]**, its value will be "hello world".

Most slots in Magic can accept expressions to reference nodes, values of nodes, and children of nodes somehow. This allows you to modify the lambda graph object, as it is currently being executed, and hence allows you to modify "anything" from "anywhere". This resembles XPath expressions from XML.

Iterators in lambda expressions

An expression is constructed from one or more "iterator". This makes an expression become "dynamically chained Linq statements", where each iterator reacts upon the results of its previous iterator. Each iterator takes as input an IEnumerable, and returns as its result another IEnumerable, where the content of the iterator somehow changes its given input, according to whatever the particular iterator's implementation does. This approach just so happens to be perfect for retrieving sub-sections of graph objects.

Each iterator ends with a "/" or a CR/LF sequence, and before its end, its value defines what it does. For instance the above iterator in the [get-value] invocation, starts out with a "@". This implies that the iterator will find the first node having a name of whatever follows its "@". For the above this implies looking for the first node who's name is ".foo". To see a slightly more advanced example, imagine the following.


It might help to transform the above expression into humanly readable language. Its English equivalent hence becomes as follows.

Find the node with the name of '.data', then retrieve its children, and filter away everything not having a name of 'item2'

Of course, the result of the above becomes "thomas".

Below is a list of all iterators that exists in magic. Substitute "xxx" with a string, "n" with a number, and "x" with an expression.

  • * Retrieves all children of its previous result
  • # Retrieves the value of its previous result as a node by reference
  • - Retrieves its previous result set's "younger sibling" (previous node)
  • + Retrieves its previous result set's "elder sibling" (next node)
  • . Retrieves its previous result set's parent node(s)
  • ^xxx Retrieves the first ancestor node with the specified "xxx" name. Similar to @ iterator but does not traverse siblings, only direct ancestors up in hierarchy
  • .. Retrieves the root node
  • ** Retrieves its previous result set's descendant, with a "breadth first" algorithm
  • -- Retrieves all ancestors and older siblings upwards in object
  • !xxx Traverses all descendants except those matching specified "xxx" name and returns
  • {x} Extrapolated expression that will be evaluated assuming it yields one result, replacing itself with the value of whatever node it points to
  • =xxx Retrieves the node with the "xxx" value, converting to string if necessary
  • [n,n] Retrieves a subset of its previous result set, implying "from, to" meaning [n1,n2>
  • @xxx Returns the first node "before" in its hierarchy that matches the given "xxx" in its name
  • n (any number) Returns the n'th child of its previous result set
  • [x|y] Pipe separated list of names returning all nodes having a name of either "x" or "y"

Notice, you can escape iterators by using backslash "\". This allows you to look for nodes who's names are for instance "3", without using the n'th child iterator, which would defeat the purpose. In addition, you can quote iterators by using double quotes ", to allow for having iterators with values that are normally not legal within an iterator, such as /, etc. If you quote an iterator you have to quote the entire expression. Below is an example of a slightly more advanced expression.

      :thomas was here

After evaluating the above Hyperlambda, the value of all nodes having "wo/rld" as their value inside of [.foo] will be updated to become "thomas was here". Obviously, the above expression is a ridiculous complex example, that you will probably never encounter in your own code. However, for reference purposes, let's break it down into its individual parts.

  1. Get parent node
  2. Get all children
  3. Filter away everything not having the name of the value of {@.dyn}, which resolves to the equivalent of :x:@.dyn, being an expression, who's result becomes ".foo".
  4. Get its children
  5. Find all nodes who's value is "wo/rld".

98% of your expressions will have 1-3 iterators, no complex escaping, and no parameters. And in fact, there are thousands of lines of Hyperlambda code in Magic's middleware, and 98% of these expressions are as simple as follows.


Which translates into the following English.

Give me the value of any [foo1] nodes, inside of the first [.arguments] node you can find upwards in the hierarchy.

Expressions can also be extrapolated, which allows you to parametrise your expressions, by nesting expressions, substituting parts of your expression dynamically as your code is executed. Imagine the following example.


The above expression will first evaluate the {@.arg1} parts, which results in "foo2", then evaluate the outer expression, which now will look like this*/foo2. You can also extrapolate expressions on values, such as illustrated below.


Extending lambda expressions/iterators

You can easily extend expressions in Magic, either with a "static" iterator, implying a direct match - Or with a dynamic parametrized iterator, allowing you to create iterators that requires "parameters". To extend the supported iterators, use any of the following two static methods.

  • Iterator.AddStaticIterator - Creates a "static" iterator, implying a direct match.
  • Iterator.AddDynamicIterator - Creates a "dynamic iterator create function".

Below is a C# example, that creates a dynamic iterator, that will only return nodes having a value, that once converted into a string, has exactly n characters, not less and not more.

Iterator.AddDynamicIterator('%', (iteratorValue) => {
    var no = int.Parse(iteratorValue.Substring(1));
    return (identity, input) => {
        return input.Where(x => x.Get<string>()?.Length == no);

var hl = @"foo
var lambda = HyperlambdaParser.Parse(hl);

var x = new Expression("../**/%3");
var result = x.Evaluate(lambda);

Notice how the iterator we created above, uses the %3 parts of the expression, to parametrize itself. If you exchange 3 with 5, it will only return [howdy1] and [howdy3] instead, since it will look for values with 5 characters instead. The Iterator class can be found in the magic.node.extensions namespace. You can use the above syntax to override the default implementation of iterators, although I wouldn't recommend it, since it would create confusion for others using your modified version.

Notice - To create an extension iterator is an exercise you will rarely if ever need to do, but is included here for reference purposes.

Parsing Hyperlambda from C#

Magic allows you to easily parse Hyperlambda from C# if you need it, which can be done as follows.

using magic.node.extensions.hyperlambda;

var hl = GetHyperlambdaAsString();
var lambda = HyperlambdaParser.Parse(hl);

The GetHyperlambdaAsString above could for instance load Hyperlambda from a file, retrieve it from your network, or some other way retrieve a snippet of Hyperlambda text. The HyperlambdaParser.Parse parts above will return your Hyperlambda as its Node equivalent. The Parser class also have an overloaded constructor for taking a Stream instead of a string.

Notice - The Node returned above will be a root node, wrapping all nodes found in your Hyperlambda as children nodes. This is necessary in order to avoid enforcing a single "document node" the way XML does. Once you have a Node object, you can easily reverse the process by using the HyperlambdaGenerator class, and its GetHyperlambda method such as the following illustrates.

using magic.node.extensions.hyperlambda;

var hl1 = GetHyperlambdaAsString();
var result = HyperlambdaParser.Parse(hl1);
var hl2 = HyperlambdaGenerator.GetHyperlambda(result.Children);

Documenting nodes, arguments to slots, etc

When referencing nodes in the documentation for Magic, it is common to reference them like [this], where "this" would be the name of some node - Implying in bold characters, wrapped by square [brackets].

Project website for magic.node

The source code for this repository can be found at, and you can provide feedback, provide bug reports, etc at the same place.

  • Build status
  • Quality Gate Status
  • Bugs
  • Code Smells
  • Coverage
  • Duplicated Lines (%)
  • Lines of Code
  • Maintainability Rating
  • Reliability Rating
  • Security Rating
  • Technical Debt
  • Vulnerabilities

The projects is copyright Thomas Hansen 2023 - 2024, and professionally maintained by AINIRO.IO.

Product 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. 
.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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (35)

Showing the top 5 NuGet packages that depend on magic.node.extensions:

Package Downloads

A generic and dynamic SQL data adapter, allowing you to generate SQL dialects, specific to your database type, such as MySQL or SQL Server. This is the core base class data adapter for Magic. To use package go to


A Super Signals implementation for Magic built on magic.node, allowing you to invoke functionality from one component in another component without any (direct) references between your components. To use package go to


A microscopic and super dynamic scripting language and DSL for .Net Core, based upon Hyperlambda syntax, and Super Signals. This project is the Hyperlambda core implementation (keywords) for Magic. To use package go to

Service implementations for magic.endpoint, that allows you to dynamically evaluate Hyperlambda files associated with a URL. To use package go to


Logging helper slots for Magic, allowing you to inject your own logging implementation, giving you the ability to create log entries from Hyperlambda. To use package go to

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
17.1.7 1,498 1/12/2024
17.1.6 1,483 1/11/2024
17.1.5 1,607 1/5/2024
17.0.1 1,639 1/1/2024
17.0.0 2,239 12/14/2023
16.11.5 2,547 11/12/2023
16.9.0 2,544 10/9/2023
16.7.0 3,611 7/11/2023
16.4.1 3,699 7/2/2023
16.4.0 3,697 6/22/2023
16.3.1 4,003 6/6/2023
16.3.0 3,915 5/28/2023
16.1.9 5,136 4/30/2023
15.10.11 4,934 4/13/2023
15.9.1 6,291 3/26/2023
15.9.0 5,778 3/24/2023
15.8.2 5,775 3/20/2023
15.7.0 6,432 3/6/2023
15.5.0 9,443 1/28/2023
15.2.0 7,899 1/18/2023
15.1.0 8,862 12/28/2022
14.5.7 8,748 12/13/2022
14.5.5 8,886 12/6/2022
14.5.1 9,291 11/23/2022
14.5.0 9,372 11/18/2022
14.4.5 11,132 10/22/2022
14.4.1 11,198 10/22/2022
14.4.0 11,039 10/17/2022
14.3.1 13,925 9/12/2022
14.3.0 11,704 9/10/2022
14.1.3 12,099 8/7/2022
14.1.2 11,699 8/7/2022
14.1.1 11,763 8/7/2022
14.1.0 418 8/7/2022
14.0.14 11,902 7/26/2022
14.0.12 11,797 7/24/2022
14.0.11 11,674 7/23/2022
14.0.10 11,801 7/23/2022
14.0.9 11,754 7/23/2022
14.0.8 12,021 7/17/2022
14.0.5 11,856 7/11/2022
14.0.4 12,245 7/6/2022
14.0.3 12,045 7/2/2022
14.0.2 11,933 7/2/2022
14.0.0 12,411 6/25/2022
13.4.0 14,523 5/31/2022
13.3.4 13,572 5/9/2022
13.3.0 13,790 5/1/2022
13.2.0 13,694 4/21/2022
13.1.0 12,884 4/7/2022
13.0.0 12,265 4/5/2022
11.0.5 13,659 3/2/2022
11.0.4 12,350 2/22/2022
11.0.3 11,684 2/9/2022
11.0.2 12,501 2/6/2022
11.0.1 488 2/5/2022
11.0.0 11,890 2/5/2022
10.0.21 16,491 1/28/2022
10.0.20 12,299 1/27/2022
10.0.19 12,032 1/23/2022
10.0.18 11,571 1/17/2022
10.0.15 9,644 12/31/2021
10.0.14 6,626 12/28/2021
10.0.7 8,792 12/22/2021
10.0.5 7,182 12/18/2021
9.9.9 8,927 11/29/2021
9.9.3 8,356 11/9/2021
9.9.2 6,784 11/4/2021
9.9.0 7,252 10/30/2021
9.8.9 7,196 10/29/2021
9.8.7 7,147 10/27/2021
9.8.6 7,121 10/27/2021
9.8.5 7,162 10/26/2021
9.8.0 9,469 10/20/2021
9.7.5 16,111 10/14/2021
9.7.0 7,360 10/9/2021
9.6.6 414 8/14/2021
9.2.0 32,723 5/26/2021
9.1.4 14,670 4/21/2021
9.1.0 7,933 4/14/2021
9.0.0 7,956 4/5/2021
8.9.9 16,790 3/30/2021
8.9.3 8,755 3/19/2021
8.9.2 7,131 1/29/2021
8.9.1 7,367 1/24/2021
8.9.0 8,611 1/22/2021
8.6.9 11,173 11/8/2020
8.6.6 9,338 11/2/2020
8.6.0 12,181 10/28/2020
8.5.0 8,506 10/23/2020
8.4.0 16,209 10/13/2020
8.3.1 9,148 10/5/2020
8.3.0 7,418 10/3/2020
8.2.2 8,983 9/26/2020
8.2.1 7,386 9/25/2020
8.2.0 7,570 9/25/2020
8.1.17 17,837 9/13/2020
8.1.16 624 9/13/2020
8.1.15 13,675 9/12/2020
8.1.11 9,437 9/11/2020
8.1.10 7,764 9/6/2020
8.1.9 8,481 9/3/2020
8.1.8 7,752 9/2/2020
8.1.7 7,095 8/28/2020
8.1.4 7,093 8/25/2020
8.1.3 7,207 8/18/2020
8.1.2 7,273 8/16/2020
8.1.1 7,325 8/15/2020
8.1.0 496 8/15/2020
8.0.1 14,278 8/7/2020
8.0.0 7,183 8/7/2020
7.0.2 483 8/7/2020
7.0.1 6,252 6/28/2020
7.0.0 8,400 6/28/2020
5.0.0 18,119 2/25/2020
4.0.4 18,543 1/27/2020
4.0.3 6,897 1/27/2020
4.0.2 6,989 1/16/2020
4.0.1 6,929 1/11/2020
4.0.0 6,962 1/5/2020
3.1.0 14,261 11/10/2019
3.0.0 16,794 10/23/2019
2.0.1 18,520 10/15/2019
2.0.0 8,002 10/13/2019
1.1.3 13,447 10/10/2019
1.1.2 22,102 10/6/2019
1.1.0 5,420 10/5/2019
1.0.0 7,189 9/26/2019