YAMLScript 0.2.2

dotnet add package YAMLScript --version 0.2.2
                    
NuGet\Install-Package YAMLScript -Version 0.2.2
                    
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="YAMLScript" Version="0.2.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="YAMLScript" Version="0.2.2" />
                    
Directory.Packages.props
<PackageReference Include="YAMLScript" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add YAMLScript --version 0.2.2
                    
#r "nuget: YAMLScript, 0.2.2"
                    
#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.
#:package YAMLScript@0.2.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=YAMLScript&version=0.2.2
                    
Install as a Cake Addin
#tool nuget:?package=YAMLScript&version=0.2.2
                    
Install as a Cake Tool

YS / YAMLScript

Add Logic to Your YAML Files

Synopsis

Load file.yaml with YS:

!YS-v0:

# Get data from external sources:
names-url =:
  'github:dominictarr/random-name/first-names.json'

name-list =: names-url:curl:json/load

# Data object with literal keys and generated values:
name:: name-list:shuffle:first
aka:: name-list:rand-nth
age:: &num 2 * 3 * 7
color:: &hue
  rand-nth: qw(red green blue yellow)
title:: "$(*num) shades of $(*hue)."

and get:

{
  "name": "Dolores",
  "aka": "Anita",
  "age": 42,
  "color": "green",
  "title": "42 shades of green."
}

Description

YS is a functional programming language with a clean YAML syntax.

YS can be used for enhancing ordinary YAML files with functional operations, such as:

  • Import (parts of) other YAML files to any node
  • String interpolation including function calls
  • Data transforms including ones defined by you

This YS library should be a drop-in replacement for your current YAML loader!

Most existing YAML files are already valid YS files. This means that YS works as a normal YAML loader, but can also evaluate functional expressions if asked to.

Under the hood, YS code compiles to the Clojure programming language. This makes YS a complete functional programming language right out of the box.

Even though YS compiles to Clojure, and Clojure compiles to Java, there is no dependency on Java or the JVM. YS is compiled to a native shared library (libys.so) that can be used by any programming language that can load shared libraries.

To see the Clojure code that YS compiles to, you can use the YS CLI binary ys to run:

$ ys --compile file.ys
(let
 [names-url "https://raw.githubusercontent.com/dominictarr/random-name/master/first-names.json"
  name-list (json/load (curl names-url))]
 (%
  "name" (first (shuffle name-list))
  "aka" (rand-nth name-list)
  "age" (_& 'num (mul+ 2 3 7))
  "color" (_& 'hue (rand-nth (qw red green blue yellow)))
  "title" (str (_** 'num) " shades of " (_** 'hue) ".")))

YAMLScript C# Implementation Details

This document describes the implementation details of the YAMLScript C# binding.

Architecture

The C# binding consists of several key components:

  1. Native FFI Layer
  • Uses C# P/Invoke to interface with YAMLScript core
  • Handles memory management and resource cleanup
  • Manages GraalVM isolates
  1. High-Level API
  • Provides an idiomatic C# interface
  • Handles type conversions between C# and YAMLScript
  • Implements proper error handling and exceptions
  1. Testing Infrastructure
  • Unit tests for API functionality
  • Integration tests with YAMLScript core
  • Memory leak detection
  • Performance benchmarks

Implementation Notes

FFI Integration

The binding uses P/Invoke to interface with the YAMLScript core library. Memory management is handled through proper disposal patterns and the IDisposable interface.

Type System

YAMLScript types are mapped to C# types as follows:

  • YAMLScript null → C# null
  • YAMLScript boolean → C# bool
  • YAMLScript number → C# double
  • YAMLScript string → C# string
  • YAMLScript array → C# IList<object>
  • YAMLScript object → C# IDictionary<string, object>

Error Handling

Errors from the YAMLScript runtime are converted to appropriate C# exceptions with meaningful stack traces and context information.

Memory Management

The binding implements proper memory management through:

  • Deterministic disposal of unmanaged resources
  • Reference counting for shared resources
  • Automatic cleanup of GraalVM isolates

Build System

The project uses the standard .NET build system with MSBuild, integrated with the YAMLScript common build infrastructure.

Testing Strategy

Tests are implemented using xUnit and cover:

  • API functionality
  • Error conditions
  • Memory management
  • Performance benchmarks
  • Edge cases

Dependencies

  • .NET 8.0 or later
  • YAMLScript core library
  • xUnit for testing

See Also

Authors

YAMLScript C# Binding Authors

Maintainers

Contributors

This file will be updated as contributors add to the C# binding.

Copyright 2022-2025 Ingy döt Net ingy@ingy.net

This project is licensed under the terms of the MIT license. See LICENSE for more details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.2 33 7/18/2025
0.2.1 124 7/10/2025