Saturday, January 26, 2019

Sasa v1.0.0-RC1

I've finally updated Sasa to target .NET standard 1.3, removed a lot of superfluous abstractions, and rewrote some of the existing API to target third-party packages that are better supported. This may be the last stable release of Sasa, since I'm shifting. Fortunately, the remaining Sasa features are very stable so there's not much need to evolve them further.

You can find the full API documentation for v1.0.0 here, and obviously you can find Sasa itself via nuget. Here's the current breakdown of features:

Sasa Assembly

The core Sasa assembly contains extensions on standard .NET types, and a few new and useful abstractions that are typical for most programs:

  • Sasa.FilePath: structured file system path handling, including jail, ensuring combined paths don't escape a root path.
  • Sasa.Func: extensions to create delegates on methods and for operators with no restrictions, unlike the standard .NET delegate APIs. For instance, open instance delegates to virtual methods are not permitted, but Sasa.Func handles this case transparently.
  • Sasa.Enums: efficient, typed enum operations, contrasted against the untyped System.Enum API.
  • Sasa.Operators: exposes any type's operators as typed delegates.
  • Sasa.Values: numerous useful extension methods on standard types, like formatting streams of values, line/word wrapping, sequence generators, string splitting, etc.
  • Sasa.VFunc/VAction: typical open instance delegates take a reference type as a first parameter, but value types aren't reference types, so they actually accept a pointer/ref to the struct. Sasa.VFunc/VAction are the struct-counterparts of System.Func/Action.
  • Sasa.Emit.Operators: extensions to simplify working with operators during code generation.
  • Sasa.Either: .NET now includes tuples and value tuples, but no sum/variant type. This is satisfied by Sasa.Either.
  • Sasa.Result: encapsulates either a successfully computed value, or an exception.

Sasa.Binary Assembly

This package provides convenient abstraction for working with binary data.

  • Sasa.Binary.Bits: low-level bit shifting, folding, counting ops.
  • Sasa.Binary.Endian: convenient endianness conversions.
  • Sasa.Binary.UnionXX: types that simplify converting between various types of the same size.
  • Sasa.Binary.IO.BinaryReader/Writer: portable binary reader/writers.

Sasa.Collections Assembly

This package provides a number of very efficient immutable collections, and some extensions on standard .NET collection types.

  • Sasa.Collections.Arrays: extension methods on arrays, to immutably insert, duplicate, append, etc.
  • Sasa.Collections.Fifo: an immutable first-in-first-out queue data structure.
  • Sasa.Collections.FingerTree: an immutable finger-tree.
  • Sasa.Collections.Lifo: an immutable last-in-first-out stack data structure.
  • Sasa.Collections.Vector: the fastest immutable vector for .NET.
  • Sasa.Collections.Trie: the fastest immutable dictionary for .NET.

Sasa.Concurrency Assembly

This packages provides a few abstractions for writing concurrent programs.

  • Sasa.Atomics: convenient atomic operations, including atomic and lock-free read/write, load-linked/store-conditional, etc.
  • Sasa.LLSC: a convenient abstraction encapsulating a load-linked/store-conditional variable.
  • Sasa.RWLock: the most lightweight read/write lock available for .NET. Only 4 bytes!

Sasa.Linq Assembly

This packages provides sophisticated extensions on IEnumerable.

  • Sasa.Linq.Enumerables: extensions to compute the difference between two IEnumerable streams.
  • Sasa.Linq.Change: describes a difference between two enumerable streams at a given position.
  • Sasa.Linq.ChangeType: the type of difference.

Sasa.Linq.Expressions Assembly

This package provides some abstractions for dealing with LINQ expressions.

  • Sasa.Linq.Expressions.Expression: a lightweight typed wrapper around System.Linq.Expressions.Expression.
  • Sasa.Linq.Expressions.Parameter: a lightweight wrapper around System.Linq.Expressions.ParameterExpression.
  • Sasa.Linq.Expressions.ExpressionVisitor: base class for implementing a basic visitor over LINQ expressions.
  • Sasa.Linq.Expressions.IdentityVisitor: an implementation of ExpressionVisitor that by default simply returns the same expression. Useful if you only want to transform only a subset of expressions.
  • Sasa.Linq.Expressions.ErrorVisitor: an implementation of ExpressionVisitor that by default simply throws an error. Useful if you want to ensure you handle all expressions.

Sasa.Mime Assembly

This package makes handling media types and file extension associations convenient.

Sasa.Net Assembly

This package exposes abstractions for network protocols and mail handling.

  • Sasa.Net.Texty: base interface for text-based protocols.
  • Sasa.Net.Pop3.*: abstractions implementing the basic POP3 protocol client.
  • Sasa.Net.Mail.*: extensions on MimeKit's mail abstractions.

Sasa.Numerics Assembly

This package provides a few convenient numerical and statistical calculations.

Sasa.Parsing Assembly

This package provides a few abstractions to creating lexers and parsers via embedded DSLs.

  • Sasa.Parsing.Lexing.*: abstractions for lexing.
  • Sasa.Parsing.Pratt.*: abstractions for easy, extensible and declarative Pratt parsing.

Sasa.Web Assembly

This package provides some convenient extensions for internet programs.

  • Sasa.Web.Uris: efficient URI encoding, decoding and URI query parameter extraction.
  • Sasa.Web.Url64: a base64 encoding that's safe to use in URIs. Much more compact than typical encodings.

SasaMetal Package

This package provides a more useful equivalent to sqlmetal for LINQ 2 SQL. It enables you to map columns and associations to typed properties, including using enums.

Deprecations

The final version of Sasa v1.0.0 will probably remove types or methods which are currently marked obsolete because there are now better alternatives:

  • Sasa.Net: Sasa now uses MailKit for all of its parsing methods, so you're better off using that package directly. Some of the extension methods may remain.
  • Sasa.T, Sasa.Pair, Sasa.Triple, Sasa.Quad: the new System.ValueType package has better integration with languages and the runtime.

Previous version of Sasa had a few more experimental and now unnecessary packages:

  • Sasa.Arrow
  • Sasa.FP
  • Sasa.Partial
  • Sasa.IoC
  • Sasa.Contracts
  • Sasa.Dynamics: see my package Dynamics.NET for further work along these lines.
  • Sasa.Data: LINQ to SQL is not supported on .NET standard, so you will have to use the old package if you still need this.